mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-14 02:23:32 +01:00
46 lines
1.2 KiB
Python
Executable file
46 lines
1.2 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
import numpy.fft as ft
|
|
|
|
from earsim import Antenna
|
|
import aa_generate_beacon as beacon
|
|
|
|
if __name__ == "__main__":
|
|
import os.path as path
|
|
|
|
fname = "ZH_airshower/mysim.sry"
|
|
|
|
####
|
|
fname_dir = path.dirname(fname)
|
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
|
|
|
f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
|
|
|
|
idx = [0, len(antennas)//2, -1]
|
|
fig1, axs = plt.subplots(2)
|
|
axs[0].set_xlabel('t [ns]')
|
|
axs[0].set_ylabel('[$\mu$V/m]')
|
|
axs[1].set_xlabel('f [GHz]')
|
|
axs[1].set_ylabel('Power')
|
|
|
|
for i in idx:
|
|
ant = antennas[i]
|
|
|
|
n_samples = len(ant.t)
|
|
samplerate = (ant.t[-1] - ant.t[0])/n_samples
|
|
|
|
axs[0].axvline(ant.t[0], color='k', alpha=0.5)
|
|
|
|
for direction, trace in dict(x=ant.Ex, y=ant.Ex, z=ant.Ez).items():
|
|
freqs = ft.fftfreq(n_samples, 1/samplerate)[:n_samples//2]
|
|
fft = 2*ft.fft(trace)[:n_samples//2]/n_samples
|
|
|
|
axs[0].plot(ant.t, trace, label=f"E{direction} {i}")
|
|
axs[1].plot(freqs, np.abs(fft))
|
|
|
|
fig1.legend(loc='center right', ncol=min(3, len(idx)))
|
|
|
|
#fig1.savefig('./fig1.png')
|
|
plt.show()
|