diff --git a/lisainstrument/noises.py b/lisainstrument/noises.py index a49ff2ee7d7b55e730c690930693a1997ab558c7..530cc2806a368f75729e6d2fe567fbf603aa6a75 100644 --- a/lisainstrument/noises.py +++ b/lisainstrument/noises.py @@ -80,7 +80,8 @@ def violet(fs, size, asd): Args: fs: sampling frequency [Hz] size: number of samples [samples] - asd: amplitude spectral density [/sqrt(Hz)]""" + asd: amplitude spectral density [/sqrt(Hz)] + """ logger.debug("Generating violet noise (fs=%s Hz, size=%s, asd=%s)", fs, size, asd) if not asd: logger.debug("Vanishing power spectral density, bypassing noise generation") @@ -89,18 +90,20 @@ def violet(fs, size, asd): return np.gradient(white_noise, 1 / fs) / (2 * pi) -def pink(fs, size, asd): +def pink(fs, size, asd, fmin=None): """Generate a pink noise in f^(-1/2) in amplitude. Args: fs: sampling frequency [Hz] size: number of samples [samples] - asd: amplitude spectral density [/sqrt(Hz)]""" + asd: amplitude spectral density [/sqrt(Hz)] + fmin: saturation frequency (default to fs / size) [Hz] + """ logger.debug("Generating pink noise (fs=%s Hz, size=%s, asd=%s)", fs, size, asd) if not asd: logger.debug("Vanishing power spectral density, bypassing noise generation") return 0 - generator = pyplnoise.PinkNoise(fs, fs / size, fs / 2) + generator = pyplnoise.PinkNoise(fs, fmin or fs / size, fs / 2) return asd / sqrt(2) * generator.get_series(size) @@ -110,7 +113,8 @@ def red(fs, size, asd): Args: fs: sampling frequency [Hz] size: number of samples [samples] - asd: amplitude spectral density [/sqrt(Hz)]""" + asd: amplitude spectral density [/sqrt(Hz)] + """ logger.debug("Generating red noise (fs=%s Hz, size=%s, asd=%s)", fs, size, asd) if not asd: logger.debug("Vanishing power spectral density, bypassing noise generation") @@ -125,7 +129,8 @@ def infrared(fs, size, asd): Args: fs: sampling frequency [Hz] size: number of samples [samples] - asd: amplitude spectral density [/sqrt(Hz)]""" + asd: amplitude spectral density [/sqrt(Hz)] + """ logger.debug("Generating infrared noise (fs=%s Hz, size=%s, asd=%s)", fs, size, asd) if not asd: logger.debug("Vanishing power spectral density, bypassing noise generation") @@ -173,11 +178,14 @@ def clock(fs, size, asd): S_q(f) [ffd] = (asd)^2 f^(-1) + Clock noise saturates below 1E-5 Hz, as the low-frequency part is modeled by + deterministing clock drifts. + Args: asd: amplitude spectral density [/sqrt(Hz)] """ logger.debug("Generating clock noise fluctuations (fs=%s Hz, size=%s, asd=%s /sqrt(Hz))", fs, size, asd) - return pink(fs, size, asd) + return pink(fs, size, asd, fmin=1E-5) def modulation(fs, size, asd):