From 2ef87343f5079dcaf87d03862147fd7a2cad5d52 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Mon, 5 Dec 2022 14:35:35 +0100 Subject: [PATCH] ZH: optional trace extender (WIP) --- .../aa_generate_beacon.py | 32 ++++++++++++++----- .../ab_modify_clocks.py | 2 +- .../airshower_beacon_simulation/lib/lib.py | 4 ++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/simulations/airshower_beacon_simulation/aa_generate_beacon.py b/simulations/airshower_beacon_simulation/aa_generate_beacon.py index bb05fec..b932649 100755 --- a/simulations/airshower_beacon_simulation/aa_generate_beacon.py +++ b/simulations/airshower_beacon_simulation/aa_generate_beacon.py @@ -264,7 +264,7 @@ if __name__ == "__main__": low_bp = 30e-3 # GHz high_bp = 80e-3 # GHz - beacon_amplitudes = 1e-6*np.array([1e5, 0, 0]) # mu V/m + beacon_amplitudes = 1e-6*np.array([1e3, 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 @@ -303,15 +303,30 @@ if __name__ == "__main__": # make beacon per antenna for i, antenna in enumerate(ev.antennas): + if False: # modify trace lengths + N_samples = len(antenna.t) + new_N = 2*N_samples + + dt = antenna.t[1] - antenna.t[0] + new_t = np.arange(0, new_N)*dt + antenna.t[0] + + antenna.t = new_t + + # TODO:trace extrapolation? + antenna.Ex = np.pad(antenna.Ex, (0, new_N-N_samples), mode='constant', constant_values=0) + antenna.Ey = np.pad(antenna.Ey, (0, new_N-N_samples), mode='constant', constant_values=0) + antenna.Ez = np.pad(antenna.Ez, (0, new_N-N_samples), mode='constant', constant_values=0) + + t0 = 0 + c_light = 3e8*1e-9 # m/ns if False: - t0 = lib.distance(tx, antenna)/3e8 * 1e9 # ns + # precalculate t0 + # set c_light=np.inf to suppress the time delay + # in the function call + t0 = lib.distance(tx, antenna)/c_light c_light = np.inf - else: - t0 = 0 - c_light = 3e8*1e-9 # m/ns beacon = lib.beacon_from(tx, antenna, f_beacon, antenna.t, t0=t0, c_light=c_light, radiate_rsq=beacon_radiate_rsq) - traces = np.array([antenna.Ex, antenna.Ey, antenna.Ez, beacon]) # add to relevant polarisation @@ -323,8 +338,9 @@ if __name__ == "__main__": append_antenna_hdf5( antennas_fname, antenna, traces, name='traces', prepend_time=True, attrs_dict=dict(t0=t0)) # Save E field in E_AxB - E = [np.dot(ev.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(traces[0], traces[1], traces[2])] + E_AxB = [np.dot(ev.uAxB,[ex,ey,ez]) for ex,ey,ez in zip(traces[0], traces[1], traces[2])] + t_AxB = antenna.t - append_antenna_hdf5( antennas_fname, antenna, [E], name='E_AxB', prepend_time=True) + append_antenna_hdf5( antennas_fname, antenna, [t_AxB, E_AxB], name='E_AxB', prepend_time=False) print("Antenna HDF5 file written as " + str(antennas_fname)) diff --git a/simulations/airshower_beacon_simulation/ab_modify_clocks.py b/simulations/airshower_beacon_simulation/ab_modify_clocks.py index 61f7acd..608c501 100755 --- a/simulations/airshower_beacon_simulation/ab_modify_clocks.py +++ b/simulations/airshower_beacon_simulation/ab_modify_clocks.py @@ -19,7 +19,7 @@ if __name__ == "__main__": from os import path import sys - max_clock_offset = 100 if len(sys.argv) < 1 else int(sys.argv[1]) # ns + max_clock_offset = 100 if len(sys.argv) < 2 else int(sys.argv[1]) # ns remake_clock_offsets = True seed = 12345 diff --git a/simulations/airshower_beacon_simulation/lib/lib.py b/simulations/airshower_beacon_simulation/lib/lib.py index 7441686..3a3f2c1 100644 --- a/simulations/airshower_beacon_simulation/lib/lib.py +++ b/simulations/airshower_beacon_simulation/lib/lib.py @@ -42,7 +42,9 @@ def geometry_time(dist, x2=None, c_light=3e8): def beacon_from(tx, rx, f, t=0, t0=0, c_light=3e8, radiate_rsq=True, amplitude=1,**kwargs): dist = distance(tx,rx) - t0 = t0 + dist/c_light + # suppress extra time delay from distance + if c_light is not None and np.isfinite(c_light): + t0 = t0 + dist/c_light if radiate_rsq: if np.isclose(dist, 0):