matrix_dft

jwst.ami.matrix_dft.matrix_dft(plane, nlam_d, npix, offset=None, inverse=False, centering='FFTSTYLE')[source]

Perform a matrix discrete Fourier transform with selectable output sampling and centering.

Where parameters can be supplied as either scalars or 2-tuples, the first element of the 2-tuple is used for the Y dimension and the second for the X dimension. This ordering matches that of numpy.ndarray.shape attributes and that of Python indexing. To achieve exact correspondence to the FFT set nlam_d and npix to the size of the input array in pixels and use ‘FFTSTYLE’ centering. (n.b. When using numpy.fft.fft2 you must numpy.fft.fftshift the input pupil both before and after applying fft2 or else it will introduce a checkerboard pattern in the signs of alternating pixels!)

Parameters:
plane2D ndarray

2D array (either real or complex) representing the input image plane or pupil plane to transform.

nlam_dfloat or 2-tuple of floats (nlam_dy, nlam_dx)

Size of desired output region in lambda / D units, assuming that the pupil fills the input array (corresponds to ‘m’ in Soummer et al. 2007 4.2). This is in units of the spatial frequency that is just Nyquist sampled by the input array.) If given as a tuple, interpreted as (nlam_dy, nlam_dx).

npixint or 2-tuple of ints (npix_y, npix_x)

Number of pixels per side side of destination plane array (corresponds to ‘N_B’ in Soummer et al. 2007 4.2). This will be the # of pixels in the image plane for a forward transformation, in the pupil plane for an inverse. If given as a tuple, interpreted as (npix_y, npix_x).

offset2-tuple of floats (offset_y, offset_x)

For ADJUSTABLE-style transforms, an offset in pixels by which the PSF will be displaced from the central pixel (or cross). Given as (offset_y, offset_x).

inversebool, optional

Is this a forward or inverse transformation? (Default is False, implying a forward transformation.)

centering{‘FFTSTYLE’, ‘SYMMETRIC’, ‘ADJUSTABLE’}, optional

What type of centering convention should be used for this FFT?

  • ADJUSTABLE (the default) For an output array with ODD size n, the PSF center will be at the center of pixel (n-1)/2. For an output array with EVEN size n, the PSF center will be in the corner between pixel (n/2-1, n/2-1) and (n/2, n/2)

  • FFTSTYLE puts the zero-order term in a single pixel.

  • SYMMETRIC spreads the zero-order term evenly between the center four pixels

Returns:
float, ndarray

Normalized FT coeffs, i.e., norm_coeff * t2.