diff --git a/airshower_beacon_simulation/dc_grid_power_time_fixes.py b/airshower_beacon_simulation/dc_grid_power_time_fixes.py index 49066ec..8984a07 100755 --- a/airshower_beacon_simulation/dc_grid_power_time_fixes.py +++ b/airshower_beacon_simulation/dc_grid_power_time_fixes.py @@ -18,17 +18,21 @@ import aa_generate_beacon as beacon import lib from lib import rit -def save_overlapping_traces_figure(test_location, ev, N_plot = 30, wx=200, title_extra=None, fname_distinguish='', fig_dir=None, **fig_kwargs): +def save_overlapping_traces_figure(test_location, ev, N_plot = 30, wx=200, title_extra=None, fname_distinguish='', fig_dir=None, location_in_plot_text_loc=(0.02, 0.95), location_text=None, **fig_kwargs): P, t_, a_, a_sum, t_sum = rit.pow_and_time(test_location, ev, dt=1) fig, axs = plt.subplots(**fig_kwargs) axs.set_title("Antenna traces" + (("\n" + title_extra) if title_extra is not None else '') ) axs.set_xlabel("Time [ns]") axs.set_ylabel("Amplitude [$\\mu V/m$]") - if True: - text_loc = (0.02, 0.95) - shower_plane_location = rit.location_to_shower_plane(test_location, ev=ev) - axs.text(*text_loc, '[' + ', '.join(['{:.1g}'.format(x) for x in shower_plane_location]) + ']', ha='left', transform=axs.transAxes) + if location_in_plot_text_loc: + text_loc = location_in_plot_text_loc + + if not location_text: + shower_plane_location = rit.location_to_shower_plane(test_location, ev=ev) + location_text = '(' + ', '.join(['{:.1g}'.format(x) for x in shower_plane_location]) + ')' + + axs.text(*text_loc, location_text, ha='left', transform=axs.transAxes) a_max = [ np.amax(ant.E_AxB) for ant in ev.antennas ] power_sort_idx = np.argsort(a_max) @@ -161,10 +165,10 @@ if __name__ == "__main__": trace_zoom_wx = 100 plot_titling = { - 'no_offset': "no clock offset", - 'repair_none': "unrepaired clock offset", - 'repair_phases': "phase resolved clock offsets repaired", - 'repair_full': "final measured clock offsets repaired" + 'no_offset': "no clock offsets", + 'repair_none': "randomised clock offsets", + 'repair_phases': "phase clock offsets", + 'repair_full': "phase + period clock offsets" } # For now only implement using one freq_name @@ -253,6 +257,7 @@ if __name__ == "__main__": transl_mode = transl_modes[case] measured_offsets = beacon.read_antenna_clock_repair_offsets(antennas, mode=transl_mode, freq_name=freq_name) else: + print(f"Warning: unknown repair case requested '{case}', defaulting to none.") measured_offsets = [0]*len(ev.antennas) for i, ant in enumerate(ev.antennas): @@ -269,7 +274,18 @@ if __name__ == "__main__": # # Plot overlapping traces at 0,0,0 # - fig = save_overlapping_traces_figure([0,0,0], ev, N_plot=N_plot, wx=trace_zoom_wx, title_extra = plot_titling[case], fname_distinguish=f'{case}.0', fig_dir=fig_dir, figsize=figsize) + loc = (0,0,0) + fig = save_overlapping_traces_figure(loc, ev, N_plot=N_plot, wx=trace_zoom_wx, title_extra = plot_titling[case], fname_distinguish=f'{case}.0', fig_dir=fig_dir, figsize=figsize) + plt.close(fig) + + # + # Plot overlapping traces at simulation shower axis + # + dX = atm.distance_to_slant_depth(np.deg2rad(ev.zenith), X, zgr) + loc = (0)*ev.uAxB + (0)*ev.uAxAxB + dX * ev.uA + loc[0:1] = 0 + + fig = save_overlapping_traces_figure(loc, ev, N_plot=N_plot, wx=trace_zoom_wx, title_extra = plot_titling[case], fname_distinguish=f'{case}.axis', location_text=f"on simulation axis, $X={X}$", fig_dir=fig_dir, figsize=figsize) plt.close(fig) # Measure power on grid