regrid_cube

FITS_tools.cube_regrid.regrid_cube(cubedata, cubeheader, targetheader, preserve_bad_pixels=True, order=1, mode='constant', out_of_bounds=nan, **kwargs)[source] [edit on github]

Attempt to reproject a cube onto another cube’s header. Uses interpolation via map_coordinates

Assumptions:

  • Both the cube and the target are 3-dimensional, with lon/lat/spectral axes
  • Both cube and header use CD/CDELT rather than PC

kwargs will be passed to map_coordinates

Parameters:

cubedata : ndarray

A three-dimensional data cube

cubeheader : Header or WCS

The header or WCS corresponding to the image

targetheader : 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

out_of_bounds : float or np.nan

Pixels in the output image that were out of bounds in the old image will be set to this value if mode=’constant’

mode : str

The mode of treatment of out-of-bounds pixels; can be ‘constant’, ‘wrap’, ‘reflect’, or ‘nearest’. See map_coordinates for details.

Returns:

newcubedata : ndarray

The regridded cube