WCS Correctors

This module provides support for manipulating tangent-plane corrections of WCS.

Authors:

Mihai Cara

License:

LICENSE

class tweakwcs.correctors.FITSWCSCorrector(wcs, meta=None)[source]

A class for holding FITS WCS information and for managing tangent-plane corrections. The units of the tangent plane of this corrector are same as detector coordinates.

Note

Currently only WCS objects that have CPDIS, DET2IM, and SIP distortions before the application of the CD or PC matrix are supported.

Parameters:
wcs: astropy.wcs.WCS

An astropy.wcs.WCS object.

property bounding_box

Get the bounding box (if any) of the underlying image for which the original WCS is defined.

det_to_tanp(x, y)[source]

Convert detector (pixel) coordinates to tangent plane coordinates.

det_to_world(x, y)[source]

Convert pixel coordinates to sky coordinates using full (i.e., including distortions) transformations.

set_correction(matrix=[[1, 0], [0, 1]], shift=[0, 0], ref_tpwcs=None, meta=None, **kwargs)[source]

Computes a corrected (aligned) wcs based on the provided linear transformation. In addition, this function updates the meta attribute of the FITSWCSCorrector object with the the values of keyword arguments except for the argument meta which is merged with the attribute meta.

Parameters:
matrix: list, numpy.ndarray

A 2x2 array or list of lists coefficients representing scale, rotation, and/or skew transformations.

shift: list, numpy.ndarray

A list of two coordinate shifts to be applied to coordinates after matrix transformations are applied.

ref_tpwcs: WCSCorrector, None, optional

A reference WCS of the type WCSCorrector that provides the tangent plane in which corrections (matrix and shift) were defined. When not provided (i.e., set to None), it is assumed that the transformations are being applied directly to this image WCS’ tangent plane.

meta: dict, None, optional

Dictionary that will be merged to the object’s meta fields.

**kwargs: optional parameters

Optional parameters for the WCS corrector. FITSWCSCorrector ignores these arguments (except for storing them in the meta attribute).

tanp_to_det(x, y)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

tanp_to_world(x, y)[source]

Convert tangent plane coordinates to world coordinates.

units = 'pixel'
world_to_det(ra, dec)[source]

Convert sky coordinates to image’s pixel coordinates using full (i.e., including distortions) transformations.

world_to_tanp(ra, dec)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

class tweakwcs.correctors.JWSTWCSCorrector(wcs, wcsinfo, meta=None)[source]

A class for holding JWST gWCS information and for managing tangent-plane corrections. The units of the tangent plane of this corrector are arcsec and the axes are not along parallel to the axes of the detector’s coordinate system.

Parameters:
wcs: GWCS

A GWCS object.

wcsinfo: dict

A dictionary containing reference angles of JWST instrument provided in the wcsinfo property of JWST meta data.

This dictionary must contain the following keys and values:

‘v2_ref’: float

V2 position of the reference point in arc seconds.

‘v3_ref’: float

V3 position of the reference point in arc seconds.

‘roll_ref’: float

Roll angle in degrees.

meta: dict, None, optional

Dictionary that will be merged to the object’s meta fields.

property bounding_box

Get the bounding box (if any) of the underlying image for which the original WCS is defined.

det_to_tanp(x, y)[source]

Convert detector (pixel) coordinates to tangent plane coordinates.

det_to_world(x, y)[source]

Convert pixel coordinates to sky coordinates using full (i.e., including distortions) transformations.

property ref_angles

Return a wcsinfo-like dictionary of main WCS parameters.

set_correction(matrix=[[1, 0], [0, 1]], shift=[0, 0], ref_tpwcs=None, meta=None, **kwargs)[source]

Sets a tangent-plane correction of the GWCS object according to the provided liniar parameters. In addition, this function updates the meta attribute of the JWSTWCSCorrector object with the values of keyword arguments except for the argument meta which is merged with the attribute meta.

Parameters:
matrix: list, numpy.ndarray

A 2x2 array or list of lists coefficients representing scale, rotation, and/or skew transformations.

