From 616a23ef2b3400fc0b6e03c8ad54e7a65c356a96 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Fri, 25 Nov 2022 12:08:00 +0100 Subject: [PATCH] ZH: write more beacon properties to tx file --- .../aa_generate_beacon.py | 72 ++++++++++++------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/simulations/airshower_beacon_simulation/aa_generate_beacon.py b/simulations/airshower_beacon_simulation/aa_generate_beacon.py index 0366b9e..3d86c52 100755 --- a/simulations/airshower_beacon_simulation/aa_generate_beacon.py +++ b/simulations/airshower_beacon_simulation/aa_generate_beacon.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# vim: fdm=indent ts=4 +# vim: fdm=marker ts=4 """ Add a beacon measurement on top of the @@ -15,23 +15,27 @@ from copy import deepcopy from earsim import REvent, Antenna, block_filter import lib +# {{{ vim marker tx_fname = 'tx.json' antennas_fname = 'antennas.hdf5' -def write_tx_file(fname, tx, f_beacon): +def write_tx_file(fname, tx, f_beacon, **kwargs): with open(fname, 'w') as fp: return json.dump( - dict( - f_beacon=f_beacon, - tx=dict( - x=tx.x, - y=tx.y, - z=tx.z, - name=tx.name + { + **kwargs, + **dict( + f_beacon=f_beacon, + tx=dict( + x=tx.x, + y=tx.y, + z=tx.z, + name=tx.name ) - ), + ) + }, fp - ) + ) def read_tx_file(fname): with open(fname, 'r') as fp: @@ -40,7 +44,10 @@ def read_tx_file(fname): f_beacon = data['f_beacon'] tx = Antenna(**data['tx']) - return tx, f_beacon + del data['f_beacon'] + del data['tx'] + + return tx, f_beacon, data def read_beacon_hdf5(fname, **h5ant_kwargs): with h5py.File(fname, 'r') as h5: @@ -227,15 +234,26 @@ def write_baseline_time_diffs_hdf5(fname, baselines, true_phase_diffs, k_periods data = np.vstack( (time_diffs, f_beacon, true_phase_diffs, k_periods) ).T dset = group.create_dataset(dset_name, data=data) +# }}} vim marker if __name__ == "__main__": from os import path + fname = "ZH_airshower/mysim.sry" + + # Transmitter remake_tx = True - fname = "ZH_airshower/mysim.sry" - tx = Antenna(x=-500,y=0,z=0,name='tx') # m - if not True: # slowest beacon to be found: + tx = Antenna(x=-2e3,y=0,z=0,name='tx') # m + if False: + # Move tx out a long way + tx.x, tx.y = -75e3, 75e3 # m + elif False: + # Move it to 0,0,0 (among the antennas) + tx.x, tx.y = 0, 0 #m + + # Beacon properties + if False: # slowest beacon to be found: f_beacon = 10e-3 # GHz low_bp = 5e-3 # GHz high_bp = 80e-3 # GHz @@ -246,31 +264,35 @@ if __name__ == "__main__": low_bp = 30e-3 # GHz high_bp = 80e-3 # GHz - # Disable block_filter - if False: - block_filter = lambda x, dt, low, high: x - - beacon_amplitudes = 1e-6*np.array([1e2, 0, 0]) # mu V/m - beacon_radiate_rsq = True + beacon_amplitudes = 1e-6*np.array([1e5, 0, 0]) # mu V/m + beacon_radiate_rsq = True # beacon_amplitude is repaired for distance to 0,0,0 + # modify beacon power to be beacon_amplitude at 0,0,0 if beacon_radiate_rsq: - # Move tx out, and magnify beacon_amplitude (at tx) - tx = Antenna(x=-20e3,y=0,z=0,name='tx') # m dist = lib.distance(tx, Antenna(x=0, y=0, z=0)) ampl = max(1, dist**2) beacon_amplitudes *= ampl + # Disable block_filter + if False: + block_filter = lambda x, dt, low, high: x + #### fname_dir = path.dirname(fname) tx_fname = path.join(fname_dir, tx_fname) antennas_fname = path.join(fname_dir, antennas_fname) + # read/write tx properties if not path.isfile(tx_fname) or remake_tx: - write_tx_file(tx_fname, tx, f_beacon) + write_tx_file(tx_fname, tx, f_beacon, amplitudes=beacon_amplitudes.tolist(), radiate_rsq=beacon_radiate_rsq) else: - tx, f_beacon = read_tx_file(tx_fname) + tx, f_beacon, _ = read_tx_file(tx_fname) + + + print("Beacon amplitude at (0,0,0) [muV/m]:", beacon_amplitudes) + print("Tx location:", [tx.x, tx.y, tx.z]) # read in antennas ev = REvent(fname)