abtem.core.fft#
Module for handling Fourier transforms and convolution in abTEM.
Module Contents#
Classes#
Functions#
Compute the 2-dimensional discrete Fourier Transform. Using the FFT library specified in the configuration. |
|
Compute the 2-dimensional convolution of an array with a kernel. |
|
Crop an array. It is assumed that the array is centered in Fourier space, this is used for real-space interpolation. |
|
Interpolate an array using Fourier space interpolation. |
|
Create boolean masks for interpolating between two arrays using Fourier space interpolation. |
|
Shift an array in real space using Fourier space interpolation. |
|
Create an array representing one or more phase ramp(s) for shifting another array. |
|
Compute the n-dimensional discrete Fourier Transform. Using the FFT library specified in the configuration. |
|
Get a pyfftw object for a given array and a given FFT function. The object is cached and reused if the array shape is the same. |
|
Compute the 2-dimensional inverse discrete Fourier Transform. Using the FFT library specified in the configuration. |
|
Compute the n-dimensional inverse discrete Fourier Transform. Using the FFT library specified in the configuration. |
|
Whether an FFT of length |
|
The smallest length >= |
|
Emit the slow-FFT diagnostic for a transform run outside |
Data#
API#
- abtem.core.fft.U#
‘TypeVar(…)’
- abtem.core.fft.fft2(...) abtem.core.fft.U[source]#
Compute the 2-dimensional discrete Fourier Transform. Using the FFT library specified in the configuration.
- abtem.core.fft.fft2_convolve(...) abtem.core.fft.U[source]#
Compute the 2-dimensional convolution of an array with a kernel.
- abtem.core.fft.fft_crop(...)[source]#
Crop an array. It is assumed that the array is centered in Fourier space, this is used for real-space interpolation.
- Parameters:
- Returns:
Cropped array.
- Return type:
- abtem.core.fft.fft_interpolate(...)[source]#
Interpolate an array using Fourier space interpolation.
- Parameters:
- Returns:
Interpolated array.
- Return type:
- abtem.core.fft.fft_interpolation_masks(...) tuple[ndarray, ndarray][source]#
Create boolean masks for interpolating between two arrays using Fourier space interpolation.
- abtem.core.fft.fft_shift(...) ndarray[source]#
Shift an array in real space using Fourier space interpolation.
- abtem.core.fft.fft_shift_kernel(...) ndarray[source]#
Create an array representing one or more phase ramp(s) for shifting another array.
- abtem.core.fft.fftn(...) abtem.core.fft.U[source]#
Compute the n-dimensional discrete Fourier Transform. Using the FFT library specified in the configuration.
- abtem.core.fft.get_fftw_object(...)[source]#
Get a pyfftw object for a given array and a given FFT function. The object is cached and reused if the array shape is the same.
- abtem.core.fft.ifft2(...) abtem.core.fft.U[source]#
Compute the 2-dimensional inverse discrete Fourier Transform. Using the FFT library specified in the configuration.
- abtem.core.fft.ifftn(...) abtem.core.fft.U[source]#
Compute the n-dimensional inverse discrete Fourier Transform. Using the FFT library specified in the configuration.
- abtem.core.fft.is_fast_fft_size(...) bool[source]#
Whether an FFT of length
nruns on fast radix kernels.FFT libraries only ship optimized kernels for lengths whose prime factors are small (2, 3, 5 and 7 are supported everywhere). A length with a larger prime factor triggers a generic fallback – on cuFFT the Bluestein algorithm, which pads internally to a power of two, costing several times the arithmetic and, on GPU, a workspace of several times the transform size.
- abtem.core.fft.next_fast_fft_size(...) int[source]#
The smallest length >=
nwhose prime factors are all in {2, 3, 5, 7}.Useful for choosing grid sizes (
gpts) that avoid the slow large-workspace Bluestein fallback on GPU. Stricter thanscipy.fft.next_fast_len, which returns 11-smooth lengths (fast for pocketfft on CPU, but off cuFFT’s documented fast path).
- abtem.core.fft.warn_if_slow_gpu_fft(...)[source]#
Emit the slow-FFT diagnostic for a transform run outside
_fft_dispatch.A few transforms call
xp.fftdirectly rather than through the wrappers in this module –structure_factor_to_potentialdoes, because the FFTW backend here only ever transforms the trailing two axes and would silently turn its 3D transform into a 2D one. They still deserve the diagnostic, so they can call this alongside. Only GPU arrays are considered: the Bluestein workspace this warns about is a cuFFT concern.