mirror of
https://github.com/vale981/fibre_walk_project_code
synced 2025-03-04 09:21:38 -05:00
CHORE: Document fft helper
This commit is contained in:
parent
8706404b50
commit
393610e0cc
1 changed files with 9 additions and 3 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Reference in a new issue