ZH: tweaks to view scripts

This commit is contained in:
Eric Teunis de Boone 2022-11-18 19:36:48 +01:00
parent 7aed162fa8
commit 6523128871
2 changed files with 20 additions and 8 deletions

View file

@ -17,7 +17,7 @@ if __name__ == "__main__":
plot_ft_amplitude = True
plot_geometry = True
####
fname_dir = path.dirname(fname)
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
@ -76,7 +76,7 @@ if __name__ == "__main__":
freqs = ft.fftfreq(n_samples, 1/samplerate)[:n_samples//2]
fft = 2*ft.fft(trace)[:n_samples//2]/n_samples
#axs[1].plot(freqs, np.abs(fft)**2, color=l[0].get_color())
if True:
@ -100,6 +100,7 @@ if __name__ == "__main__":
plot_antenna_geometry(antennas, ax=axs2, plot_max_values=False, color='grey', plot_names=False)
plot_antenna_geometry([ antennas[i] for i in idx], ax=axs2, colors=colorlist, plot_max_values=False)
axs2.plot(tx.x, tx.y, marker='X', color='k')
axs2.set_title("Geometry with selected antennas")
#fig1.savefig('./fig1.png')
plt.show()

View file

@ -3,9 +3,6 @@
import numpy as np
import matplotlib.pyplot as plt
from earsim import REvent
def plot_antenna_Efields(antenna, ax=None, plot_Ex=True, plot_Ey=True, plot_Ez=True, label_append="",**kwargs):
"""Show waveforms from an antenna"""
if ax is None:
@ -70,18 +67,32 @@ def plot_antenna_geometry(antennas, ax=None, plot_names=True, plot_max_values=Tr
return ax, sc
if __name__ == "__main__":
import os.path as path
from earsim import REvent
import aa_generate_beacon as beacon
fname = "ZH_airshower/mysim.sry"
i = 0
ev = REvent(fname)
if True:
ev = REvent(fname)
antennas = ev.antennas
else:
fname_dir = path.dirname(fname)
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
if True:
fig, ax1 = plt.subplots()
plot_antenna_Efields(ev.antennas[i], ax=ax1)
plot_antenna_Efields(antennas[i], ax=ax1)
if True:
fig2, ax2 = plt.subplots()
plot_antenna_geometry(ev.antennas, ax=ax2, plot_max_values=True, plot_names=False)
plot_antenna_geometry(antennas, ax=ax2, plot_max_values=True, plot_names=False)
ax2.set_aspect('equal', 'datalim')
plt.show()