ZH: set figsize for subplots

This commit is contained in:
Eric Teunis de Boone 2023-02-01 14:13:26 +01:00
parent 6151199650
commit f698010ddf
9 changed files with 36 additions and 27 deletions

View file

@ -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")

View file

@ -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)

View file

@ -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 ])

View file

@ -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:

View file

@ -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]")

View file

@ -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]")

View file

@ -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)

View file

@ -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$]")

View file

@ -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$]")