fft(a, *v, **kw) | |
ifft(a, *v, **kw) | |
fftn(a, *v, **kw) | |
ifftn(a, *v, **kw) | |
rfft(a, *v, **kw) | |
irfft(a, *v, **kw) | |
rfftn(a, *v, **kw) | |
irfftn(a, *v, **kw) | |
fftshift(x[, axes]) | Shift the zero-frequency component to the center of the spectrum. |
ifftshift(x[, axes]) | The inverse of fftshift. |
fftfreq(n[, d]) | Return the Discrete Fourier Transform sample frequencies. |
Wrappers for the FFT. Uses the :pkg:`anfft` package if available (which wraps the FFTW3), otherwise uses numpy.fft.
Shift the zero-frequency component to the center of the spectrum.
This function swaps half-spaces for all axes listed (defaults to all). Note that y[0] is the Nyquist component only if len(x) is even.
Parameters : | x : array_like
axes : int or shape tuple, optional
|
---|---|
Returns : | y : ndarray
|
See also
Examples
>>> freqs = np.fft.fftfreq(10, 0.1)
>>> freqs
array([ 0., 1., 2., 3., 4., -5., -4., -3., -2., -1.])
>>> np.fft.fftshift(freqs)
array([-5., -4., -3., -2., -1., 0., 1., 2., 3., 4.])
Shift the zero-frequency component only along the second axis:
>>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
>>> freqs
array([[ 0., 1., 2.],
[ 3., 4., -4.],
[-3., -2., -1.]])
>>> np.fft.fftshift(freqs, axes=(1,))
array([[ 2., 0., 1.],
[-4., 3., 4.],
[-1., -3., -2.]])
The inverse of fftshift.
Parameters : | x : array_like
axes : int or shape tuple, optional
|
---|---|
Returns : | y : ndarray
|
See also
Examples
>>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
>>> freqs
array([[ 0., 1., 2.],
[ 3., 4., -4.],
[-3., -2., -1.]])
>>> np.fft.ifftshift(np.fft.fftshift(freqs))
array([[ 0., 1., 2.],
[ 3., 4., -4.],
[-3., -2., -1.]])
Return the Discrete Fourier Transform sample frequencies.
The returned float array contains the frequency bins in cycles/unit (with zero at the start) given a window length n and a sample spacing d:
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) if n is odd
Parameters : | n : int
d : scalar
|
---|---|
Returns : | out : ndarray
|
Examples
>>> signal = np.array([-2, 8, 6, 4, 1, 0, 3, 5], dtype=float)
>>> fourier = np.fft.fft(signal)
>>> n = signal.size
>>> timestep = 0.1
>>> freq = np.fft.fftfreq(n, d=timestep)
>>> freq
array([ 0. , 1.25, 2.5 , 3.75, -5. , -3.75, -2.5 , -1.25])