transfer_wcs_correction
- jwst.tweakreg.utils.transfer_wcs_correction(to_image, from_image, matrix=None, shift=None)[source]
Applies the same total WCS correction that was applied by
tweakreg
(!) to the WCS in thefrom_image
data model to the WCS of theto_image
data model. In some ways this function is analogous function to thetweakback
function for HST available in the drizzlepac package.One fundamental difference between this function and
tweakback
is that JWST data models do not keep a history of data’s WCS via alternative WCS as it is done in HST data and so it is impossible to select and apply only one particular WCS correction if there were multiple corrections previously applied to a WCS. The tangent-plane correction in JWST WCS is cumulative/total correction. If you would like to apply a specific/custom correction, you can do that viamatrix
andshift
arguments which is defined in the reference tangent plane provided by thefrom_image
’s WCS.When providing your own corrections via
matrix
andshift
arguments, this function is similar to theadjust_wcs()
function but provides an alternative way of specifying corrections via affine transformations in a reference tangent plane.Warning
Upon return, if the
to_image
argument is anImageModel
it will be modified with an updatedImageModel.meta.wcs
WCS model. Ifto_image
argument is a file name of anImageModel
, that model will be read in, its WCS will be updated, and the updated model will be written out to the same file. BACKUP the file into_image
argument before calling this function.Warning
This function does not support input data models whose WCS were modified by
adjust_wcs()
. Only WCS corrections computed by either thetweakreg
step or bytweakwcs
package are supported.- Parameters:
to_image (str, ImageModel) –
Image model to which the correction should be applied/transferred to.
Warning
If it is a string file name then, upon return, this file will be overwritten with a data model with an updated WCS.
from_image (str, ImageModel, gwcs.wcs.WCS) –
A data model whose WCS was previously corrected. This data model plays two roles: 1) it is the reference WCS which provides a tangent plane in which corrections have been defined, and 2) it provides WCS corrections to be applied to
to_image
’s WCS.If the WCS of the
from_image
data model does not contain corrections, then bothmatrix
andshift
arguments must be supplied.matrix (2D list, 2D numpy.ndarray, None, optional) –
A 2D matrix part of an affine transformation defined in the tangent plane derived from the
from_image
’s WCS.Note
When provided,
shift
argument must also be provided in which casematrix
andshift
arguments override the correction (if present) from thefrom_file
’s WCS.shift (list, numpy.ndarray, None, optional) –
A list of length 2 representing the translational part of an affine transformation (in arcsec) defined in the tangent plane derived from the
from_image
’s WCS.Note
When provided,
matrix
argument must also be provided in which casematrix
andshift
arguments override the correction (if present) from thefrom_file
’s WCS.
- Returns:
Upon return, if the
to_image
argument is anImageModel
it will bemodified with an updated
ImageModel.meta.wcs
WCS model.If
to_image
argument is a file name of anImageModel
, thatmodel will be read in, its WCS will be updated, and the updated model
will be written to the same file. BACKUP the file in
to_image
argument before calling this function.