dft

function of dascore.transform.fourier source

dft(
    patch: Patch ,
    dim: str | None | collections.abc.Sequence[str, None, collections.abc.Sequence[str]] ,
    real: str | bool | None[str, bool, None] = None,
    pad: bool = True,
)-> ‘PatchType’

Perform the discrete Fourier transform (dft) on specified dimension(s).

Parameters

Parameter Description
patch Patch to transform.
dim A single, or multiple dimensions over which to perform dft. If
None, perform dft over all dimensions.
real Either 1) The name of the axis over which to perform a rfft, 2)
True, which means the last (possibly only) dimenson should have an
rfft performed, or 3) None, meaning no rfft.
pad If True, pad patch before peforming dft along desired dimensions to
the next fast length. This can avoid major slow-downs when dimension
lengths are prime numbers.
Note
  • Simply uses numpy’s fft module but outputs are scaled by the sample spacing along each transformed dimension and coordinates corresponding to frequency bins are shifted so they remain ordered.

  • Each transformed dimension is renamed with a preceding ft_. e.g., time becomes ft_time (ft stands for fourier transform).

  • Each transformed dimension has units of 1/original units.

  • Output data units are the original data units multiplied by the units of each transformed dimension.

  • Non-dimensional coordiantes associated with transformed coordinates will be dropped in the output.

  • See the FFT notes for more details.

See Also

-idft

Examples

import dascore as dc
patch = dc.get_example_patch()
# perform dft (fft) on time axis
dft_time = patch.dft(dim="time")
# make it a real fft (no negative frequencies)
dft_time_real = patch.dft(dim="time", real=True)
# dft on specified dimensions, specify real dimension
dft_some_real = patch.dft(dim=("time", "distance"), real="time")