diff --git a/src/scgenerator/noise.py b/src/scgenerator/noise.py index ec0cd8b..63cf7a0 100644 --- a/src/scgenerator/noise.py +++ b/src/scgenerator/noise.py @@ -104,7 +104,8 @@ class NoiseMeasurement: dB: bool = True, wavelength: float | None = None, power: float | None = None, - crop: int | float = 1, + left: int = 1, + right: int = -1, ) -> tuple[np.ndarray, np.ndarray]: """ Transforms the PSD in a way that makes it easy to plot @@ -116,9 +117,12 @@ class NoiseMeasurement: wavelength, power : float | None, optional if both are provided, will be used to compute the quantum noise limit and the PSD will be output relative to that amount - crop : int, optional - how many low frequency points to drop. The default (1) is to drop only the 0 frequency + left : int, optional + Index of the first frequency point. The default (1) is to drop only the 0 frequency point, as it is outside the plot range when plotting the PSD on a log-log plot. + right : int, optional + index of the last frequency point, non inclusive (i.e. like slices). The default (-1) is + to drop only the Nyquist frequency, as segmentation artificially reduces its value. Returns ------- @@ -131,7 +135,7 @@ class NoiseMeasurement: ------- >>> noise = NoiseMeasurement(*np.load("my_measurement.npy")) >>> plt.plot(*noise.plottable(wavelength=800e-9, power=0.3)) # dB above quantum limit - >>> plt.xscale("log") + >>> plt.xscale("log") # creates log-log plot is dB is already log scale for y axis >>> plt.show() """ psd = self.psd @@ -141,10 +145,7 @@ class NoiseMeasurement: if dB: psd = math.to_dB(psd, ref=1.0) - if isinstance(crop, (float, np.floating)): - crop = math.argclosest(self.freq, crop) - - return self.freq[crop:], psd[crop:] + return self.freq[left:right], psd[left:right] def sample_spectrum( self, nf: int, dt: float | None = None, log_mode: bool = False