prtools.idft2#
- idft2(F, alpha, shape=None, shift=(0, 0), offset=(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 andalpha[2]
represents column-wise sampling. Ifalpha
is a scalar,alpha[1] = alpha[2] = alpha
represents uniform sampling across the rows and columns of the input plane.shape (int or array_like, optional) – Size of the output array
F
. Ifnpshapeix
is an array,F.shape = (shape[0], shape[1])
. Ifshape
is a scalar,F.shape = (shape, shape)
. Default isF.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 isTrue
.
- Returns:
f
- Return type:
complex ndarray
Notes
Setting
alpha = 1/F.shape
andshape = F.shape
is equivalent toF = 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 atnp.floor(shape/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 passingorigin = 'lower'
toimshow()
.
References
[1] Soummer, et. al. Fast computation of Lyot-style coronagraph propagation (2007)