resize_psf#
- photutils.psf_matching.resize_psf(psf, input_pixel_scale, output_pixel_scale, *, order=3)[source]#
Resize a PSF using spline interpolation of the requested order.
The PSF is interpolated at the points of a grid with the output pixel scale that is centered on the central pixel of the input PSF. The total flux of the PSF is conserved during the resizing.
- Parameters:
- psf2D array_like
The 2D data array of the PSF. The PSF must have odd dimensions. It is assumed to be centered on the central pixel.
- input_pixel_scalefloat or
Quantity The pixel scale of the input
psf. If a float, the units must matchoutput_pixel_scale. If aQuantity, the units must be convertible to those ofoutput_pixel_scale.- output_pixel_scalefloat or
Quantity The pixel scale of the output
psf. If a float, the units must matchinput_pixel_scale. If aQuantity, the units must be convertible to those ofinput_pixel_scale.- orderint, optional
The order of the spline interpolation (0-5). The default is 3.
- Returns:
- result2D
ndarray The resampled/interpolated 2D data array, with a pixel scale of
output_pixel_scale. The output always has odd dimensions, which guarantees that it is centered and usable for PSF matching. The size along each axis is2 * floor((input_size - 1) / 2 * (input_pixel_scale / output_pixel_scale)) + 1. This is the largest odd size for which the output grid lies within the outermost pixel centers of the input PSF, so no output value is extrapolated.
- result2D
- Raises:
- ValueError
If
psfis not a 2D array, has even dimensions, contains NaN or Inf values, or has a zero sum, if the pixel scales are not positive, iforderis not an integer from 0 to 5, or if the resized PSF has a zero sum.- TypeError
If the pixel scales have units that are not convertible to each other, or if only one of them is a
Quantity.
Notes
This function changes only the pixel scale. The resized PSF generally does not have the same shape as the PSF it will be matched to, so the two PSFs may still need to be cropped or padded to a common shape before computing a matching kernel.
The PSF is interpolated and is not integrated over the output pixels. If the two PSFs come from images with different detector pixel sizes, each PSF should already include the pixel integration of its own image. An oversampled PSF that is sampled at points, such as the output of an optical model, should first be integrated over the detector pixels with
make_epsf_from_psf().The input PSF should be well sampled at both the input and output pixel scales. Resizing a PSF to a larger pixel scale samples it without any smoothing. If the PSF is undersampled at the output pixel scale, the result is aliased and a matching kernel computed from it will be inaccurate. A spline is also a poor interpolant for a PSF that is undersampled at the input pixel scale.