diff --git a/airshower_beacon_simulation/ca_period_from_shower.py b/airshower_beacon_simulation/ca_period_from_shower.py index f95ce61..cdf5b70 100755 --- a/airshower_beacon_simulation/ca_period_from_shower.py +++ b/airshower_beacon_simulation/ca_period_from_shower.py @@ -20,7 +20,7 @@ import aa_generate_beacon as beacon import lib from lib import rit -def find_best_period_shifts_summing_at_location(test_loc, antennas, allowed_ks, period=1, dt=None, period_shift_first_trace=0, plot_iteration_with_shifted_trace=None, fig_dir=None, fig_distinguish=None): +def find_best_period_shifts_summing_at_location(test_loc, antennas, allowed_ks, period=1, dt=None, period_shift_first_trace=0, plot_iteration_with_shifted_trace=None, fig_dir=None, fig_distinguish=None,snr_str=None): """ Find the best sample_shift for each antenna by summing the antenna traces and seeing how to get the best alignment. @@ -81,7 +81,7 @@ def find_best_period_shifts_summing_at_location(test_loc, antennas, allowed_ks, # init figure if i in plot_iteration_with_shifted_trace: fig, ax = plt.subplots(figsize=figsize) - ax.set_title("Traces at ({:.1f},{:.1f},{:.1f}) i={i}/{tot}".format(*test_loc, i=i, tot=N_ant)) + ax.set_title("Traces at ({:.1g},{:.1g},{:.1g}); i={i}/{tot}".format(*test_loc, i=i, tot=N_ant)) ax.set_xlabel("Time [ns]") ax.set_ylabel("Amplitude") ax.plot(t_sum, a_sum) @@ -108,7 +108,7 @@ def find_best_period_shifts_summing_at_location(test_loc, antennas, allowed_ks, if True: # plot best k again ax.plot(t_sum, best_augmented_a, alpha=0.8, label=f'best $k$={best_period_shifts[i]:g}', lw=2) - ax.legend( ncol=5 ) + ax.legend(title='period shift $k$; '+snr_str, ncol=5 ) if fig_dir: fig.tight_layout() fname = path.join(fig_dir, path.basename(__file__) + f'.{fig_distinguish}i{i}' + '.loc{:.1f}-{:.1f}-{:.1f}'.format(*test_loc)) @@ -212,7 +212,7 @@ if __name__ == "__main__": ev.antennas = antennas # read in snr information beacon_snrs = beacon.read_snr_file(beacon_snr_fname) - snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1e}" + snr_str = f"$\\langle SNR \\rangle$ = {beacon_snrs['mean']: .1g}" # For now only implement using one freq_name freq_names = antennas[0].beacon_info.keys() @@ -412,7 +412,8 @@ if __name__ == "__main__": # Find best k for each antenna ks_per_loc[i], maxima_per_loc[i] = find_best_period_shifts_summing_at_location(test_loc, ev.antennas, allowed_ks, period=1/f_beacon, dt=dt, plot_iteration_with_shifted_trace=[ 5, len(ev.antennas)-1], - fig_dir=tmp_fig_subdir, fig_distinguish=f"run{r}.") + fig_dir=tmp_fig_subdir, fig_distinguish=f"run{r}.", + snr_str=snr_str) xx = np.array(xx) yy = np.array(yy)