From 8c59f95a014638b81731e9a4df97d0dbee8e8238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Sierro?= Date: Thu, 14 Mar 2024 14:32:35 +0100 Subject: [PATCH] added linear attenuation to mask_wl --- src/scgenerator/spectra.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/scgenerator/spectra.py b/src/scgenerator/spectra.py index 45fafda..54906c4 100644 --- a/src/scgenerator/spectra.py +++ b/src/scgenerator/spectra.py @@ -203,12 +203,16 @@ class Spectrum(np.ndarray): return np.trapz(self.time_int, x=self.t, axis=-1) def mask_wl( - self, pos: float, width: float, shot_noise: pulse.ShotNoiseParameter | None = None + self, + pos: float, + width: float, + shot_noise: pulse.ShotNoiseParameter | None = None, + peak: float = 1.0, ) -> Spectrum: """ Filters the spectrum with a bandpass centered at `pos` of FWHM `width`. The FWHM is taken on the intensity profile (as would be in an experiment), not on the - complex amplitude + complex amplitude. Parameters ---------- @@ -216,12 +220,16 @@ class Spectrum(np.ndarray): peak of the gaussian bandpass filter in m width : float fwhm of the bandpass filter, in m - sn_args : (bool, bool) | None, optional + shot_noise : (bool, bool) | ShotNoiseParameter | None, optional if specified, shot noise is compensated in the attenuation process and this tuple corresponds to (constant_amplitude, phase_only) in `pulse.shot_noise`. By default, shot noise is not compensated. + peak : float, optional + relative height of the peak of the bandpass filter, by default 1.0, which means the + spectrum is untouched at `pos` and attenuated elsewhere. If <1.0, will attenuate even + the peak. """ - band = np.exp(-(((self.l - pos) / (pulse.fwhm_to_T0_fac["gaussian"] * width)) ** 2)) + band = peak * np.exp(-(((self.l - pos) / (pulse.fwhm_to_T0_fac["gaussian"] * width)) ** 2)) if shot_noise: sn = np.reshape( [pulse.shot_noise(self.w, *shot_noise) for _ in range(np.prod(self.shape[:-1]))],