plan_fft#

diffsims.utils.fourier_transform.plan_fft(A, n=None, axis=None, norm=None, **_)[source]#

Plans an fft for repeated use. Parameters are the same as for pyfftw’s fftn which are, where possible, the same as the numpy equivalents. Note that some functionality is only possible when using the pyfftw backend.

Parameters:
  • A (numpy.ndarray, of dimension d) – Array of same shape to be input for the fft

  • n (iterable or None, len(n) == d, optional) – The output shape of fft (default=`None` is same as A.shape)

  • axis (int, iterable length d, or None, optional) – The axis (or axes) to transform (default=`None` is all axes)

  • overwrite (bool, optional) – Whether the input array can be overwritten during computation (default=False)

  • planner ({0, 1, 2, 3}, optional) – Amount of effort put into optimising Fourier transform where 0 is low and 3 is high (default=`1`).

  • threads (int, None) – Number of threads to use (default=`None` is all threads)

  • auto_align_input (bool, optional) – If True then may re-align input (default=`True`)

  • auto_contiguous (bool, optional) – If True then may re-order input (default=`True`)

  • avoid_copy (bool, optional) – If True then may over-write initial input (default=`False`)

  • norm ({None, 'ortho'}, optional) – Indicate whether fft is normalised (default=`None`)

Returns:

  • plan (function) – Returns the Fourier transform of B, plan() == fftn(B)

  • B (numpy.ndarray, A.shape) – Array which should be modified inplace for fft to be computed. If possible, B is A.

Example

A = numpy.zeros((8,16)) plan, B = plan_fft(A)

B[:,:] = numpy.random.rand(8,16) numpy.fft.fftn(B) == plan()

B = numpy.random.rand(8,16) numpy.fft.fftn(B) != plan()