ZH: Note SNRs in legends of the plots

This commit is contained in:
Eric-Teunis de Boone 2023-04-12 22:42:59 +02:00
parent 83811bbd1a
commit b20e2f0f03
8 changed files with 67 additions and 22 deletions

View file

@ -28,7 +28,7 @@ def save_overlapping_traces_figure(test_location, ev, N_plot = 30, wx=200, title
axs.set_ylabel("Amplitude [$\\mu V/m$]")
if False:
text_loc = (0.02, 0.95)
axs.text(*text_loc, '[' + ', '.join(['{:.2e}'.format(x) for x in test_location]) + ']', ha='left', transform=axs.transAxes)
axs.text(*text_loc, '[' + ', '.join(['{:.1e}'.format(x) for x in test_location]) + ']', ha='left', transform=axs.transAxes)
a_max = [ np.amax(ant.E_AxB) for ant in ev.antennas ]
power_sort_idx = np.argsort(a_max)
@ -123,6 +123,7 @@ if __name__ == "__main__":
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
pickle_fname = path.join(fname_dir, 'res.pkl')
tx_fname = path.join(fname_dir, beacon.tx_fname)
snr_fname = path.join(fname_dir, beacon.snr_fname)
# create fig_dir
if fig_dir:
@ -136,6 +137,9 @@ if __name__ == "__main__":
bak_ants = ev.antennas
# .. patch in our antennas
ev.antennas = antennas
# Read in snr info
snrs = beacon.read_snr_file(snr_fname)
snr_str = f"$\\langle SNR \\rangle$ = {snrs['mean']: .1e}"
##
## Setup grid
@ -288,6 +292,7 @@ if __name__ == "__main__":
fig.suptitle("")
axs.set_title(suptitle +"\n" +plot_titling[case])
#axs.set_aspect('equal', 'datalim')
axs.legend(title=snr_str)
if fig_dir:
fig.tight_layout()
@ -307,7 +312,7 @@ if __name__ == "__main__":
# only add distance horizontally
location = maxp_loc + np.sqrt(dist*1e3)*np.array([1,1,0])
fig = save_overlapping_traces_figure(location, ev, N_plot=N_plot, wx=wx, title_extra = plot_titling[case] + ', ' + scalename + f', x + {dist}km', fname_distinguish=f'{scalename}.{dist}', fig_dir=fig_dir, figsize=figsize)
fig = save_overlapping_traces_figure(location, ev, N_plot=N_plot, wx=wx, title_extra = plot_titling[case] + ', ' + scalename + f', x + {dist}km', fname_distinguish=f'{scalename}.x{dist}', fig_dir=fig_dir, figsize=figsize)
plt.close(fig)