UPDATEHDR: Functions for Updating WCS with New Solutions
The functions in this module support updating the WCS information in
distorted images with the alignment solution determined by TweakReg
or saved in a shiftfile.
- Authors:
Warren Hack, Mihai Cara
- License:
- drizzlepac.updatehdr.create_unique_wcsname(fimg, extnum, wcsname)[source]
This function evaluates whether the specified wcsname value has already been used in this image. If so, it automatically modifies the name with a simple version ID using wcsname_NNN format.
- Parameters:
- fimgobj
PyFITS object of image with WCS information to be updated
- extnumint
Index of extension with WCS information to be updated
- wcsnamestr
Value of WCSNAME specified by user for labelling the new WCS
- Returns:
- uniqnamestr
Unique WCSNAME value
- drizzlepac.updatehdr.interpret_wcsname_type(wcsname)[source]
Interpret WCSNAME as a standardized human-understandable description
- drizzlepac.updatehdr.linearize(wcsim, wcsima, wcsref, imcrpix, f, shift, hx=1.0, hy=1.0)[source]
linearization using 5-point formula for first order derivative
- drizzlepac.updatehdr.update_from_shiftfile(shiftfile, wcsname=None, force=False)[source]
Update headers of all images specified in shiftfile with shifts from shiftfile.
- Parameters:
- shiftfilestr
Filename of shiftfile.
- wcsnamestr
Label to give to new WCS solution being created by this fit. If a value of None is given, it will automatically use ‘TWEAK’ as the label. [Default =None]
- forcebool
Update header even though WCS already exists with this solution or wcsname? [Default=False]
- drizzlepac.updatehdr.update_refchip_with_shift(chip_wcs, wcslin, fitgeom='rscale', rot=0.0, scale=1.0, xsh=0.0, ysh=0.0, fit=None, xrms=None, yrms=None)[source]
Compute the matrix for the scale and rotation correction
- Parameters:
- chip_wcs: wcs object
HST of the input image
- wcslin: wcs object
Reference WCS from which the offsets/rotations are determined
- fitgeom: str
NOT USED
- rotfloat
Amount of rotation measured in fit to be applied. [Default=0.0]
- scalefloat
Amount of scale change measured in fit to be applied. [Default=1.0]
- xshfloat
Offset in X pixels from defined tangent plane to be applied to image. [Default=0.0]
- yshfloat
Offset in Y pixels from defined tangent plane to be applied to image. [Default=0.0]
- fitarr
Linear coefficients for fit [Default = None]
- xrmsfloat
RMS of fit in RA (in decimal degrees) that will be recorded as CRDER1 in WCS and header [Default = None]
- yrmsfloat
RMS of fit in Dec (in decimal degrees) that will be recorded as CRDER2 in WCS and header [Default = None]
- drizzlepac.updatehdr.update_wcs(image, extnum, new_wcs, wcsname='', reusename=False, verbose=False)[source]
Updates the WCS of the specified extension number with the new WCS after archiving the original WCS.
The value of ‘new_wcs’ needs to be the full HSTWCS object.
- Parameters:
- imagestr
Filename of image with WCS that needs to be updated
- extnumint
Extension number for extension with WCS to be updated/replaced
- new_wcsobject
Full HSTWCS object which will replace/update the existing WCS
- wcsnamestr
Label to give newly updated WCS
- reusenamebool
User can choose whether to over-write WCS with same name or not. [Default: False]
- verbosebool, int
Print extra messages during processing? [Default: False]
- drizzlepac.updatehdr.updatewcs_with_shift(image, reference, wcsname='TWEAK', reusename=False, fitgeom='rscale', rot=0.0, scale=1.0, xsh=0.0, ysh=0.0, fit=None, xrms=None, yrms=None, verbose=False, force=False, sciext='SCI')[source]
Update the SCI headers in ‘image’ based on the fit provided as determined in the WCS specified by ‘reference’. The fit should be a 2-D matrix as generated for use with ‘make_vector_plot()’.
- Parameters:
- imagestr or PyFITS.HDUList object
Filename, or PyFITS object, of image with WCS to be updated. All extensions with EXTNAME matches the value of the ‘sciext’ parameter value (by default, all ‘SCI’ extensions) will be updated.
- referencestr
Filename of image/headerlet (FITS file) which contains the WCS used to define the tangent plane in which all the fit parameters (shift, rot, scale) were measured.
- wcsnamestr, None, optional
Label to give to new WCS solution being created by this fit. If a value of None is given, it will automatically use ‘TWEAK’ as the label. [Default =None]
- reusenamebool
User can specify whether or not to over-write WCS with same name. [Default: False]
- rotfloat
Amount of rotation measured in fit to be applied. [Default=0.0]
- scalefloat
Amount of scale change measured in fit to be applied. [Default=1.0]
- xshfloat
Offset in X pixels from defined tangent plane to be applied to image. [Default=0.0]
- yshfloat
Offset in Y pixels from defined tangent plane to be applied to image. [Default=0.0]
- fitarr
Linear coefficients for fit [Default = None]
- xrmsfloat
RMS of fit in RA (in decimal degrees) that will be recorded as CRDER1 in WCS and header [Default = None]
- yrmsfloat
RMS of fit in Dec (in decimal degrees) that will be recorded as CRDER2 in WCS and header [Default = None]
- verbosebool
Print extra messages during processing? [Default=False]
- forcebool
Update header even though WCS already exists with this solution or wcsname? [Default=False]
- sciextstring
Value of FITS EXTNAME keyword for extensions with WCS headers to be updated with the fit values. [Default=’SCI’]
Notes
The algorithm used to apply the provided fit solution to the image involves applying the following steps to the WCS of each of the input image’s chips:
- compute RA/Dec with full distortion correction for
reference point as (Rc_i,Dc_i)
- find the Xc,Yc for each Rc_i,Dc_i and get the difference from the
CRPIX position for the reference WCS as (dXc_i,dYc_i)
- apply fit (rot&scale) to (dXc_i,dYc_i) then apply shift, then add
CRPIX back to get new (Xcs_i,Ycs_i) position
compute (Rcs_i,Dcs_i) as the sky coordinates for (Xcs_i,Ycs_i)
compute delta of (Rcs_i-Rc_i, Dcs_i-Dcs_i) as (dRcs_i,dDcs_i)
- apply the fit to the chip’s undistorted CD matrix, the apply linear
distortion terms back in to create a new CD matrix
add (dRcs_i,dDcs_i) to CRVAL of the reference chip’s WCS
update header with new WCS values