Skip to main content

fftfreq

Return the Discrete Fourier Transform sample frequencies. The returned array contains the frequency bin centers in cycles per unit of the sample spacing.
Returns: NDArray — Float64 array of length n containing the sample frequencies. For even n, the layout is [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n). For odd n, it is [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n).

rfftfreq

Return the Discrete Fourier Transform sample frequencies for use with rfft. Since rfft returns only the positive half of the spectrum, this function returns frequencies for bins 0, 1, ..., n//2.
Returns: NDArray — Float64 array of length n//2 + 1 containing the non-negative sample frequencies.

fftshift

Shift the zero-frequency component to the center of the spectrum. This is useful for visualizing the Fourier transform with the DC component in the middle.
Returns: NDArray — The shifted array.

ifftshift

Inverse of fftshift. Undoes the centering performed by fftshift, moving the zero-frequency component back to the beginning.
Returns: NDArray — The unshifted array.

Usage Pattern

A common workflow combines these utilities with the FFT functions: