mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
Pulse: noise realisation option to normalise
This commit is contained in:
parent
fd9119ad89
commit
227a897840
1 changed files with 9 additions and 4 deletions
|
@ -53,8 +53,13 @@ class Waveform:
|
||||||
def __len__():
|
def __len__():
|
||||||
return len(self.signal)
|
return len(self.signal)
|
||||||
|
|
||||||
def white_noise_realisation(N_samples, noise_sigma=1, rng=rng):
|
def white_noise_realisation(N_samples, noise_sigma=1, rng=rng, normalise=False):
|
||||||
return rng.normal(0, noise_sigma or 0, size=N_samples)
|
noise = rng.normal(0, noise_sigma or 0, size=N_samples)
|
||||||
|
|
||||||
|
if normalise:
|
||||||
|
noise /= max(noise)
|
||||||
|
|
||||||
|
return noise
|
||||||
|
|
||||||
def antenna_bp(trace, low_bp, high_bp, dt, order=3):
|
def antenna_bp(trace, low_bp, high_bp, dt, order=3):
|
||||||
fs = 1/dt
|
fs = 1/dt
|
||||||
|
@ -170,7 +175,7 @@ if __name__ == "__main__":
|
||||||
N_residuals = 50*3 if len(sys.argv) < 2 else int(sys.argv[1])
|
N_residuals = 50*3 if len(sys.argv) < 2 else int(sys.argv[1])
|
||||||
snr_factors = np.concatenate( # 1/noise_amplitude factor
|
snr_factors = np.concatenate( # 1/noise_amplitude factor
|
||||||
(
|
(
|
||||||
[0.25, 0.5, 0.75],
|
#[0.25, 0.5, 0.75],
|
||||||
[1, 1.5, 2, 2.5, 3, 4, 5, 7],
|
[1, 1.5, 2, 2.5, 3, 4, 5, 7],
|
||||||
[10, 20, 30, 50],
|
[10, 20, 30, 50],
|
||||||
[100, 200, 300, 500]
|
[100, 200, 300, 500]
|
||||||
|
@ -279,7 +284,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
## Add noise
|
## Add noise
|
||||||
noise_amplitude = max(template.signal) * 1/snr_sigma_factor
|
noise_amplitude = max(template.signal) * 1/snr_sigma_factor
|
||||||
noise_realisation = noise_amplitude * white_noise_realisation(len(antenna.signal))
|
noise_realisation = noise_amplitude * white_noise_realisation(len(antenna.signal), normalise=False)
|
||||||
filtered_noise = antenna_bp(noise_realisation, *bp_freq, antenna.dt)
|
filtered_noise = antenna_bp(noise_realisation, *bp_freq, antenna.dt)
|
||||||
|
|
||||||
antenna.signal += filtered_noise
|
antenna.signal += filtered_noise
|
||||||
|
|
Loading…
Reference in a new issue