shift: list, numpy.ndarray

A list of two coordinate shifts to be applied to coordinates after matrix transformations are applied.

ref_tpwcs: WCSCorrector, None, optional

A reference WCS of the type WCSCorrector that provides the tangent plane in which corrections (matrix and shift) were defined. When not provided (i.e., set to None), it is assumed that the transformations are being applied directly to this image WCS’ tangent plane.

meta: dict, None, optional

Dictionary that will be merged to the object’s meta fields.

**kwargs: optional parameters

Optional parameters for the WCS corrector. JWSTWCSCorrector ignores these arguments (except for storing them in the meta attribute).

tanp_to_det(x, y)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

tanp_to_world(x, y)[source]

Convert tangent plane coordinates to world coordinates.

units = 'arcsec'
world_to_det(ra, dec)[source]

Convert sky coordinates to image’s pixel coordinates using full (i.e., including distortions) transformations.

world_to_tanp(ra, dec)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

class tweakwcs.correctors.WCSCorrector(wcs, meta=None)[source]

A class that provides common interface for manipulating WCS information and for managing tangent-plane corrections.

Parameters:
wcs: ``WCS object``

A WCS object supported by a child class.

meta: dict, None, optional

Dictionary that will be merged to the object’s meta fields.

property bounding_box

Get the bounding box (if any) of the underlying image for which the original WCS is defined.

copy()[source]

Returns a deep copy of this object.

abstract det_to_tanp(x, y)[source]

Convert detector (pixel) coordinates to tangent plane coordinates.

abstract det_to_world(x, y)[source]

Convert pixel coordinates to sky coordinates using full (i.e., including distortions) transformations.

property meta
property original_wcs

Get original WCS object.

abstract set_correction(matrix=[[1, 0], [0, 1]], shift=[0, 0], ref_tpwcs=None, meta=None, **kwargs)[source]

Sets a tangent-plane correction of the WCS object according to the provided liniar parameters. In addition, this function updates the meta attribute of the WCSCorrector-derived object with the values of keyword arguments except for the argument meta which is merged with the attribute meta.

Parameters:
matrix: list, numpy.ndarray, optional

A 2x2 array or list of lists coefficients representing scale, rotation, and/or skew transformations.

shift: list, numpy.ndarray, optional

A list of two coordinate shifts to be applied to coordinates after matrix transformations are applied.

ref_tpwcs: WCSCorrector, None, optional

A reference WCS of the type WCSCorrector that provides the tangent plane in which corrections (matrix and shift) were defined. When not provided (i.e., set to None), it is assumed that the transformations are being applied directly to this image WCS’ tangent plane.

meta: dict, None, optional

Dictionary that will be merged to the object’s meta fields.

**kwargs: optional parameters

Optional parameters for the WCS corrector.

property tanp_center_pixel_scale

Estimate pixel scale in the tangent plane near a location in the detector’s coordinate system corresponding to the origin of the tangent plane.

Returns:
pscale: float

Pixel scale [in units used in the tangent plane coordinate system] in the tangent plane near a location in the detector’s plane corresponding to the origin of the tangent plane.

tanp_pixel_scale(x, y)[source]

Estimate pixel scale in the tangent plane near a location in the detector’s coordinate system given by parameters x and y.

Parameters:
x: int, float

X-coordinate of the pixel in the detector’s coordinate system near which pixel scale in the tangent plane needs to be estimated.

y: int, float

Y-coordinate of the pixel in the detector’s coordinate system near which pixel scale in the tangent plane needs to be estimated.

Returns:
pscale: float

Pixel scale [in units used in the tangent plane coordinate system] in the tangent plane near a location specified by detector coordinates x and y.

abstract tanp_to_det(x, y)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

abstract tanp_to_world(x, y)[source]

Convert tangent plane coordinates to world coordinates.

units = None
property wcs

Get current WCS object.

abstract world_to_det(ra, dec)[source]

Convert sky coordinates to image’s pixel coordinates using full (i.e., including distortions) transformations.

abstract world_to_tanp(ra, dec)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.