added linear attenuation to mask_wl

This commit is contained in:
2024-03-14 14:32:35 +01:00
parent 618ed6d891
commit 8c59f95a01

View File

@@ -203,12 +203,16 @@ class Spectrum(np.ndarray):
return np.trapz(self.time_int, x=self.t, axis=-1) return np.trapz(self.time_int, x=self.t, axis=-1)
def mask_wl( 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: ) -> Spectrum:
""" """
Filters the spectrum with a bandpass centered at `pos` of FWHM `width`. 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 The FWHM is taken on the intensity profile (as would be in an experiment), not on the
complex amplitude complex amplitude.
Parameters Parameters
---------- ----------
@@ -216,12 +220,16 @@ class Spectrum(np.ndarray):
peak of the gaussian bandpass filter in m peak of the gaussian bandpass filter in m
width : float width : float
fwhm of the bandpass filter, in m 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 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 corresponds to (constant_amplitude, phase_only) in `pulse.shot_noise`. By default, shot
noise is not compensated. 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: if shot_noise:
sn = np.reshape( sn = np.reshape(
[pulse.shot_noise(self.w, *shot_noise) for _ in range(np.prod(self.shape[:-1]))], [pulse.shot_noise(self.w, *shot_noise) for _ in range(np.prod(self.shape[:-1]))],