diff --git a/simulations/airshower_beacon_simulation/Makefile b/simulations/airshower_beacon_simulation/Makefile index b7721d0..6fb7223 100644 --- a/simulations/airshower_beacon_simulation/Makefile +++ b/simulations/airshower_beacon_simulation/Makefile @@ -4,10 +4,10 @@ all: beacon clocks beacon: - ./generate_beacon.py + ./aa_generate_beacon.py clocks: - ./modify_clocks.py + ./ab_modify_clocks.py dist-clean: rm -f ZH_airshower/antennas.hdf5 diff --git a/simulations/airshower_beacon_simulation/README.md b/simulations/airshower_beacon_simulation/README.md index 98e8446..d4e99be 100644 --- a/simulations/airshower_beacon_simulation/README.md +++ b/simulations/airshower_beacon_simulation/README.md @@ -9,13 +9,19 @@ The produced files can be read using [./earsim](./earsim). Steps: 1. Setup - 1. Beacon ([./generate_beacon.py]) + 1. Beacon ([./aa_generate_beacon.py]) 1. Define tx position 2. Read in antennas 3. Sample beacon at each antenna 4. Add to relevant polarisation 5. Save antenna traces - 2. Timeoffset ([./generate_timeoffset.pyt]) + 2. Timeoffset ([./ab_modify_clocks.py]) 1. Generate timeoffsets for each antenna 2. Modify time samples + + 2. Beacon analysis + 1. Find beacon frequency and phase in antenna traces ([./ba_beacon_phases.py]) + 2. Find k\*2\\pi phase offsets (periods) ([./bb_beacon_multiples.py]) + + 3. Rewrite clocks diff --git a/simulations/airshower_beacon_simulation/generate_beacon.py b/simulations/airshower_beacon_simulation/aa_generate_beacon.py similarity index 98% rename from simulations/airshower_beacon_simulation/generate_beacon.py rename to simulations/airshower_beacon_simulation/aa_generate_beacon.py index 7bfbd07..f8939e2 100755 --- a/simulations/airshower_beacon_simulation/generate_beacon.py +++ b/simulations/airshower_beacon_simulation/aa_generate_beacon.py @@ -52,7 +52,8 @@ def read_beacon_hdf5(fname): antenna.Ex = ant['traces'][1] antenna.Ey = ant['traces'][2] antenna.Ez = ant['traces'][3] - antenna.beacon = ant['traces'][4] + if len(ant['traces']) > 4: + antenna.beacon = ant['traces'][4] antennas.append(antenna) diff --git a/simulations/airshower_beacon_simulation/modify_clocks.py b/simulations/airshower_beacon_simulation/ab_modify_clocks.py similarity index 98% rename from simulations/airshower_beacon_simulation/modify_clocks.py rename to simulations/airshower_beacon_simulation/ab_modify_clocks.py index c6b16c4..e5418b5 100755 --- a/simulations/airshower_beacon_simulation/modify_clocks.py +++ b/simulations/airshower_beacon_simulation/ab_modify_clocks.py @@ -9,7 +9,7 @@ from copy import deepcopy as copy from earsim import REvent, Antenna -import generate_beacon as beacon +import aa_generate_beacon as beacon import lib diff --git a/simulations/airshower_beacon_simulation/view_beaconed_antenna.py b/simulations/airshower_beacon_simulation/view_beaconed_antenna.py new file mode 100755 index 0000000..3e33ab5 --- /dev/null +++ b/simulations/airshower_beacon_simulation/view_beaconed_antenna.py @@ -0,0 +1,46 @@ +#!/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()