tpwcs

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

Authors:Mihai Cara
License:LICENSE
class tweakwcs.tpwcs.TPWCS(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.

bounding_box

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

copy(self)[source]

Returns a deep copy of this object.

det_to_tanp(self, x, y)[source]

Convert detector (pixel) coordinates to tangent plane coordinates.

det_to_world(self, x, y)[source]

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

meta
original_wcs

Get original WCS object.

set_correction(self, 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 TPWCS-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: TPWCS, None, optional

A reference WCS of the type TPWCS 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.

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(self, 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.

tanp_to_det(self, x, y)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

tanp_to_world(self, x, y)[source]

Convert tangent plane coordinates to world coordinates.

wcs

Get current WCS object.

world_to_det(self, ra, dec)[source]

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

world_to_tanp(self, ra, dec)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

class tweakwcs.tpwcs.JWSTgWCS(wcs, wcsinfo, meta=None)[source]

A class for holding JWST gWCS information and for managing tangent-plane corrections.

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.

bounding_box

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

det_to_tanp(self, x, y)[source]

Convert detector (pixel) coordinates to tangent plane coordinates.

det_to_world(self, x, y)[source]

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

ref_angles

Return a wcsinfo-like dictionary of main WCS parameters.

set_correction(self, 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 JWSTgWCS 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: TPWCS, None, optional

A reference WCS of the type TPWCS 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. JWSTgWCS ignores these arguments (except for storing them in the meta attribute).

tanp_to_det(self, x, y)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

tanp_to_world(self, x, y)[source]

Convert tangent plane coordinates to world coordinates.

world_to_det(self, ra, dec)[source]

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

world_to_tanp(self, ra, dec)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

class tweakwcs.tpwcs.FITSWCS(wcs, meta=None)[source]

A class for holding FITS WCS information and for managing tangent-plane corrections.

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.

bounding_box

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

det_to_tanp(self, x, y)[source]

Convert detector (pixel) coordinates to tangent plane coordinates.

det_to_world(self, x, y)[source]

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

set_correction(self, 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 FITSWCS 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: TPWCS, None, optional

A reference WCS of the type TPWCS 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. FITSWCS ignores these arguments (except for storing them in the meta attribute).

tanp_to_det(self, x, y)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.

tanp_to_world(self, x, y)[source]

Convert tangent plane coordinates to world coordinates.

world_to_det(self, ra, dec)[source]

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

world_to_tanp(self, ra, dec)[source]

Convert tangent plane coordinates to detector (pixel) coordinates.