From 7eaa97d0cbbc89c1cb30b84f424bda41d48528b7 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Mon, 1 May 2023 17:43:20 +0200 Subject: [PATCH] ZH: rename clock repair-all mode to repair-full --- airshower_beacon_simulation/Makefile | 4 ++-- airshower_beacon_simulation/aa_generate_beacon.py | 4 ++-- airshower_beacon_simulation/da_reconstruction.py | 14 ++++++++++---- .../db_longitudinal_figure.py | 6 ++++-- .../dc_grid_power_time_fixes.py | 9 ++++----- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/airshower_beacon_simulation/Makefile b/airshower_beacon_simulation/Makefile index 7a87ca5..0c404f7 100644 --- a/airshower_beacon_simulation/Makefile +++ b/airshower_beacon_simulation/Makefile @@ -79,8 +79,8 @@ vary-fixes: # reconstruct: - ./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} + ./da_reconstruction.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR} --input-fname ${INPUT_DIR} --clock-repair full + ./db_longitudinal_figure.py --no-show-plots --fig-dir=${FIG_DIR} --data-dir ${DATA_DIR} --clock-repair full dist-clean: rm -vf ${DATA_DIR}/ diff --git a/airshower_beacon_simulation/aa_generate_beacon.py b/airshower_beacon_simulation/aa_generate_beacon.py index 0422661..5f833fe 100755 --- a/airshower_beacon_simulation/aa_generate_beacon.py +++ b/airshower_beacon_simulation/aa_generate_beacon.py @@ -22,8 +22,8 @@ beacon_snr_fname = 'beacon_snr.json' airshower_snr_fname = 'airshower_snr.json' c_light = lib.c_light -def read_antenna_clock_repair_offsets(antennas, mode='all', freq_name=None): - valid_modes = ['orig', 'ks', 'phases', 'all'] +def read_antenna_clock_repair_offsets(antennas, mode='full', freq_name=None): + valid_modes = ['orig', 'ks', 'phases', 'full'] time_offsets = [] for i, ant in enumerate(antennas): diff --git a/airshower_beacon_simulation/da_reconstruction.py b/airshower_beacon_simulation/da_reconstruction.py index 2bc10de..e1813ae 100755 --- a/airshower_beacon_simulation/da_reconstruction.py +++ b/airshower_beacon_simulation/da_reconstruction.py @@ -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)') + parser.add_argument('--clock-repair', type=str, default='full', choices=['orig', 'ks', 'phases', 'full'], help='How to repair the clock offsets. (Default: %(default)s)') args = parser.parse_args() if not args.input_fname: @@ -43,7 +44,8 @@ if __name__ == "__main__": figsize = (12,8) fig_dir = args.fig_dir - fig_subdir = path.join(fig_dir, 'reconstruction') + clock_repair_mode = args.clock_repair + fig_subdir = path.join(fig_dir, 'reconstruction', clock_repair_mode) show_plots = args.show_plots apply_signal_window_from_max = True @@ -52,7 +54,7 @@ if __name__ == "__main__": #### fname_dir = args.data_dir antennas_fname = path.join(fname_dir, beacon.antennas_fname) - pickle_fname = path.join(fname_dir, 'res.pkl') + pickle_fname = path.join(fname_dir, 'res-'+clock_repair_mode+'.pkl') tx_fname = path.join(fname_dir, beacon.tx_fname) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname) @@ -82,7 +84,7 @@ if __name__ == "__main__": f_beacon = ev.antennas[0].beacon_info[freq_name]['freq'] # Repair clock offsets with the measured offsets - measured_repair_offsets = beacon.read_antenna_clock_repair_offsets(ev.antennas, mode='phases', freq_name=freq_name) + measured_repair_offsets = beacon.read_antenna_clock_repair_offsets(ev.antennas, mode=clock_repair_mode, freq_name=freq_name) for i, ant in enumerate(ev.antennas): # t_AxB will be set by the rit.set_pol_and_bp function ev.antennas[i].orig_t = ev.antennas[i].t @@ -201,7 +203,11 @@ if __name__ == "__main__": fig.savefig(path.join(fig_dir, path.basename(__file__)+f'.traces.A{i}.pdf')) - N_X, Xlow, Xhigh = 23, 100, 1200 + if False: # very fine grid + N_X, Xlow, Xhigh = 23, 100, 1200 + else: + N_X, Xlow, Xhigh = 6, 200, 1200 + with joblib.parallel_backend("loky"): res = rit.reconstruction(ev, outfile=fig_subdir+'/fig.pdf', slice_outdir=fig_subdir+'/', Xlow=Xlow, N_X=N_X, Xhigh=Xhigh, disable_pol_and_bp=True) diff --git a/airshower_beacon_simulation/db_longitudinal_figure.py b/airshower_beacon_simulation/db_longitudinal_figure.py index c5da800..4ec7db8 100755 --- a/airshower_beacon_simulation/db_longitudinal_figure.py +++ b/airshower_beacon_simulation/db_longitudinal_figure.py @@ -26,15 +26,17 @@ if __name__ == "__main__": from scriptlib import MyArgumentParser parser = MyArgumentParser() + parser.add_argument('--clock-repair', type=str, default='full', choices=['orig', 'ks', 'phases', 'full'], help='How to repair the clock offsets. (Default: %(default)s)') args = parser.parse_args() fig_dir = args.fig_dir + clock_repair_mode = args.clock_repair show_plots = args.show_plots #### fname_dir = args.data_dir antennas_fname = path.join(fname_dir, beacon.antennas_fname) - pickle_fname = path.join(fname_dir, 'res.pkl') + pickle_fname = path.join(fname_dir, 'res-'+clock_repair_mode+'.pkl') # create fig_dir if fig_dir: @@ -53,4 +55,4 @@ if __name__ == "__main__": fig = rit.longitudinal_figure(res.dl[0], res.dX[0], res.profile_rit[0], mode=mode) if fig_dir: - fig.savefig(path.join(fig_dir, path.basename(__file__) + f".{mode}.pdf")) + fig.savefig(path.join(fig_dir, path.basename(__file__) + f".{clock_repair_mode}.{mode}.pdf")) diff --git a/airshower_beacon_simulation/dc_grid_power_time_fixes.py b/airshower_beacon_simulation/dc_grid_power_time_fixes.py index b725657..57af6af 100755 --- a/airshower_beacon_simulation/dc_grid_power_time_fixes.py +++ b/airshower_beacon_simulation/dc_grid_power_time_fixes.py @@ -79,7 +79,7 @@ def save_overlapping_traces_figure(test_location, ev, N_plot = 30, wx=200, title return fig if __name__ == "__main__": - valid_cases = ['no_offset', 'repair_none', 'repair_phases', 'repair_all'] + valid_cases = ['no_offset', 'repair_none', 'repair_phases', 'repair_full'] import sys import os @@ -121,7 +121,6 @@ if __name__ == "__main__": #### 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) beacon_snr_fname = path.join(fname_dir, beacon.beacon_snr_fname) @@ -165,7 +164,7 @@ if __name__ == "__main__": 'no_offset': "no clock offset", 'repair_none': "unrepaired clock offset", 'repair_phases': "phase resolved clock offsets repaired", - 'repair_all': "final measured clock offsets repaired" + 'repair_full': "final measured clock offsets repaired" } # For now only implement using one freq_name @@ -248,7 +247,7 @@ if __name__ == "__main__": for case in wanted_cases: print(f"Starting {case} figure") # Repair clock offsets with the measured offsets - transl_modes = {'no_offset':'orig', 'repair_phases':'phases', 'repair_all':'all'} + transl_modes = {'no_offset':'orig', 'repair_phases':'phases', 'repair_full':'full'} if case in transl_modes: transl_mode = transl_modes[case] @@ -310,7 +309,7 @@ if __name__ == "__main__": # # and plot overlapping traces at two other locations # - if True: + if False: for dist in [ 0.5, 5, 10, 50, 100]: # only add distance horizontally location = maxp_loc + np.sqrt(dist*1e3)*np.array([1,1,0])