diff --git a/simulations/airshower_beacon_simulation/ac_show_signal_to_noise.py b/simulations/airshower_beacon_simulation/ac_show_signal_to_noise.py index 8141abe..46aac64 100755 --- a/simulations/airshower_beacon_simulation/ac_show_signal_to_noise.py +++ b/simulations/airshower_beacon_simulation/ac_show_signal_to_noise.py @@ -15,7 +15,6 @@ from earsim import REvent, block_filter import aa_generate_beacon as beacon import lib - if __name__ == "__main__": from os import path import sys @@ -24,10 +23,14 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" fig_dir = "./figures/" - show_plots = not False + show_plots = args.show_plots #### fname_dir = path.dirname(fname) diff --git a/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py b/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py index 7da7f03..c638e18 100755 --- a/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py +++ b/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py @@ -21,14 +21,19 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + parser.add_argument('--no-use-AxB', dest='use_AxB_trace', action='store_false') + args = parser.parse_args() + f_beacon_band = (49e-3,55e-3) #GHz allow_frequency_fitting = False read_frequency_from_file = True - use_AxB_trace = True if len(sys.argv) < 2 else bool(int(sys.argv[1])) + use_AxB_trace = args.use_AxB_trace use_beacon_trace = True # only applicable if AxB = False - show_plots = True + show_plots = args.show_plots fname = "ZH_airshower/mysim.sry" diff --git a/simulations/airshower_beacon_simulation/bb_measure_true_phase.py b/simulations/airshower_beacon_simulation/bb_measure_true_phase.py index 0c3e6b5..b0791a2 100755 --- a/simulations/airshower_beacon_simulation/bb_measure_true_phase.py +++ b/simulations/airshower_beacon_simulation/bb_measure_true_phase.py @@ -18,9 +18,13 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" c_light = lib.c_light - show_plots = True + show_plots = args.show_plots remove_absolute_phase_offset_first_antenna = True # takes precedence remove_absolute_phase_offset_minimum = True diff --git a/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py b/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py index 70c4512..6d78b96 100755 --- a/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py +++ b/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py @@ -19,10 +19,14 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" c_light = 3e8*1e-9 - show_plots = True - ref_ant_id = None if not True else [50] # leave None for all baselines + show_plots = args.show_plots + ref_ant_id = None if True else [50] # leave None for all baselines #### fname_dir = path.dirname(fname) diff --git a/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py b/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py index 242e3fc..894780d 100755 --- a/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py +++ b/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py @@ -21,9 +21,13 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" - show_plots = True + show_plots = args.show_plots ref_ant_id = None # leave None for all baselines #### diff --git a/simulations/airshower_beacon_simulation/ca_period_from_shower.py b/simulations/airshower_beacon_simulation/ca_period_from_shower.py index 6d2aaf7..82e562c 100755 --- a/simulations/airshower_beacon_simulation/ca_period_from_shower.py +++ b/simulations/airshower_beacon_simulation/ca_period_from_shower.py @@ -149,11 +149,15 @@ if __name__ == "__main__": atm = AtmoCal() + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" fig_dir = "./figures/periods_from_shower_figures/" fig_subdir = path.join(fig_dir, 'shifts/') - show_plots = False + show_plots = args.show_plots allowed_ks = [ -2, -1, 0, 1, 2] Xref = 400 diff --git a/simulations/airshower_beacon_simulation/cb_report_measured_antenna_time_offsets.py b/simulations/airshower_beacon_simulation/cb_report_measured_antenna_time_offsets.py index 0f89f0d..dd5265f 100755 --- a/simulations/airshower_beacon_simulation/cb_report_measured_antenna_time_offsets.py +++ b/simulations/airshower_beacon_simulation/cb_report_measured_antenna_time_offsets.py @@ -18,10 +18,14 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" fig_dir = "./figures" # set None to disable saving - show_plots = not False + show_plots = args.show_plots #### fname_dir = path.dirname(fname) diff --git a/simulations/airshower_beacon_simulation/da_reconstruction.py b/simulations/airshower_beacon_simulation/da_reconstruction.py index 55cbf46..fcbd59d 100755 --- a/simulations/airshower_beacon_simulation/da_reconstruction.py +++ b/simulations/airshower_beacon_simulation/da_reconstruction.py @@ -28,11 +28,15 @@ if __name__ == "__main__": atm = AtmoCal() + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" fig_dir = "./figures/" fig_subdir = path.join(fig_dir, 'reconstruction') - show_plots = False + show_plots = args.show_plots #### fname_dir = path.dirname(fname) diff --git a/simulations/airshower_beacon_simulation/db_longitudinal_figure.py b/simulations/airshower_beacon_simulation/db_longitudinal_figure.py index 980bb7d..b84f6e3 100755 --- a/simulations/airshower_beacon_simulation/db_longitudinal_figure.py +++ b/simulations/airshower_beacon_simulation/db_longitudinal_figure.py @@ -24,10 +24,14 @@ if __name__ == "__main__": if os.name == 'posix' and "DISPLAY" not in os.environ: matplotlib.use('Agg') + from scriptlib import MyArgumentParser + parser = MyArgumentParser() + args = parser.parse_args() + fname = "ZH_airshower/mysim.sry" fig_dir = "./figures/" - show_plots = False + show_plots = args.show_plots #### fname_dir = path.dirname(fname) diff --git a/simulations/airshower_beacon_simulation/scriptlib.py b/simulations/airshower_beacon_simulation/scriptlib.py new file mode 100644 index 0000000..766aab6 --- /dev/null +++ b/simulations/airshower_beacon_simulation/scriptlib.py @@ -0,0 +1,20 @@ +""" +Some preconfigured ArgumentParser +""" + +from argparse import ArgumentParser + +def MyArgumentParser(default_show_plots=False, **kwargs): + """ + A somewhat preconfigured ArgumentParser + + Set show_plots=True to by default enable showing plots. + """ + parser = ArgumentParser(**kwargs) + + # Whether to show plots + parser.add_argument('--show-plots', action='store_true') + parser.add_argument('--no-show-plots', dest='show-plots', action='store_false') + parser.set_defaults(show_plots=default_show_plots) + + return parser