ZH: separate data-dir and input-dir on cli

This commit is contained in:
Eric Teunis de Boone 2023-02-02 17:55:37 +01:00
parent a66782064e
commit 47916e2e88
15 changed files with 76 additions and 50 deletions

View file

@ -19,35 +19,40 @@ PB_HIGH ?= 0.08
REF_ANTS ?=
DATA_DIR ?= ./data
INPUT_DIR ?= ./ZH_airshower/
all: beacon clocks phases findks vary-fixes reconstruct
beacon:
./aa_generate_beacon.py -N ${TRACE_N} -P ${TRACE_PRE} -n ${NOISE_SIGMA} -a ${BEAC_AMP} -f ${BEAC_F} -l ${PB_LOW} -u ${PB_HIGH} -d ${BEAC_DECAY} | tee ${FIG_DIR}/aa.log
./ab_modify_clocks.py 0 | tee ${FIG_DIR}/ab.log
./ac_show_signal_to_noise.py --no-show-plots --fig-dir=${FIG_DIR}
./view_beaconed_antenna.py 72 -p x -p y -p z -p n -p b --ft --no-show-plots --fig-dir=${FIG_DIR}
./aa_generate_beacon.py -N ${TRACE_N} -P ${TRACE_PRE} -n ${NOISE_SIGMA} -a ${BEAC_AMP} -f ${BEAC_F} -l ${PB_LOW} -u ${PB_HIGH} -d ${BEAC_DECAY} --data-dir ${DATA_DIR} --input-fname ${INPUT_DIR} | tee ${FIG_DIR}/aa.log
./ab_modify_clocks.py 0 --data-dir ${DATA_DIR} | tee ${FIG_DIR}/ab.log
./ac_show_signal_to_noise.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
./view_beaconed_antenna.py 72 -p x -p y -p z -p n -p b --ft --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
clocks:
./ab_modify_clocks.py ${CLK_DEV} --gaussian
./ab_modify_clocks.py ${CLK_DEV} --gaussian --data-dir ${DATA_DIR}
phases:
./ba_measure_beacon_phase.py --no-show-plots --fig-dir=${FIG_DIR}
./bb_measure_clock_phase.py --no-show-plots --fig-dir=${FIG_DIR}
./bc_baseline_phase_deltas.py ${REF_ANTS} --no-show-plots --fig-dir=${FIG_DIR}
./bd_antenna_phase_deltas.py --no-show-plots --fig-dir=${FIG_DIR}
./ba_measure_beacon_phase.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
./bb_measure_clock_phase.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
./bc_baseline_phase_deltas.py ${REF_ANTS} --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
./bd_antenna_phase_deltas.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
findks:
./ca_period_from_shower.py --max-k ${MAX_K} --no-show-plots --fig-dir=${FIG_DIR}
./cb_report_measured_antenna_time_offsets.py --no-show-plots --fig-dir=${FIG_DIR}
./ca_period_from_shower.py --input-fname ${INPUT_DIR} --max-k ${MAX_K} --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
./cb_report_measured_antenna_time_offsets.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
vary-fixes:
./dc_grid_power_time_fixes.py --no-show-plots --fig-dir=${FIG_DIR}
./dc_grid_power_time_fixes.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR} --input-fname ${INPUT_DIR}
reconstruct:
./da_reconstruction.py --no-show-plots --fig-dir=${FIG_DIR}
./db_longitudinal_figure.py --no-show-plots --fig-dir=${FIG_DIR}
./da_reconstruction.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR} --input-fname ${INPUT_DIR}
./db_longitudinal_figure.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR}
dist-clean:
rm -f ZH_airshower/antennas.hdf5
rm -f ZH_airshower/clocks.csv
rm -f ZH_airshower/tx.json
rm -vf ${DATA_DIR}/antennas.hdf5
rm -vf ${DATA_DIR}/ca_breaked_run
rm -vf ${DATA_DIR}/res.pkl
rm -vf ${DATA_DIR}/clocks.csv
rm -vf ${DATA_DIR}/tx.json

View file

