Pulse: explicit window for signal + cache writing toggle

This commit is contained in:
Eric Teunis de Boone 2023-05-17 17:35:36 +02:00
parent 003245fbd0
commit f4d8966df8

View file

@ -192,6 +192,7 @@ def get_time_residuals_for_template(
snr_sigma_factor=10,bp_freq=(0,np.inf),
normalise_noise=False, h5_cache_fname=None, read_cache=True, write_cache=None,
rng=rng, tqdm=tqdm,
peak_window=[0.2, 0.8],
):
# Read in cached time residuals
if read_cache:
@ -211,7 +212,7 @@ def get_time_residuals_for_template(
## place the deltapeak signal at a random location
antenna = Waveform(None, dt=antenna_dt, name='Signal')
if interpolation_template is None: # Create antenna trace without interpolation template
antenna_true_signal, antenna_peak_sample = util.deltapeak(timelength=antenna_timelength, samplerate=1/antenna.dt, offset=[0.2, 0.8], rng=rng)
antenna_true_signal, antenna_peak_sample = util.deltapeak(timelength=antenna_timelength, samplerate=1/antenna.dt, offset=peak_window, rng=rng)
antenna.peak_sample = antenna_peak_sample
antenna.peak_time = antenna.dt * antenna.peak_sample
@ -220,7 +221,8 @@ def get_time_residuals_for_template(
print(f"Antenna Peak Sample: {antenna.peak_sample}")
else: # Sample the interpolation template at some offset
antenna.peak_time = antenna_timelength * ((0.8 - 0.2) *rng.random(1) + 0.2)
peak_window_length = peak_window[-1] - peak_window[0]
antenna.peak_time = antenna_timelength * (peak_window_length*rng.random(1) + peak_window[0])
sampling_offset = rng.random(1)*antenna.dt
antenna.t = util.sampled_time(1/antenna.dt, start=0, end=antenna_timelength)
@ -438,6 +440,7 @@ if __name__ == "__main__":
h5_cache_fname = f'11_pulsed_timing.hdf5'
use_cache = True
write_cache = None # Leave None for default action
#
# Interpolation Template
@ -489,7 +492,7 @@ if __name__ == "__main__":
N_residuals, template, interpolation_template=interp_template,
antenna_dt=antenna_dt, antenna_timelength=antenna_timelength,
snr_sigma_factor=snr_sigma_factor, bp_freq=bp_freq, normalise_noise=normalise_noise,
h5_cache_fname=h5_cache_fname, rng=rng, tqdm=tqdm, read_cache=use_cache)
h5_cache_fname=h5_cache_fname, rng=rng, tqdm=tqdm, read_cache=use_cache, write_cache=write_cache)
print()# separating tqdm
print()# separating tqdm