fft¶
-
powerbox.dft.
fft
(X, L=None, Lk=None, a=0, b=6.283185307179586, axes=None, ret_cubegrid=False)[source]¶ Arbitrary-dimension nice Fourier Transform.
This function wraps numpy’s
fftn
and applies some nice properties. Notably, the returned fourier transform is equivalent to what would be expected from a continuous Fourier Transform (including normalisations etc.). In addition, arbitrary conventions are supported (seepowerbox.dft
for details).Default parameters have the same normalising conventions as
numpy.fft.fftn
.The output object always has the zero in the centre, with monotonically increasing spectral arguments.
Parameters: - X : array
An array with arbitrary dimensions defining the field to be transformed. Should correspond exactly to the continuous function for which it is an analogue. A lower-dimensional transform can be specified by using the
axes
argument.- L : float or array-like, optional
The length of the box which defines
X
. If a scalar, each transformed dimension inX
is assumed to have the same length. If array-like, must be of the same length as the number of transformed dimensions. The default returns the un-normalised DFT (same as numpy).- Lk : float or array-like, optional
The length of the fourier-space box which defines the dual of
X
. Only one of L/Lk needs to be provided. If provided, L takes precedence. If a scalar, each transformed dimension inX
is assumed to have the same length. If array-like, must be of the same length as the number of transformed dimensions.- a,b : float, optional
These define the Fourier convention used. See
powerbox.dft
for details. The defaults return the standard DFT as defined innumpy.fft
.- axes : sequence of ints, optional
The axes to take the transform over. The default is to use all axes for the transform.
- ret_cubegrid : bool, optional
Whether to return the entire grid of frequency magnitudes.
Returns: - ft : array
The DFT of X, normalised to be consistent with the continuous transform.
- freq : list of arrays
The frequencies in each dimension, consistent with the Fourier conventions specified.
- grid : array
Only returned if
ret_cubegrid
isTrue
. An array with shape given byaxes
specifying the magnitude of the frequencies at each point of the fourier transform.