rebin_image

sofia_redux.instruments.forcast.undistort.rebin_image(image, factor, header=None, variance=None, platescale=None)[source]

Rebin the image to square pixels

Here factor represents dy/dx (pixel height/width). If the pixels were square, then 11*dx == 11*dy, or nx*dy == ny*dy. The smaller the pixels, the larger the number of them across the array for the same angular distance. We can make the pixels square by re-binning such that the above equation holds, but must assume one dimension is the reference with 256 pixels.

We can adopt the principle that the re-binned array should be as close to 256 x 256 as possible. In that case nx’*ny’ == 256*256 and nx’ == ny’ * (dy/dx).

Parameters:
imagenumpy.ndarray

input image with rectangular pixels (nrow, ncol)

factorfloat

the ration dy/dx (pixel height/width)

headerastropy.io.fits.header.Header

FITS header containing WCS. Values will be updated and HISTORY messages will be written.

variancenumpy.ndarray

variance array to update in parallel

platescalefloat

if set, CDELT will be set to this value in header WCS. Should be provided as arc seconds.

Returns:
2-tuple

numpy.ndarray : the rebinned image (nrow, ncol) numpy.ndarray : the rebinned variance (nrow, ncol)