mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-14 02:23:32 +01:00
83 lines
2.3 KiB
Python
Executable file
83 lines
2.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# vim: indent=fdm ts=4
|
|
|
|
"""
|
|
Show Signal to noise for the original simulation signal,
|
|
the beacon signal and the combined signal for each antenna
|
|
"""
|
|
|
|
import numpy as np
|
|
import h5py
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
from earsim import REvent
|
|
import aa_generate_beacon as beacon
|
|
import lib
|
|
|
|
|
|
if __name__ == "__main__":
|
|
from os import path
|
|
import sys
|
|
import matplotlib
|
|
import os
|
|
if os.name == 'posix' and "DISPLAY" not in os.environ:
|
|
matplotlib.use('Agg')
|
|
|
|
fname = "ZH_airshower/mysim.sry"
|
|
|
|
fig_dir = "./figures/"
|
|
show_plots = not False
|
|
|
|
####
|
|
fname_dir = path.dirname(fname)
|
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
|
tx_fname = path.join(fname_dir, beacon.tx_fname)
|
|
|
|
# create fig_dir
|
|
if fig_dir:
|
|
os.makedirs(fig_dir, exist_ok=True)
|
|
|
|
# Read in antennas from file
|
|
f_beacon, tx, antennas = beacon.read_beacon_hdf5(antennas_fname)
|
|
_, __, txdata = beacon.read_tx_file(tx_fname)
|
|
|
|
# general properties
|
|
dt = antennas[0].t[1] - antennas[0].t[0] # ns
|
|
pb = lib.passband(30e-3, 80e-3) # GHz
|
|
beacon_pb = lib.passband(f_beacon-1e-3, f_beacon+1e-3) # GHz
|
|
|
|
beacon_amp = np.max(txdata['amplitudes'])# mu V/m
|
|
|
|
##
|
|
## Beacon vs Noise SNR
|
|
##
|
|
if True:
|
|
beacon_snrs = [ lib.signal_to_noise(beacon_amp*ant.beacon, ant.noise, samplerate=1/dt, signal_band=beacon_pb) for ant in antennas ]
|
|
|
|
fig, ax = plt.subplots()
|
|
ax.set_title("Maximum Beacon SNR")
|
|
ax.set_xlabel("Antenna no.")
|
|
ax.set_ylabel("SNR")
|
|
ax.plot([ int(ant.name) for ant in antennas], beacon_snrs, 'o', ls='none')
|
|
|
|
if fig_dir:
|
|
fig.savefig(path.join(fig_dir, path.basename(__file__) + f".beacon_snr.pdf"))
|
|
|
|
##
|
|
## Airshower signal vs Noise SNR
|
|
##
|
|
if True:
|
|
shower_snrs = [ lib.signal_to_noise(ant.E_AxB, ant.noise, samplerate=1/dt, signal_band=pb) for ant in antennas ]
|
|
|
|
fig, ax = plt.subplots()
|
|
ax.set_title("Total (Signal+Beacon+Noise) SNR")
|
|
ax.set_xlabel("Antenna no.")
|
|
ax.set_ylabel("SNR")
|
|
ax.plot([ int(ant.name) for ant in antennas], shower_snrs, 'o', ls='none')
|
|
|
|
if fig_dir:
|
|
fig.savefig(path.join(fig_dir, path.basename(__file__) + f".total_snr.pdf"))
|
|
|
|
if show_plots:
|
|
plt.show()
|