hcongrid

image_tools.pyhcongrid.hcongrid(image, header1, header2, **kwargs)[source] [edit on github]

This now exists in FITS_tools: https://github.com/keflavich/FITS_tools/blob/master/FITS_tools/hcongrid.py and is better maintained there

Interpolate an image from one FITS header onto another

kwargs will be passed to scipy.ndimage.map_coordinates

Parameters:

image : ndarray

A two-dimensional image

header1 : pyfits.Header or pywcs.WCS

The header or WCS corresponding to the image

header2 : pyfits.Header or pywcs.WCS

The header or WCS to interpolate onto

Returns:

ndarray with shape defined by header2’s naxis1/naxis2

Raises:

TypeError if either is not a Header or WCS instance

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

Examples

(not written with >>> because test.fits/test2.fits do not exist) fits1 = pyfits.open(‘test.fits’) target_header = pyfits.getheader(‘test2.fits’) new_image = hcongrid(fits1[0].data, fits1[0].header, target_header)