FITS_tools.hcongrid.hastrom(image, header1, header2, preserve_bad_pixels=True, **kwargs) [edit on github]

Interpolate an image from one FITS header onto another

kwargs will be passed to map_coordinates


image : ndarray

A two-dimensional image

header1 : Header or WCS

The header or WCS corresponding to the image

header2 : Header or WCS

The header or WCS to interpolate onto

preserve_bad_pixels : bool

Try to set NAN pixels to NAN in the zoomed image. Otherwise, bad pixels will be set to zero


newimage : ndarray

ndarray with shape defined by header2’s naxis1/naxis2


TypeError if either is not a Header or WCS instance

Exception if image1’s shape doesn’t match header1’s naxis1/naxis2


>>> fits1 = pyfits.open('test.fits')
>>> target_header = pyfits.getheader('test2.fits')
>>> new_image = hcongrid(fits1[0].data, fits1[0].header, target_header)