Version 1.0b1 API Documentation generated by Endo 2006-08-14
Discrete Fourier Transforms - FFT.py
The underlying code for these functions is an f2c translated and modified version of the FFTPACK routines.
fft(a, n=None, axis=-1) ifft(a, n=None, axis=-1) rfft(a, n=None, axis=-1) irfft(a, n=None, axis=-1) hfft(a, n=None, axis=-1) ihfft(a, n=None, axis=-1) fftn(a, s=None, axes=None) ifftn(a, s=None, axes=None) rfftn(a, s=None, axes=None) irfftn(a, s=None, axes=None) fft2(a, s=None, axes=(-2,-1)) ifft2(a, s=None, axes=(-2, -1)) rfft2(a, s=None, axes=(-2,-1)) irfft2(a, s=None, axes=(-2, -1))
irefft = deprecate(irfft, 'irefft', 'irfft')
irefft2 = deprecate(irfft2, 'irefft2', 'irfft2')
irefftn = deprecate(irfftn, 'irefftn', 'irfftn')
refft = deprecate(rfft, 'refft', 'rfft')
refft2 = deprecate(rfft2, 'refft2', 'rfft2')
refftn = deprecate(rfftn, 'refftn', 'rfftn')
fft(a, n=None, axis=-1)
Will return the n point discrete Fourier transform of a. n defaults to the length of a. If n is larger than a, then a will be zero-padded to make up the difference. If n is smaller than a, the first n items in a will be used.
The packing of the result is "standard": If A = fft(a, n), then A[0] contains the zero-frequency term, A[1:n/2+1] contains the positive-frequency terms, and A[n/2+1:] contains the negative-frequency terms, in order of decreasingly negative frequency. So for an 8-point transform, the frequencies of the result are [ 0, 1, 2, 3, 4, -3, -2, -1].
This is most efficient for n a power of two. This also stores a cache of working memory for different sizes of fft's, so you could theoretically run into memory problems if you call this too many times with too many different n's.
fft2(a, s=None, axes=(-2,-1))
The 2d fft of a. This is really just fftn with different default behavior.
fftn(a, s=None, axes=None)
The n-dimensional fft of a. s is a sequence giving the shape of the input an result along the transformed axes, as n for fft. Results are packed analogously to fft: the term for zero frequency in all axes is in the low-order corner, while the term for the Nyquist frequency in all axes is in the middle.
If neither s nor axes is specified, the transform is taken along all axes. If s is specified and axes is not, the last len(s) axes are used. If axes are specified and s is not, the input shape along the specified axes is used. If s and axes are both specified and are not the same length, an exception is raised.
hfft(a, n=None, axis=-1) ihfft(a, n=None, axis=-1)
These are a pair analogous to rfft/irfft, but for the opposite case: here the signal is real in the frequency domain and has Hermite symmetry in the time domain. So here it's hermite_fft for which you must supply the length of the result if it is to be odd.
ihfft(hfft(a), len(a)) == a within numerical accuracy.
ifft(a, n=None, axis=-1)
Will return the n point inverse discrete Fourier transform of a. n defaults to the length of a. If n is larger than a, then a will be zero-padded to make up the difference. If n is smaller than a, then a will be truncated to reduce its size.
The input array is expected to be packed the same way as the output of fft, as discussed in it's documentation.
This is the inverse of fft: ifft(fft(a)) == a within numerical accuracy.
This is most efficient for n a power of two. This also stores a cache of working memory for different sizes of fft's, so you could theoretically run into memory problems if you call this too many times with too many different n's.
ifft2(a, s=None, axes=(-2, -1))
The inverse of fft2d. This is really just ifftn with different default behavior.
ifftn(a, s=None, axes=None)
The inverse of fftn.
hfft(a, n=None, axis=-1) ihfft(a, n=None, axis=-1)
These are a pair analogous to rfft/irfft, but for the opposite case: here the signal is real in the frequency domain and has Hermite symmetry in the time domain. So here it's hfft for which you must supply the length of the result if it is to be odd.
ihfft(hfft(a), len(a)) == a within numerical accuracy.
irfft(a, n=None, axis=-1)
Will return the real valued n point inverse discrete Fourier transform of a, where a contains the nonnegative frequency terms of a Hermite-symmetric sequence. n is the length of the result, not the input. If n is not supplied, the default is 2*(len(a)-1). If you want the length of the result to be odd, you have to say so.
If you specify an n such that a must be zero-padded or truncated, the extra/removed values will be added/removed at high frequencies. One can thus resample a series to m points via Fourier interpolation by: a_resamp = irfft(rfft(a), m).
This is the inverse of rfft: irfft(rfft(a), len(a)) == a within numerical accuracy.
irfft2(a, s=None, axes=(-2, -1))
The inverse of rfft2. This is really just irfftn with different default behavior.
irfftn(a, s=None, axes=None)
The inverse of rfftn. The transform implemented in ifft is applied along all axes but the last, then the transform implemented in irfft is performed along the last axis. As with irfft, the length of the result along that axis must be specified if it is to be odd.
rfft(a, n=None, axis=-1)
Will return the n point discrete Fourier transform of the real valued array a. n defaults to the length of a. n is the length of the input, not the output.
The returned array will be the nonnegative frequency terms of the Hermite-symmetric, complex transform of the real array. So for an 8-point transform, the frequencies in the result are [ 0, 1, 2, 3, 4]. The first term will be real, as will the last if n is even. The negative frequency terms are not needed because they are the complex conjugates of the positive frequency terms. (This is what I mean when I say Hermite-symmetric.)
This is most efficient for n a power of two.
rfft2(a, s=None, axes=(-2,-1))
The 2d fft of the real valued array a. This is really just rfftn with different default behavior.
rfftn(a, s=None, axes=None)
The n-dimensional discrete Fourier transform of a real array a. A real transform as rfft is performed along the axis specified by the last element of axes, then complex transforms as fft are performed along the other axes.
| Local name | Refers to |
|---|---|
| arange | numpy.core.numeric.arange |
| array | numpy.core.defchararray.array |
| asarray | numpy.core.defchararray.asarray |
| concatenate | numpy.core.numeric.concatenate |
| fftfreq | numpy.dft.helper.fftfreq |
| fftpack | fftpack_lite |
| fftshift | numpy.dft.helper.fftshift |
| ifftshift | numpy.dft.helper.ifftshift |
| shape | numpy.core.fromnumeric.shape |
| swapaxes | numpy.core.fromnumeric.swapaxes |
| take | numpy.core.fromnumeric.take |
| types | types |
| zeros | numpy.core.numeric.zeros |