diff --git a/src/rabifun/analysis.py b/src/rabifun/analysis.py index 933e57b..e9bb2f7 100644 --- a/src/rabifun/analysis.py +++ b/src/rabifun/analysis.py @@ -2,12 +2,17 @@ import numpy as np def fourier_transform( - t: np.ndarray, signal: np.ndarray, window: tuple[float, float] | None = None + t: np.ndarray, + signal: np.ndarray, + window: tuple[float, float] | None = None, + low_cutoff: float = 0, + high_cutoff: float = np.inf, ): """ Compute the Fourier transform of a signal from the time array ``t`` and the real signal ``signal``. Optionally, a time window - can be specified through ``window = ([begin], [end])`` . + can be specified through ``window = ([begin], [end])`` . The + ``low_cuttof (high_cutoff)`` is the lower (upper) bound of frequencies returned. :returns: The (linear) frequency array and the Fourier transform. """ @@ -20,4 +25,5 @@ def fourier_transform( freq = np.fft.rfftfreq(len(t), t[1] - t[0]) fft = np.fft.rfft(signal) - return freq, fft + mask = (freq > low_cutoff) & (freq < high_cutoff) + return freq[mask], fft[mask]