From 6c0ae17b07673dbcd74314ddfa6ace6437da4c4a Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Fri, 25 Nov 2022 17:46:02 +0100 Subject: [PATCH] ZH: nicefy some output + CLI --- .../airshower_beacon_simulation/ba_beacon_phases.py | 2 +- .../airshower_beacon_simulation/bb_beacon_true_phases.py | 4 ++-- .../airshower_beacon_simulation/bc_beacon_periods.py | 7 ++++--- simulations/airshower_beacon_simulation/bd_time_diffs.py | 6 ++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/simulations/airshower_beacon_simulation/ba_beacon_phases.py b/simulations/airshower_beacon_simulation/ba_beacon_phases.py index 7a3571c..85f42b1 100755 --- a/simulations/airshower_beacon_simulation/ba_beacon_phases.py +++ b/simulations/airshower_beacon_simulation/ba_beacon_phases.py @@ -22,7 +22,7 @@ if __name__ == "__main__": allow_frequency_fitting = False read_frequency_from_file = True - use_AxB_trace = True + use_AxB_trace = True if len(sys.argv) < 2 else bool(int(sys.argv[1])) use_beacon_trace = True # only applicable if AxB = False show_plots = True diff --git a/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py b/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py index 394fb52..1127158 100755 --- a/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py +++ b/simulations/airshower_beacon_simulation/bb_beacon_true_phases.py @@ -28,7 +28,7 @@ def antenna_true_phases(tx, antennas, freq_name, c_light=3e8): geom_time = lib.geometry_time(tx, ant, c_light=c_light) geom_phase = geom_time * 2*np.pi*f_beacon - true_phases[i] = lib.phase_mod(lib.phase_mod(measured_phase) - lib.phase_mod(geom_phase)) + true_phases[i] = lib.phase_mod( lib.phase_mod(geom_phase) - lib.phase_mod(measured_phase)) return true_phases @@ -67,7 +67,7 @@ if __name__ == "__main__": # Remove the phase from one antenna # this is a free parameter # (only required for absolute timing) - if False: + if True: if True: # just take the first phase minimum_phase = -1*true_phases[0] else: # take the minimum diff --git a/simulations/airshower_beacon_simulation/bc_beacon_periods.py b/simulations/airshower_beacon_simulation/bc_beacon_periods.py index 652d051..307b1cc 100755 --- a/simulations/airshower_beacon_simulation/bc_beacon_periods.py +++ b/simulations/airshower_beacon_simulation/bc_beacon_periods.py @@ -87,7 +87,6 @@ if __name__ == "__main__": # Plotting for one or two iterations if show_plots and (i in [ 1, 57 ] or k_period > 3): # More than three periods is quite much so report it - print('i',i,'k[T]',k_period, 'rest[ns]',t_rest, 'T[ns]',1/f_beacon, 'dT_coher[ns]', delta_t_coherence) # Show correlation maxima plot if not True: @@ -122,6 +121,8 @@ if __name__ == "__main__": if beacons is None: axs = [axs] + print('i',i,f"B({base[0].name},{base[1].name})", 'k[T]',k_period, 'rest[ns]',t_rest, 'T[ns]',1/f_beacon, 'dT_coher[ns]', delta_t_coherence, 'dT_beac[ns]', delta_t_beacon) + fig.suptitle( ", ".join([ f"$\\Delta$t_beacon [ns]: {delta_t_beacon:.2f}", @@ -146,7 +147,7 @@ if __name__ == "__main__": l1 = axs[0].plot(base[0].t, traces[0], label=f'Ref: {base[0].name}', alpha=0.8) l2 = axs[0].plot(base[1].t, traces[1], label=f'Orig: {base[1].name}', alpha=0.3, marker='+', ms=5) axs[0].plot(base[0].t + k_period/f_beacon + t_rest, traces[1], label='Coherence', alpha=0.3, marker='x', ms=5) - l3 = axs[0].plot(base[1].t - delta_t_beacon +k_period/f_beacon, traces[1], label=f'$\\Delta t_{{\\sigma\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8) + l3 = axs[0].plot(base[1].t - delta_t_beacon +k_period/f_beacon, traces[1], label=f'$\\Delta t_{{\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8) axs[0].legend(fancybox=True, framealpha=0.5) @@ -156,7 +157,7 @@ if __name__ == "__main__": ax.set_title("Original Beacons") ax.plot(base[0].t, beacons[0], label=f'Ref: {base[0].name}', alpha=0.8, color=l1[0].get_color()) ax.plot(base[1].t, beacons[1], label=f'Orig: {base[1].name}', alpha=0.3, marker='+', ms=5, color=l2[0].get_color()) - ax.plot(base[1].t -delta_t_beacon +k_period/f_beacon, beacons[1], label=f'$\\Delta t_{{\\sigma\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8, color=l3[0].get_color()) + ax.plot(base[1].t -delta_t_beacon +k_period/f_beacon, beacons[1], label=f'$\\Delta t_{{\\varphi}}$ + ($k={k_period:.0f}$)T', alpha=0.8, color=l3[0].get_color()) if False: if False: diff --git a/simulations/airshower_beacon_simulation/bd_time_diffs.py b/simulations/airshower_beacon_simulation/bd_time_diffs.py index ce7e1c9..d4824f5 100755 --- a/simulations/airshower_beacon_simulation/bd_time_diffs.py +++ b/simulations/airshower_beacon_simulation/bd_time_diffs.py @@ -22,8 +22,9 @@ if __name__ == "__main__": #### fname_dir = path.dirname(fname) antennas_fname = path.join(fname_dir, beacon.antennas_fname) + time_diffs_fname = antennas_fname - basenames, time_diffs, f_beacon, true_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(antennas_fname) + basenames, time_diffs, f_beacon, true_phase_diffs, k_periods = beacon.read_baseline_time_diffs_hdf5(time_diffs_fname) f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname) @@ -53,6 +54,3 @@ if __name__ == "__main__": ax.legend() plt.show() - - -