import dascore as dc
patch = dc.get_example_patch()
dft_time = patch.dft(dim="time")
dft_time_real = patch.dft(dim="time", real=True)
dft_some_real = patch.dft(dim=("time", "distance"), real="time")
psd = patch.dft(dim="time", real=True, output="PSD")dft
dft(
patch: Patch ,
dim: str | collections.abc.Sequence[str, collections.abc.Sequence[str], None] ,
real: str | bool | None[str, bool, None] = None,
pad: bool = True,
output: Literal[‘FFT’, ‘PSD’, ‘PS’, ‘AS’] = FFT,
db: bool = False,
)-> ‘PatchType’
Perform the discrete Fourier transform (dft) on specified dimension(s).
Parameters
| Parameter | Description |
|---|---|
| patch | Patch to transform. |
| dim | Dimension or dimensions to transform. None transforms all dimensions. |
| real |
Dimension for a real FFT, True for the last requested dimension, or None for complex FFTs along every dimension. |
| pad | Pad each transformed dimension to its next fast FFT length. |
| output |
Spectral representation for each frequency bin: - 'FFT': Complex Fourier coefficients scaled by sample spacing.- 'AS': Amplitude spectrum in the original data units.- 'PS': Power spectrum whose bin sum gives mean square.- 'PSD': Spectral density whose bin-width-weighted sum givesmean square. |
| db |
Convert non-FFT output to decibels without a reference value: use20 * log10 for AS and 10 * log10 for PS or PSD.
|
NumPy FFT output is scaled by each transformed dimension’s sample spacing. Frequency coordinates remain ordered, use reciprocal units, and are named with an ft_ prefix (for example, time becomes ft_time).
A non-dimensional coordinate measured on one transformed dimension is removed from the output coordinates but retained for idft to restore. One spanning multiple dimensions is dropped.
FFT data units combine the original data and transformed-dimension units; other outputs are normalized as described under output.
With real=True, AS, PS, and PSD do not double non-DC or non-Nyquist bins for a one-sided spectrum; multiply the applicable bins when needed.
If every requested dimension is already transformed, dft returns the input unchanged regardless of output. See the FFT notes for details.