FFT functions

C/C++

sdp_Fft *sdp_fft_create(const sdp_Mem *input, const sdp_Mem *output, int32_t num_dims_fft, int32_t is_forward, sdp_Error *status)

Creates a plan for FFTs using the supplied input and output buffers.

The number of dimensions used for the FFT is specified using the num_dims_fft parameter. If this is less than the number of dimensions in the arrays, then the FFT batch size is assumed to be the size of the first (slowest varying) dimension.

This wraps cuFFT in addition to CPU FFT code. Advanced data layouts although supported for GPU are not supported for CPU version and thus are discouraged.

Parameters:
  • input – Input data.

  • output – Output data.

  • num_dims_fft – The number of dimensions for the FFT.

  • is_forward – Set true if FFT should be “forward”, false for “inverse”.

  • status – Error status.

Returns:

sdp_Fft* Handle to FFT plan.

void sdp_fft_exec(sdp_Fft *fft, sdp_Mem *input, sdp_Mem *output, sdp_Error *status)

Executes FFT using plan and supplied data.

Parameters:
  • fft – Handle to FFT plan.

  • input – Input data.

  • output – Output data.

  • status – Error status.

void sdp_fft_exec_shift(sdp_Fft *fft, sdp_Mem *data, int norm, sdp_Error *status)

Wrapper to apply FFT shift, execute FFT, shift again and normalise.

This is a convenience function to apply the four operations, since they frequently need to be done together.

Parameters:
  • fft – Handle to FFT plan.

  • data – Input and output data.

  • norm – If true, the output will be normalised.

  • status – Error status.

void sdp_fft_free(sdp_Fft *fft)

Destroys the FFT plan.

Parameters:

fft – Handle to FFT plan.

void sdp_fft_norm(sdp_Mem *data, sdp_Error *status)

Normalises the supplied array by dividing by the number of elements.

This is to provide compatibility with numpy’s ifft.

Parameters:
  • data – Array to normalise.

  • status – Error status.

void sdp_fft_phase(sdp_Mem *data, sdp_Error *status)

Provide fftshift() behaviour for complex data.

The data are multiplied by a checker-board pattern to achieve the same result as fftshift(), without actually moving memory around. CPU or GPU memory locations are supported.

Parameters:
  • data – Array to shift. Can be 1D or 2D, but must be of complex type.

  • status – Error status.

int sdp_fft_padded_size(int n, double padding_factor)

Returns the next largest even that is a power of 2, 3, 5, 7 or 11.

Parameters:
  • n – Minimum input grid size.

  • padding_factor – Padding factor to multiply input grid size.

Returns:

Optimal grid size.

Python

class ska_sdp_func.fourier_transforms.Fft(input_data, output_data, num_dims_fft, is_forward)

Interface to SDP FFT.

__init__(input_data, output_data, num_dims_fft, is_forward)

Creates a plan for FFTs using the supplied input and output buffers.

The number of dimensions used for the FFT is specified using the num_dims_fft parameter. If this is less than the number of dimensions in the arrays, then the FFT batch size is assumed to be the size of the first (slowest varying) dimension.

Parameters:
  • input_data (numpy.ndarray or cupy.ndarray) – Input data.

  • output_data (numpy.ndarray or cupy.ndarray) – Output data.

  • num_dims_fft (int) – The number of dimensions for the FFT.

  • is_forward (bool) – Set true if FFT should be “forward”, false for “inverse”.

exec(input_data, output_data)

Executes FFT using plan and supplied data.

Parameters:
  • input_data (cupy.ndarray) – Input data.

  • output_data (cupy.ndarray) – Output data.

ska_sdp_func.fourier_transforms.padded_fft_size(num: int, padding_factor: float)

Returns the next largest even that is a power of 2, 3, 5, 7 or 11.

Parameters:
  • num – Minimum input grid size.

  • padding_factor – Padding factor to multiply input grid size.