From f698010ddfc13aadf18f1117b11ddc0d3af53397 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Wed, 1 Feb 2023 14:13:26 +0100 Subject: [PATCH] ZH: set figsize for subplots --- .../ac_show_signal_to_noise.py | 7 ++++--- .../ba_measure_beacon_phase.py | 7 ++++--- .../bb_measure_clock_phase.py | 5 +++-- .../bc_baseline_phase_deltas.py | 9 +++++---- .../bd_antenna_phase_deltas.py | 17 +++++++++-------- .../ca_period_from_shower.py | 9 +++++---- .../cb_report_measured_antenna_time_offsets.py | 3 ++- .../da_reconstruction.py | 3 ++- .../dc_grid_power_time_fixes.py | 3 ++- 9 files changed, 36 insertions(+), 27 deletions(-) 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 5c0d73c..c79a568 100755 --- a/simulations/airshower_beacon_simulation/ac_show_signal_to_noise.py +++ b/simulations/airshower_beacon_simulation/ac_show_signal_to_noise.py @@ -34,6 +34,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) fig_dir = args.fig_dir show_plots = args.show_plots @@ -72,7 +73,7 @@ if __name__ == "__main__": if True: beacon_snrs = [ lib.signal_to_noise(myfilter(beacon_amp*ant.beacon), myfilter(ant.noise), samplerate=1/dt, signal_band=beacon_pb, noise_band=pb) for ant in antennas ] - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title("Maximum Beacon/Noise SNR") ax.set_xlabel("Antenna no.") ax.set_ylabel("SNR") @@ -87,7 +88,7 @@ if __name__ == "__main__": if True: beacon_snrs = [ lib.signal_to_noise(myfilter(beacon_amp*ant.beacon), ant.E_AxB, samplerate=1/dt, signal_band=beacon_pb, noise_band=pb) for ant in antennas ] - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title("Maximum Beacon/Total SNR") ax.set_xlabel("Antenna no.") ax.set_ylabel("SNR") @@ -101,7 +102,7 @@ if __name__ == "__main__": if True: shower_snrs = [ lib.signal_to_noise(ant.E_AxB, myfilter(ant.noise), samplerate=1/dt, signal_band=pb, noise_band=pb) for ant in antennas ] - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title("Total (Signal+Beacon+Noise)/Noise SNR") ax.set_xlabel("Antenna no.") ax.set_ylabel("SNR") diff --git a/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py b/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py index a98bcb6..613acda 100755 --- a/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py +++ b/simulations/airshower_beacon_simulation/ba_measure_beacon_phase.py @@ -36,6 +36,7 @@ if __name__ == "__main__": show_plots = args.show_plots fname = "ZH_airshower/mysim.sry" + figsize = (9,6) print("use_AxB_trace:", use_AxB_trace, "use_beacon_trace:",use_beacon_trace) @@ -178,7 +179,7 @@ if __name__ == "__main__": if (show_plots or fig_dir) and (i == 0 or i == 72 or i == 70): p2t = lambda phase: phase/(2*np.pi*f_beacon) - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title(f"Beacon at antenna {h5ant.attrs['name']}\nF:{frequency:.2e}, P:{beacon_phase:.4f}, A:{amplitude:.1e}") ax.set_xlabel("t [ns]") ax.set_ylabel("Amplitude") @@ -239,7 +240,7 @@ if __name__ == "__main__": # show histogram of found frequencies if show_plots or fig_dir: if True or allow_frequency_fitting: - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_xlabel("Frequency") ax.set_ylabel("Counts") ax.axvline(f_beacon, ls='dashed', color='g') @@ -248,7 +249,7 @@ if __name__ == "__main__": fig.savefig(path.join(fig_dir, path.basename(__file__) + f".hist_freq.pdf")) if True: - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_xlabel("Amplitudes") ax.set_ylabel("Counts") ax.hist(found_data[:,2], bins='sqrt', density=False) diff --git a/simulations/airshower_beacon_simulation/bb_measure_clock_phase.py b/simulations/airshower_beacon_simulation/bb_measure_clock_phase.py index 59afe8d..a16fa76 100755 --- a/simulations/airshower_beacon_simulation/bb_measure_clock_phase.py +++ b/simulations/airshower_beacon_simulation/bb_measure_clock_phase.py @@ -23,6 +23,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) c_light = lib.c_light show_plots = args.show_plots @@ -83,7 +84,7 @@ if __name__ == "__main__": # Plot True Phases at their locations if show_plots or fig_dir: - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) spatial_unit='m' fig.suptitle('Clock phases\nf_beacon= {:2.0f}MHz'.format(f_beacon*1e3)) @@ -111,7 +112,7 @@ if __name__ == "__main__": # Plot True Phases - Actual True Phases at their location if show_plots or fig_dir: - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) fig.suptitle('Clock phase Residuals\nf_beacon={:2.0f}MHz'.format(f_beacon*1e3)) actual_clock_phases = np.array([ -2*np.pi*a.attrs['clock_offset']*f_beacon for a in antennas ]) diff --git a/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py b/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py index ecb1861..887cd0e 100755 --- a/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py +++ b/simulations/airshower_beacon_simulation/bc_baseline_phase_deltas.py @@ -24,6 +24,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) c_light = 3e8*1e-9 show_plots = args.show_plots ref_ant_id = None if True else [50] # leave None for all baselines @@ -104,12 +105,12 @@ if __name__ == "__main__": plot_residuals = i == 1 colors = ['blue', 'orange'] - fig, axs = plt.subplots(2, 1, sharex=True) + fig, axs = plt.subplots(2, 1, sharex=True, figsize=figsize) if True: - forward = lambda x: x/(2*np.pi*f_beacon) - inverse = lambda x: 2*np.pi*x*f_beacon - secax = axs[0].secondary_xaxis('top', functions=(forward, inverse)) + phase2time = lambda x: x/(2*np.pi*f_beacon) + time2phase = lambda x: 2*np.pi*x*f_beacon + secax = axs[0].secondary_xaxis('top', functions=(phase2time, time2phase)) secax.set_xlabel('Time $\\Delta\\varphi/(2\\pi f_{beac})$ [ns]') if plot_residuals: diff --git a/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py b/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py index 3522983..746ca9b 100755 --- a/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py +++ b/simulations/airshower_beacon_simulation/bd_antenna_phase_deltas.py @@ -26,6 +26,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) show_plots = args.show_plots ref_ant_id = None # leave None for all baselines @@ -69,7 +70,7 @@ if __name__ == "__main__": # Show Matrix as figure if True: - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title("Measured clock phase differences Baseline i,j") ax.set_ylabel("Antenna no. i") ax.set_xlabel("Antenna no. j") @@ -92,7 +93,7 @@ if __name__ == "__main__": # Show subtraction Matrix as figure if True: - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title("Clock Phase Subtraction matrix i,j") ax.set_ylabel("Antenna no. i") ax.set_xlabel("Antenna no. j") @@ -121,7 +122,7 @@ if __name__ == "__main__": # Show resulting matrix as figure if True: - fig, axs = plt.subplots(2,1, sharex=True) + fig, axs = plt.subplots(2,1, sharex=True, figsize=figsize) axs[0].set_title("Modified clock phase differences Baseline 0,j") axs[0].set_ylabel("Antenna no. 0") axs[-1].set_xlabel("Antenna no. j") @@ -178,12 +179,12 @@ if __name__ == "__main__": plot_residuals = i == 1 colors = ['blue', 'orange'] - fig, axs = plt.subplots(2, 1, sharex=True) + fig, axs = plt.subplots(2, 1, sharex=True, figsize=figsize) if True: - forward = lambda x: x/(2*np.pi*f_beacon) - inverse = lambda x: 2*np.pi*x*f_beacon - secax = axs[0].secondary_xaxis('top', functions=(forward, inverse)) + phase2time = lambda x: x/(2*np.pi*f_beacon) + time2phase = lambda x: 2*np.pi*x*f_beacon + secax = axs[0].secondary_xaxis('top', functions=(phase2time, time2phase)) secax.set_xlabel('Time $\\Delta\\varphi/(2\\pi f_{beac})$ [ns]') if plot_residuals: @@ -240,7 +241,7 @@ if __name__ == "__main__": # Make a plot if True: for i in range(2): - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title("Baseline Time difference reconstruction" + ( '' if i == 0 else ' (wrapped time)')) ax.set_xlabel("Baseline no.") ax.set_ylabel("Time $\\Delta t$ [ns]") diff --git a/simulations/airshower_beacon_simulation/ca_period_from_shower.py b/simulations/airshower_beacon_simulation/ca_period_from_shower.py index cfa76ee..6f9e85f 100755 --- a/simulations/airshower_beacon_simulation/ca_period_from_shower.py +++ b/simulations/airshower_beacon_simulation/ca_period_from_shower.py @@ -81,7 +81,7 @@ def find_best_sample_shifts_summing_at_location(test_loc, antennas, allowed_samp # init figure if i in plot_iteration_with_shifted_trace: - fig, ax = plt.subplots() + 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_xlabel("Time [ns]") ax.set_ylabel("Amplitude") @@ -155,6 +155,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) fig_dir = args.fig_dir fig_subdir = path.join(fig_dir, 'shifts/') @@ -244,7 +245,7 @@ if __name__ == "__main__": if i == 2: orig_beacon_amplifier = ampl/max(ant.beacon) - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title(f"Signal and Beacon traces Antenna {i}") ax.set_xlabel("Time [ns]") ax.set_ylabel("Amplitude [$\\mu V/m$]") @@ -375,7 +376,7 @@ if __name__ == "__main__": np.savetxt(path.join(fig_dir, path.basename(__file__)+f'.maxima.run{r}.txt'), np.column_stack((locs, maxima_per_loc, ks_per_loc)) ) if True: #plot maximum at test locations - fig, axs = plt.subplots() + fig, axs = plt.subplots(figsize=figsize) axs.set_title(f"Optimizing signal strength by varying $k$ per antenna,\n Grid Run {r}") axs.set_ylabel("vxvxB [km]") axs.set_xlabel(" vxB [km]") @@ -437,7 +438,7 @@ if __name__ == "__main__": P, t_, a_, a_sum, t_sum = rit.pow_and_time(test_loc, ev, dt=dt) maxima[i] = np.max(a_sum) - fig, axs = plt.subplots() + fig, axs = plt.subplots(figsize=figsize) axs.set_title(f"Shower slice for best k, Grid Run {r}") axs.set_ylabel("vxvxB [km]") axs.set_xlabel(" vxB [km]") 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 17edaff..6a00681 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 @@ -23,6 +23,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) fig_dir = args.fig_dir # set None to disable saving show_plots = args.show_plots @@ -78,7 +79,7 @@ if __name__ == "__main__": plot_residuals = i == 1 colors = ['blue', 'orange'] - fig, axs = plt.subplots(2, 1, sharex=True) + fig, axs = plt.subplots(2, 1, sharex=True, figsize=figsize) if True: phase2time = lambda x: x/(2*np.pi*f_beacon) diff --git a/simulations/airshower_beacon_simulation/da_reconstruction.py b/simulations/airshower_beacon_simulation/da_reconstruction.py index 720aa6e..6bc4291 100755 --- a/simulations/airshower_beacon_simulation/da_reconstruction.py +++ b/simulations/airshower_beacon_simulation/da_reconstruction.py @@ -34,6 +34,7 @@ if __name__ == "__main__": args = parser.parse_args() fname = "ZH_airshower/mysim.sry" + figsize = (9,6) fig_dir = args.fig_dir fig_subdir = path.join(fig_dir, 'reconstruction') @@ -119,7 +120,7 @@ if __name__ == "__main__": tmp_beacon = tx_amps[0]/tx_amps_sum * calc_beacon fname_extra = ".Ex" - fig, ax = plt.subplots() + fig, ax = plt.subplots(figsize=figsize) ax.set_title(f"Signal and Beacon traces Antenna {i}") ax.set_xlabel("Time [ns]") ax.set_ylabel("Amplitude [$\\mu V/m$]") diff --git a/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py b/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py index 8bb4cce..2372ac8 100755 --- a/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py +++ b/simulations/airshower_beacon_simulation/dc_grid_power_time_fixes.py @@ -45,6 +45,7 @@ if __name__ == "__main__": wanted_cases = valid_cases fname = "ZH_airshower/mysim.sry" + figsize = (9,6) fig_dir = args.fig_dir show_plots = args.show_plots @@ -184,7 +185,7 @@ if __name__ == "__main__": if True: P, t_, a_, a_sum, t_sum = rit.pow_and_time([0,0,0], ev, dt=1) - fig, axs = plt.subplots() + fig, axs = plt.subplots(figsize=figsize) axs.set_title("Antenna traces" + "\n" + plot_titling[case]) axs.set_xlabel("Time [ns]") axs.set_ylabel("Amplitude [$\\mu V/m$]")