lentil.fourier.idft2

lentil.fourier.idft2(F, alpha, npix=None, shift=(0, 0), unitary=True, out=None)[source]

Compute the 2-dimensional inverse discrete Fourier Transform.

The IDFT is defined in one dimension as

\[a_m = \frac{1}{n}\sum_{k=0}^{n-1} A_k \exp \left(2\pi i\frac{mk}{n}\right) \hspace{3em} m=0, \dots, n-1\]

This function allows independent control over input shape, output shape, and output sampling by implementing the matrix triple product algorithm described in [1].

Parameters
  • F (array_like) – 2D array to Fourier Transform

  • alpha (float or array_like) – Input plane sampling interval (frequency). If alpha is an array, alpha[1] represents row-wise sampling and alpha[2] represents column-wise sampling. If alpha is a scalar, alpha[1] = alpha[2] = alpha represents uniform sampling across the rows and columns of the input plane.

  • npix (int or array_like, optional) – Size of the output array F. If npix is an array, F.shape = (npix[1], npix[2]). If npix is a scalar, F.shape = (npix, npix). Default is F.shape

  • shift (array_like, optional) – Number of pixels in (x,y) to shift the DC pixel in the output plane with the origin centrally located in the plane. Default is [0,0].

  • unitary (bool, optional) – Normalization flag. If True, a normalization is performed on the output such that the DFT operation is unitary and energy is conserved through the Fourier transform operation (Parseval’s theorem). In this way, the energy in in a limited-area DFT is a fraction of the total energy corresponding to the limited area. Default is True.

Returns

f

Return type

complex ndarray

Notes

  • Setting alpha = 1/F.shape and npix = F.shape is equivalent to

    F = np.fft.ifftshift(np.fft.ifft2(np.fft.fftshift(F)))
    
  • idft2() is designed to place the DC pixel in the same location as a well formed call to any standard FFT for both even and odd sized input arrays. The DC pixel is located at np.floor(npix/2) + 1, which is consistent with calls to Numpy’s IFFT method where the input and output are correctly shifted: np.fft.ifftshift(np.fft.ifft2(np.fft.fftshift(f))).

  • If the y-axis shift behavior is not what you are expecting, you most likely have your plotting axes flipped (matplotlib’s default behavior is to place [0,0] in the upper left corner of the axes). This may be resolved by either flipping the sign of the y component of shift or by passing origin = 'lower' to imshow().

References

[1] Soummer, et. al. Fast computation of Lyot-style coronagraph propagation (2007)

[2] Expressing the inverse DFT in terms of the DFT.