Scipy - FFT Cheat Sheet
Scipy - FFT Cheat Sheet
Scipy - FFT Cheat Sheet
New to the scipy.fft module? Check out Fourier Transforms With scipy.fft: Python Signal Processing.
Note: Functions with names beginning with i are the inverse of the functions that share the name without the i.
Compute the fast Fourier transform on one-, two-, and n-dimensional input. Compute the discrete cosine transform on one- and n-dimensional input. Real-
Work on real or complex input. valued input and output. Often a better choice than fft() or rfft().
Compute the fast Fourier transform on one-, two-, and n-dimensional real input. Compute the discrete sine transform on one- and n-dimensional input. Real-
Faster than the fft*() functions. valued input and output.
Compute the fast Fourier transform on one-, two-, and n-dimensional input that By default, the fft and fftfreq functions return all the positive components,
has Hermitian symmetry. Produce real-valued output. followed by all the negative components. This function swaps the two halves so
that the zero-frequency component is in the center: [0, 1, 2, -3, -2, -1] →
[-3, -2, -1, 0, 1, 2, 3].
realpython.com 1
scipy.fft Cheat Sheet
Get the frequencies of each bin returned by the FFT functions, such as the X-axis. Context manager to set the number of parallel worker threads used to compute
the FFT.
next_fast_len()
get_workers()
The FFT functions work fastest at certain lengths of input. This function returns
the next largest one for use with zero-padding. Returns the number of workers used in the current context.
Note: I’ve left out backend-switching functions since, at the time of writing, SciPy ships with only one available backend.
There are three main transforms that scipy.fft deals with: the discrete Fourier transform, the discrete cosine transform, and the discrete sine transform. This section is a quick
reminder of what each transform is.
realpython.com 2