caput.algorithms.fft.fftw#

Fast FFT implementation using FFTW.

This module adds some minor abstraction to use pyfftw in a way which seems to be faster than using the pyfftw.builders interface, and uses the same api as scipy.fft and numpy.fft.

Only forward and reverse complex->complex transforms are currently supported.

Examples#

The core of this module is the FFTW, which essentially just abstracts the pyfftw.FFTW class in a simple way.

>>> import numpy as np
>>> from caput.algorithms.fft import fftw
>>>
>>> shape = (24, 50)
>>> x = np.random.rand(*shape) + 1j * np.random.rand(*shape)
>>>
>>> fftobj = fftw.FFTW(x.shape, x.dtype, axes=-1)
>>>
>>> X = fftobj.fft(x)
>>> xi = fftobj.ifft(X)
>>>
>>> np.allclose(x, xi)
True

Alternatively, for one-off transforms, the module-level functions can be used, which create FFTW objects internally.

Classes#

FFTW

Create FFTW objects for repeat use.

Functions#

fft(x[, axes])

Perform a forward discrete Fourier Transform.

fftconvolve(in1, in2[, axes])

Convolve two arrays by multiplying in the Fourier domain.

fftwindow(x, window[, axes])

Apply a window function in Fourier space.

ifft(x[, axes])

Perform an inverse discrete Fourier Transform.