@ -289,16 +289,24 @@ if __name__ == "__main__":
parser.add_argument('-N', '--new-trace-length', type=float, help='resize airshower trace (Default: %(default)d)', default=1e4)
parser.add_argument('-P', '--pre-trace-length', type=float, help='amount of trace to prepend the airshower when resizing (Default: %(default)d)', default=2e3)
# Input directory
parser.add_argument('--input-fname', type=str, default=None, help='Path to mysim.sry, either directory or path. If empty it takes DATA_DIR and appends mysim.sry. (Default: %(default)s)')
parser.add_argument('--data-dir', type=str, default="./ZH_airshower", help='Path to Data Directory. (Default: %(default)s)')
args = parser.parse_args()
if not args.input_fname:
args.input_fname = args.data_dir
if path.isdir(args.input_fname):
args.input_fname = path.join(args.input_fname, "mysim.sry")
##
## End of ArgumentParsing
##
rng = np.random.default_rng()
fname = "ZH_airshower/mysim.sry"
# Noise properties
noise_sigma = args.noise_sigma # mu V/m set to None to ignore
@ -337,7 +345,7 @@ if __name__ == "__main__":
block_filter = lambda x, dt, low, high: x
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
tx_fname = path.join(fname_dir, tx_fname)
antennas_fname = path.join(fname_dir, antennas_fname)
@ -354,7 +362,7 @@ if __name__ == "__main__":
print("Noise sigma [muV/m]:", noise_sigma)
# read in antennas
ev = REvent(fname)
ev = REvent(args.input_fname)
N_antennas = len(ev.antennas)
# initialize hdf5 file

View file

@ -27,6 +27,8 @@ if __name__ == "__main__":
parser.add_argument('--gaussian', action='store_const', const='gauss', dest='dist_type')
parser.set_defaults(dist_type='gauss')
parser.add_argument('--data-dir', type=str, default="./data", help='Path to Data Directory. (Default: %(default)s)')
args = parser.parse_args()
max_clock_offset = args.max_clock_offset # ns
@ -35,10 +37,8 @@ if __name__ == "__main__":
seed = 12345
rng = np.random.default_rng(seed)
fname = "ZH_airshower/mysim.sry"
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
clocks_fname = path.join(fname_dir, clocks_fname)
antennas_fname = path.join(fname_dir, beacon.antennas_fname)

View file

@ -33,14 +33,13 @@ if __name__ == "__main__":
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
fig_dir = args.fig_dir
show_plots = args.show_plots
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
tx_fname = path.join(fname_dir, beacon.tx_fname)

View file

@ -35,13 +35,12 @@ if __name__ == "__main__":
show_plots = args.show_plots
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
print("use_AxB_trace:", use_AxB_trace, "use_beacon_trace:",use_beacon_trace)
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
fig_dir = args.fig_dir # set None to disable saving

View file

@ -22,7 +22,6 @@ if __name__ == "__main__":
parser = MyArgumentParser()
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
c_light = lib.c_light
show_plots = args.show_plots
@ -31,7 +30,7 @@ if __name__ == "__main__":
remove_absolute_phase_offset_minimum = True
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
fig_dir = args.fig_dir # set None to disable saving

View file

@ -24,14 +24,13 @@ if __name__ == "__main__":
parser.add_argument('ref_ant_idx', default=None, nargs='*', type=int, help='Reference Antenna Indices for Baselines(ref_ant_idx, *). Leave empty to use all available antennas. (Default: %(default)s) ')
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
c_light = 3e8*1e-9
show_plots = args.show_plots
ref_ant_id = args.ref_ant_idx # leave None for all baselines
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname

View file

@ -25,14 +25,13 @@ if __name__ == "__main__":
parser = MyArgumentParser()
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
show_plots = args.show_plots
ref_ant_id = None # leave None for all baselines
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if False else antennas_fname
fig_dir = args.fig_dir # set None to disable saving

View file

@ -152,9 +152,15 @@ if __name__ == "__main__":
from scriptlib import MyArgumentParser
parser = MyArgumentParser(default_fig_dir="./figures/periods_from_shower_figures/")
parser.add_argument('--max-k', type=float, default=2, help='Maximum abs(k) allowed to be shifted. (Default: %(default)d)')
parser.add_argument('--input-fname', type=str, default=None, help='Path to mysim.sry, either directory or path. If empty it takes DATA_DIR and appends mysim.sry. (Default: %(default)s)')
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
if not args.input_fname:
args.input_fname = args.data_dir
if path.isdir(args.input_fname):
args.input_fname = path.join(args.input_fname, "mysim.sry")
figsize = (12,8)
fig_dir = args.fig_dir
@ -170,7 +176,7 @@ if __name__ == "__main__":
apply_signal_window_from_max = True
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname
@ -188,7 +194,7 @@ if __name__ == "__main__":
# Read in antennas from file
_, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
# Read original REvent
ev = REvent(fname)
ev = REvent(args.input_fname)
# .. patch in our antennas
ev.antennas = antennas

