scipy.fft interface

This module implements those functions that replace aspects of the scipy.fft module. This module provides the entire documented namespace of scipy.fft, but those functions that are not included here are imported directly from scipy.fft.

The exceptions raised by each of these functions are mostly as per their equivalents in scipy.fft, though there are some corner cases in which this may not be true.

Some corner (mis)usages of scipy.fft may not transfer neatly. For example, using scipy.fft.fft2() with a non 1D array and a 2D s argument will return without exception whereas pyfftw.interfaces.scipy_fft.fft2() will raise a ValueError.

pyfftw.interfaces.scipy_fft.fft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 1D FFT.

The first six arguments are as per scipy.fft.fft(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.fft2(x, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 2D FFT.

The first six arguments are as per scipy.fft.fft2(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.fftn(x, s=None, axes=None, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform an n-D FFT.

The first six arguments are as per scipy.fft.fftn(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.hfft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 1D Hermitian FFT.

The first six arguments are as per scipy.fft.hfft(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.ifft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 1D inverse FFT.

The first six arguments are as per scipy.fft.ifft(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.ifft2(x, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 2D inverse FFT.

The first six arguments are as per scipy.fft.ifft2(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.ifftn(x, s=None, axes=None, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform an n-D inverse FFT.

The first six arguments are as per scipy.fft.ifftn(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.ihfft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 1D Hermitian inverse FFT.

The first six arguments are as per scipy.fft.ihfft(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.irfft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 1D real inverse FFT.

The first six arguments are as per scipy.fft.irfft(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.irfft2(x, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 2D real inverse FFT.

The first six arguments are as per scipy.fft.irfft2(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.irfftn(x, s=None, axes=None, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform an n-D real inverse FFT.

The first six arguments are as per scipy.fft.irfftn(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.next_fast_len(target)

Find the next fast transform length for FFTW.

FFTW has efficient functions for transforms of length 2**a * 3**b * 5**c * 7**d * 11**e * 13**f, where e + f is either 0 or 1.

Parameters

target (int) – Length to start searching from. Must be a positive integer.

Returns

out – The first fast length greater than or equal to target.

Return type

int

Examples

On a particular machine, an FFT of prime length takes 2.1 ms:

>>> from pyfftw.interfaces import scipy_fftpack
>>> min_len = 10007  # prime length is worst case for speed
>>> a = numpy.random.randn(min_len)
>>> b = scipy_fftpack.fft(a)

Zero-padding to the next fast length reduces computation time to 406 us, a speedup of ~5 times:

>>> next_fast_len(min_len)
10080
>>> b = scipy_fftpack.fft(a, 10080)

Rounding up to the next power of 2 is not optimal, taking 598 us to compute, 1.5 times as long as the size selected by next_fast_len.

>>> b = fftpack.fft(a, 16384)

Similar speedups will occur for pre-planned FFTs as generated via pyfftw.builders.

pyfftw.interfaces.scipy_fft.rfft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 1D real FFT.

The first six arguments are as per scipy.fft.rfft(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.rfft2(x, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform a 2D real FFT.

The first six arguments are as per scipy.fft.rfft2(); the rest of the arguments are documented in the additional argument docs.

pyfftw.interfaces.scipy_fft.rfftn(x, s=None, axes=None, norm=None, overwrite_x=False, workers=None, planner_effort=None, auto_align_input=True, auto_contiguous=True)

Perform an n-D real FFT.

The first six arguments are as per scipy.fft.rfftn(); the rest of the arguments are documented in the additional argument docs.