ZH: apply block_filter before determining SNRs

This commit is contained in:
Eric Teunis de Boone 2023-01-12 13:47:37 +01:00
parent c09bb6563c
commit 9af9815a31

View file

@ -11,7 +11,7 @@ import h5py
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from earsim import REvent from earsim import REvent, block_filter
import aa_generate_beacon as beacon import aa_generate_beacon as beacon
import lib import lib
@ -49,29 +49,48 @@ if __name__ == "__main__":
beacon_amp = np.max(txdata['amplitudes'])# mu V/m beacon_amp = np.max(txdata['amplitudes'])# mu V/m
if True: # Apply filter to raw beacon/noise to compare with Filtered Traces
myfilter = lambda x: block_filter(x, dt, pb[0], pb[1])
else: # Compare raw beacon/noise with Filtered Traces
myfilter = lambda x: x
## ##
## Beacon vs Noise SNR ## Beacon vs Noise SNR
## ##
if True: 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 ] beacon_snrs = [ lib.signal_to_noise(myfilter(beacon_amp*ant.beacon), myfilter(ant.noise), samplerate=1/dt, signal_band=beacon_pb) for ant in antennas ]
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.set_title("Maximum Beacon SNR") ax.set_title("Maximum Beacon/Noise SNR")
ax.set_xlabel("Antenna no.") ax.set_xlabel("Antenna no.")
ax.set_ylabel("SNR") ax.set_ylabel("SNR")
ax.plot([ int(ant.name) for ant in antennas], beacon_snrs, 'o', ls='none') ax.plot([ int(ant.name) for ant in antennas], beacon_snrs, 'o', ls='none')
if fig_dir: if fig_dir:
fig.savefig(path.join(fig_dir, path.basename(__file__) + f".beacon_snr.pdf")) fig.savefig(path.join(fig_dir, path.basename(__file__) + f".beacon_vs_noise_snr.pdf"))
## ##
## Beacon vs Total SNR
##
if True:
beacon_snrs = [ lib.signal_to_noise(myfilter(beacon_amp*ant.beacon), ant.E_AxB, samplerate=1/dt, signal_band=beacon_pb) for ant in antennas ]
fig, ax = plt.subplots()
ax.set_title("Maximum Beacon/Total 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_vs_total_snr.pdf"))
##
## Airshower signal vs Noise SNR ## Airshower signal vs Noise SNR
## ##
if True: if True:
shower_snrs = [ lib.signal_to_noise(ant.E_AxB, ant.noise, samplerate=1/dt, signal_band=pb) for ant in antennas ] shower_snrs = [ lib.signal_to_noise(ant.E_AxB, myfilter(ant.noise), samplerate=1/dt, signal_band=pb) for ant in antennas ]
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.set_title("Total (Signal+Beacon+Noise) SNR") ax.set_title("Total (Signal+Beacon+Noise)/Noise SNR")
ax.set_xlabel("Antenna no.") ax.set_xlabel("Antenna no.")
ax.set_ylabel("SNR") ax.set_ylabel("SNR")
ax.plot([ int(ant.name) for ant in antennas], shower_snrs, 'o', ls='none') ax.plot([ int(ant.name) for ant in antennas], shower_snrs, 'o', ls='none')