motion_correction.image_registration.FITS_tools package

Submodules

motion_correction.image_registration.FITS_tools.fits_overlap module

motion_correction.image_registration.FITS_tools.fits_overlap.fits_overlap(file1, file2, **kwargs)[source]

Create a header containing the exact overlap region between two .fits files

Does NOT check to make sure the FITS files are in the same coordinate system!

Parameters

file1,file2str,str

files from which to extract header strings

motion_correction.image_registration.FITS_tools.fits_overlap.header_overlap(hdr1, hdr2, max_separation=180, overlap='union')[source]

Create a header containing the exact overlap region between two .fits files

Does NOT check to make sure the FITS files are in the same coordinate system!

Parameters

hdr1,hdr2pyfits.Header

Two pyfits headers to compare

max_separationint

Maximum number of degrees between two headers to consider before flipping signs on one of them (this to deal with the longitude=0 region)

overlap: ‘union’ or ‘intersection’

Which merger to do

motion_correction.image_registration.FITS_tools.hcongrid module

motion_correction.image_registration.FITS_tools.load_header module

motion_correction.image_registration.FITS_tools.load_header.get_cd(wcs, n=1)[source]

Get the value of the change in world coordinate per pixel across a linear axis. Defaults to wcs.wcs.cd if present. Does not support rotated headers (e.g., with nonzero CDm_n where m!=n)

motion_correction.image_registration.FITS_tools.load_header.load_data(data)[source]

Attempt to load an image specified as an HDU, a string pointing to a FITS file, an HDUlist, or an actual data array

motion_correction.image_registration.FITS_tools.load_header.load_header(header)[source]

Attempt to load a header specified as a header, a string pointing to a FITS file, or a string pointing to a Header text file, or a string that contains the actual header, or an HDU

motion_correction.image_registration.FITS_tools.match_images module

motion_correction.image_registration.FITS_tools.match_images.match_fits(fitsfile1, fitsfile2, header=None, sigma_cut=False, use_mad_std=True, return_header=False, **kwargs)[source]

Project one FITS file into another’s coordinates If sigma_cut is used, will try to find only regions that are significant in both images using the standard deviation

Parameters

fitsfile1: str

Reference fits file name

fitsfile2: str

Offset fits file name

header: pyfits.Header

Optional - can pass a header to projet both images to

sigma_cut: bool or int

Perform a sigma-cut on the returned images at this level

use_mad_stdbool

Use mad_std instead of std dev for stddev estimation

Returns

image1,image2,[header] : Two images projected into the same space, and optionally the header used to project them

motion_correction.image_registration.FITS_tools.match_images.project_to_header(fitsfile, header, **kwargs)[source]

Reproject an image to a header. Simple wrapper of reproject.reproject_interp

Parameters

fitsfilestring

a FITS file name

headerpyfits.Header

A pyfits Header instance with valid WCS to project to

quietbool

Silence Montage’s output

Returns

np.ndarray image projected to header’s coordinates

motion_correction.image_registration.FITS_tools.match_images.register_fits(fitsfile1, fitsfile2, errfile=None, return_error=True, register_method=<function chi2_shift_iterzoom>, return_cropped_images=False, return_shifted_image=False, return_header=False, sigma_cut=None, **kwargs)[source]

Determine the shift between two FITS images using the cross-correlation technique. Requires montage or hcongrid.

kwargs are passed to register_method()

Parameters

fitsfile1: str

Reference fits file name

fitsfile2: str

Offset fits file name

errfilestr [optional]

An error image, intended to correspond to fitsfile2

register_methodfunction

Can be any of the shift functions in image_registration. Defaults to chi2_shift_iterzoom()

return_errors: bool

Return the errors on each parameter in addition to the fitted offset

return_cropped_images: bool

Returns the images used for the analysis in addition to the measured offsets

return_shifted_images: bool

Return image 2 shifted into image 1’s space

return_headerbool

Return the header the images have been projected to

quiet: bool

Silence messages?

sigma_cut: bool or int

Perform a sigma-cut before cross-correlating the images to minimize noise correlation?

Returns

xoff,yoff(float,float)

pixel offsets

xoff_wcs,yoff_wcs(float,float)

world coordinate offsets

exoff,eyoff(float,float) (only if return_errors is True)

Standard error on the fitted pixel offsets

exoff_wcs,eyoff_wcs(float,float) (only if return_errors is True)

Standard error on the fitted world coordinate offsets

proj_image1, proj_image2(ndarray,ndarray) (only if return_cropped_images is True)

The images projected into the same coordinates

shifted_image2ndarray (if return_shifted_image is True)

The second image projected and shifted to match image 1.

headerpyfits.Header (only if return_header is True)

The header the images have been projected to

Module contents