Tools

Image Regridding

FITS_tools.hcongrid.hcongrid is meant to replicate hcongrid and hastrom. It uses scipy’s interpolation routines.

FITS_tools.hcongrid.wcsalign does the same thing as hcongrid but uses pyast as its backend.

Cube Regridding

FITS_tools.cube_regrid.regrid_fits_cube reprojects a cube to a new grid using scipy’s interpolation routines.

FITS_tools.match_images.match_fits_cubes takes two cubes, and reprojects the first to the coordinates of the second (it’s a wrapper)

For a flux-conserving (but slower) approach, there is a wrapper of montage in python-montage.

Reference/API

FITS_tools Package

This is an Astropy affiliated package.

Functions

fits_overlap(file1, file2, **kwargs) Create a header containing the exact overlap region between two .fits files
header_overlap(hdr1, hdr2[, max_separation, ...]) Create a header containing the exact overlap region between two .fits files
match_fits(fitsfile1, fitsfile2[, header, ...]) Project one FITS file into another’s coordinates.
project_to_header(fitsfile, header[, ...]) Light wrapper of montage with hcongrid as a backup
regrid_cube(cubedata, cubeheader, targetheader) Attempt to reproject a cube onto another cube’s header.
regrid_cube_hdu(hdu, outheader[, smooth]) Regrid a FITS HDU to a target header.
regrid_fits_cube(cubefilename, outheader[, ...]) Regrid a FITS file to a target header.
test([package, test_path, args, plugins, ...]) Run the tests using py.test.

FITS_tools.cube_regrid Module

Functions

downsample_cube(cubehdu, factor[, spectralaxis]) Downsample a cube along the spectral axis
get_cube_mapping(header1, header2) Determine the pixel mapping from Header 1 to Header 2
gsmooth_cube(cube, kernelsize[, use_fft, ...]) Smooth a cube with a gaussian in 3d
regrid_cube(cubedata, cubeheader, targetheader) Attempt to reproject a cube onto another cube’s header.
regrid_cube_hdu(hdu, outheader[, smooth]) Regrid a FITS HDU to a target header.
regrid_fits_cube(cubefilename, outheader[, ...]) Regrid a FITS file to a target header.
smoothing_kernel_size(hdr_from, hdr_to) Determine the smoothing kernel size needed to convolve a cube before downsampling it to retain signal.
spatial_smooth_cube(cube, kernelwidth[, ...]) Parallelized spatial smoothing
spectral_smooth_cube(cube, kernelwidth[, ...]) Parallelized spectral smoothing
find_grid_limits(grid) Determine the min/max of each dimension along a grid returned by get_cube_mapping.

FITS_tools.downsample Module

Functions

downsample_axis(myarr, factor, axis[, ...]) Downsample an ND array by averaging over factor pixels along an axis.
downsample_header(header, factor, axis) Downsample a FITS header along an axis using the FITS convention for axis number

FITS_tools.spectral_regrid Module

Functions

get_spectral_mapping(header1, header2[, ...]) Determine the mapping from header1 pixel units to header2 pixel units along
spec_pix_to_world(pixel, wcs, axisnumber[, unit]) Given a WCS, an axis ID, and a pixel ID, return the WCS spectral value at a
spec_world_to_pix(worldunit, wcs, ...) Given a WCS, an axis ID, and WCS location, return the pixel index value at a

FITS_tools.hcongrid Module

Functions

get_pixel_mapping(header1, header2) Determine the mapping from pixel coordinates in header1 to pixel
hastrom(image, header1, header2[, ...]) Interpolate an image from one FITS header onto another
hastrom_hdu(hdu_in, header, **kwargs) Wrapper of hcongrid to work on HDUs
hcongrid(image, header1, header2[, ...]) Interpolate an image from one FITS header onto another
hcongrid_hdu(hdu_in, header, **kwargs) Wrapper of hcongrid to work on HDUs
wcsalign(hdu_in, header[, outname, clobber]) Align one FITS image to a specified header
zoom_fits(fitsfile, scalefactor[, ...]) Zoom in on a FITS image by interpolating using zoom

FITS_tools.match_images Module

Functions

match_fits(fitsfile1, fitsfile2[, header, ...]) Project one FITS file into another’s coordinates.
match_fits_cubes(fitsfile1, fitsfile2[, ...]) Project one FITS file representing a data cube into another’s coordinates.
project_to_header(fitsfile, header[, ...]) Light wrapper of montage with hcongrid as a backup

FITS_tools.strip_headers Module

Functions

flatten_header(header[, delete]) Attempt to turn an N-dimensional fits header into a 2-dimensional header Turns all CRPIX[>2] etc.
speccen_header(header[, lon, lat]) Turn a cube header into a spectrum header, retaining RA/Dec vals where possible

FITS_tools.load_header Module

Functions

get_cd(wcs[, n]) Get the value of the change in world coordinate per pixel across a linear axis.
load_data(data[, extnum]) Attempt to load a header specified as a header, a string pointing to a FITS
load_header(header[, extnum]) Attempt to load a header specified as a header, a string pointing to a FITS

FITS_tools.header_tools Module

Functions

enclosing_header(header1, header2[, wrapangle]) Find the smallest header that encloses both header1 and header2 in the
header_to_platescale(header, **kwargs) Attempt to determine the spatial platescale from a
smoothing_kernel_size(hdr_from, hdr_to) Determine the smoothing kernel size needed to convolve header_from to header_to without losing signal.
wcs_to_platescale(mywcs[, assert_square, ...]) Attempt to determine the spatial plate scale from a WCS