diff --git a/simulations/airshower_beacon_simulation/aa_generate_beacon.py b/simulations/airshower_beacon_simulation/aa_generate_beacon.py index 46e9c41..68b3222 100755 --- a/simulations/airshower_beacon_simulation/aa_generate_beacon.py +++ b/simulations/airshower_beacon_simulation/aa_generate_beacon.py @@ -92,7 +92,7 @@ def read_beacon_hdf5(fname, **h5ant_kwargs): return f_beacon, tx, antennas -def Antenna_from_h5ant(h5ant, traces_key='traces', raise_exception=True, read_AxB=True, read_beacon_info=True): +def Antenna_from_h5ant(h5ant, traces_key='filtered_traces', raise_exception=True, read_AxB=True, read_beacon_info=True): mydict = { k:h5ant.attrs.get(k) for k in ['x', 'y', 'z', 'name'] } ant = Antenna(**mydict) if h5ant.attrs: @@ -362,6 +362,8 @@ if __name__ == "__main__": # make beacon per antenna for i, antenna in enumerate(ev.antennas): + #TODO: allow to change the samplerate (2, 4, 8 ns) + if i%10 == 0: print(f"Beaconed antenna {i} out of", len(ev.antennas)) @@ -394,15 +396,20 @@ if __name__ == "__main__": # Collect all data to be saved (with the first 3 values the E fields) traces = np.array([antenna.Ex, antenna.Ey, antenna.Ez, beacon, noise_realisation]) - # add to relevant polarisation - # and apply block filter - dt = antenna.t[1] - antenna.t[0] + # add beacon and noise to relevant polarisations for j, amp in enumerate(beacon_amplitudes): - traces[j] = block_filter(traces[j] + amp*beacon + noise_realisation, dt, low_bp, high_bp) + traces[j] = traces[j] + amp*beacon + noise_realisation - append_antenna_hdf5( antennas_fname, antenna, traces, name='traces', prepend_time=True) + append_antenna_hdf5( antennas_fname, antenna, traces, name='raw_traces', prepend_time=True) - # Save E field in E_AxB + # .. and apply block_filter to every trace + dt = antenna.t[1] - antenna.t[0] + for j in range(len(traces)): + traces[j] = block_filter(traces[j], dt, low_bp, high_bp) + + append_antenna_hdf5( antennas_fname, antenna, traces, name='filtered_traces', prepend_time=True) + + # Save filtered E field in E_AxB 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