mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
ZH: make a plot of a single antenna after beaconing
This commit is contained in:
parent
9f16aced49
commit
82ad45730e
2 changed files with 51 additions and 22 deletions
|
@ -10,6 +10,7 @@ beacon:
|
|||
./aa_generate_beacon.py | tee figures/aa.log
|
||||
./ab_modify_clocks.py 0 | tee figures/ab.log
|
||||
./ac_show_signal_to_noise.py --no-show-plots --fig-dir=${FIG_DIR}
|
||||
./view_beaconed_antenna.py 72 -p x -p y -p z -p AxB --no-show-plots --fig-dir=${FIG_DIR}
|
||||
|
||||
clocks:
|
||||
./ab_modify_clocks.py 15 --gaussian
|
||||
|
|
|
@ -11,12 +11,32 @@ from earsim import Antenna
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os.path as path
|
||||
from os import path
|
||||
import sys
|
||||
import matplotlib
|
||||
import os
|
||||
if os.name == 'posix' and "DISPLAY" not in os.environ:
|
||||
matplotlib.use('Agg')
|
||||
|
||||
from scriptlib import MyArgumentParser
|
||||
parser = MyArgumentParser()
|
||||
parser.add_argument('ant_idx', default=[72], nargs='*', help='Antenna Indices')
|
||||
parser.add_argument('-p', '--polarisations', choices=['x', 'y', 'z', 'b', 'AxB'], action='append', help='Default: x,y,z')
|
||||
parser.add_argument('--geom', action='store_true', help='Make a figure containg the geometry from tx to antenna(s)')
|
||||
parser.add_argument('--ft', action='store_true', help='Add FT strenghts of antenna traces')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
fname = "ZH_airshower/mysim.sry"
|
||||
|
||||
plot_ft_amplitude = True
|
||||
plot_geometry = True
|
||||
plot_ft_amplitude = args.ft
|
||||
plot_geometry = args.geom
|
||||
|
||||
fig_dir = args.fig_dir
|
||||
show_plots = args.show_plots
|
||||
|
||||
if not args.polarisations:
|
||||
args.polarisations = ['x','y', 'z']
|
||||
|
||||
####
|
||||
fname_dir = path.dirname(fname)
|
||||
|
@ -24,6 +44,9 @@ if __name__ == "__main__":
|
|||
|
||||
f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
|
||||
|
||||
idx = args.ant_idx
|
||||
|
||||
if not idx:
|
||||
if not True:
|
||||
idx = [0, 1, len(antennas)//2, len(antennas)//2+1, -2, -1]
|
||||
elif not True:
|
||||
|
@ -34,8 +57,6 @@ if __name__ == "__main__":
|
|||
|
||||
idx = [ i for i, ant in enumerate(antennas) if int(ant.name) in names ]
|
||||
|
||||
[ print(antennas[i].name) for i in names ]
|
||||
|
||||
fig1, axs = plt.subplots(1+plot_ft_amplitude*2)
|
||||
if not plot_ft_amplitude:
|
||||
axs = [axs]
|
||||
|
@ -58,15 +79,18 @@ if __name__ == "__main__":
|
|||
|
||||
axs[0].axvline(ant.t[0], color='k', alpha=0.5)
|
||||
|
||||
if True: # total E field
|
||||
mydict = dict(AxB=ant.E_AxB)
|
||||
elif False: # polarisations
|
||||
mydict = dict(x=ant.Ex, y=ant.Ex, z=ant.Ez)
|
||||
else: # beacon
|
||||
mydict = dict(b=ant.beacon)
|
||||
mydict = {}
|
||||
for p in args.polarisations:
|
||||
pattr = 'E'+str(p)
|
||||
if p == 'b':
|
||||
pattr = 'beacon'
|
||||
elif p == 'AxB':
|
||||
pattr = 'E_AxB'
|
||||
|
||||
mydict[p] = getattr(ant, pattr)
|
||||
|
||||
for j, (direction, trace) in enumerate(mydict.items()):
|
||||
l = axs[0].plot(ant.t, trace, label=f"$E_{{{direction}}}$ {ant.name}", alpha=0.8)
|
||||
l = axs[0].plot(ant.t, trace, label=f"$E_{{{direction}}}$ {ant.name}", alpha=0.7)
|
||||
|
||||
#if False and j == 0 and 't0' in ant.attrs:
|
||||
# axs[0].axvline(ant.attrs['t0'], color=l[0].get_color(), alpha=0.5)
|
||||
|
@ -95,7 +119,9 @@ if __name__ == "__main__":
|
|||
if plot_ft_amplitude:
|
||||
fig1.legend(loc='center right', ncol=min(2, len(idx)))
|
||||
else:
|
||||
fig1.legend(loc='upper right', ncol=min(3, len(idx)))
|
||||
axs[0].legend(loc='upper right', ncol=min(3, len(idx)))
|
||||
if fig_dir:
|
||||
fig1.savefig(path.join(fig_dir, path.basename(__file__) + f".trace.pdf"))
|
||||
|
||||
if plot_geometry:
|
||||
if len(mydict) == 1:
|
||||
|
@ -110,6 +136,8 @@ if __name__ == "__main__":
|
|||
|
||||
axs2.plot(tx.x, tx.y, marker='X', color='k')
|
||||
axs2.set_title("Geometry with selected antennas")
|
||||
if fig_dir:
|
||||
fig2.savefig(path.join(fig_dir, path.basename(__file__) + f".geom.pdf"))
|
||||
|
||||
#fig1.savefig('./fig1.png')
|
||||
if show_plots:
|
||||
plt.show()
|
||||
|
|
Loading…
Reference in a new issue