View file

@ -22,14 +22,13 @@ if __name__ == "__main__":
parser = MyArgumentParser()
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
fig_dir = args.fig_dir # set None to disable saving
show_plots = args.show_plots
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname

View file

@ -31,9 +31,15 @@ if __name__ == "__main__":
from scriptlib import MyArgumentParser
parser = MyArgumentParser()
parser.add_argument('--input-fname', type=str, default=None, help='Path to mysim.sry, either directory or path. If empty it takes DATA_DIR and appends mysim.sry. (Default: %(default)s)')
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
if not args.input_fname:
args.input_fname = args.data_dir
if path.isdir(args.input_fname):
args.input_fname = path.join(args.input_fname, "mysim.sry")
figsize = (12,8)
fig_dir = args.fig_dir
@ -43,7 +49,7 @@ if __name__ == "__main__":
remove_beacon_from_traces = True
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
pickle_fname = path.join(fname_dir, 'res.pkl')
tx_fname = path.join(fname_dir, beacon.tx_fname)
@ -58,7 +64,7 @@ if __name__ == "__main__":
_, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
_, __, txdata = beacon.read_tx_file(tx_fname)
# Read original REvent
ev = REvent(fname)
ev = REvent(args.input_fname)
# .. patch in our antennas
ev.antennas = antennas

View file

@ -28,13 +28,11 @@ if __name__ == "__main__":
parser = MyArgumentParser()
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
fig_dir = args.fig_dir
show_plots = args.show_plots
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
pickle_fname = path.join(fname_dir, 'res.pkl')

View file

@ -32,6 +32,7 @@ if __name__ == "__main__":
from scriptlib import MyArgumentParser
parser = MyArgumentParser()
parser.add_argument('--input-fname', type=str, default=None, help='Path to mysim.sry, either directory or path. If empty it takes DATA_DIR and appends mysim.sry. (Default: %(default)s)')
group = parser.add_argument_group('figures')
for case in valid_cases:
@ -39,12 +40,17 @@ if __name__ == "__main__":
args = parser.parse_args()
if not args.input_fname:
args.input_fname = args.data_dir
if path.isdir(args.input_fname):
args.input_fname = path.join(args.input_fname, "mysim.sry")
wanted_cases = args.figures
if not wanted_cases or 'all' in wanted_cases:
wanted_cases = valid_cases
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
fig_dir = args.fig_dir
@ -54,7 +60,7 @@ if __name__ == "__main__":
apply_signal_window_from_max = True
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
pickle_fname = path.join(fname_dir, 'res.pkl')
tx_fname = path.join(fname_dir, beacon.tx_fname)
@ -67,7 +73,7 @@ if __name__ == "__main__":
_, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
_, __, txdata = beacon.read_tx_file(tx_fname)
# Read original REvent
ev = REvent(fname)
ev = REvent(args.input_fname)
bak_ants = ev.antennas
# .. patch in our antennas
ev.antennas = antennas

View file

@ -7,6 +7,7 @@ from argparse import ArgumentParser
def MyArgumentParser(
default_fig_dir='./figures',
default_show_plots=False,
default_data_dir='./ZH_airshower',
**kwargs):
"""
A somewhat preconfigured ArgumentParser to be shared across
@ -22,6 +23,9 @@ def MyArgumentParser(
group1.add_argument('--show-plots', action='store_true', default=default_show_plots, help='Default: %(default)s')
group1.add_argument('--no-show-plots', dest='show-plots', action='store_false')
# Data directory
parser.add_argument('--data-dir', type=str, default=default_data_dir, help='Path to Data Directory. (Default: %(default)s)')
# Figures directory
parser.add_argument('--fig-dir', type=str, default=default_fig_dir, help='Set None to disable saving figures. (Default: %(default)s)')

View file

@ -27,7 +27,6 @@ if __name__ == "__main__":
args = parser.parse_args()
fname = "ZH_airshower/mysim.sry"
figsize = (12,8)
plot_ft_amplitude = args.ft
@ -40,7 +39,7 @@ if __name__ == "__main__":
args.polarisations = ['x','y', 'z']
####
fname_dir = path.dirname(fname)
fname_dir = args.data_dir
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
tx_fname = path.join(fname_dir, beacon.tx_fname)