calc_pixmap¶
- drizzle.utils.calc_pixmap(wcs_from, wcs_to, shape=None, disable_bbox='to')[source]¶
Calculate a discretized on a grid mapping between the pixels of two images using provided WCS of the original (“from”) image and the destination (“to”) image.
Note
This function assumes that output frames of
wcs_from
andwcs_to
WCS have the same units.- Parameters:
wcs_from (wcs) – A WCS object representing the coordinate system you are converting from. This object’s
array_shape
(orpixel_shape
) property will be used to define the shape of the pixel map array. Ifshape
parameter is provided, it will take precedence over this object’sarray_shape
value.wcs_to (wcs) – A WCS object representing the coordinate system you are converting to.
shape (tuple, None, optional) – A tuple of integers indicating the shape of the output array in the
numpy.ndarray
order. When provided, it takes precedence over thewcs_from.array_shape
property.disable_bbox ({"to", "from", "both", "none"}, optional) – Indicates whether to use or not to use the bounding box of either (both)
wcs_from
or (and)wcs_to
when computing pixel map. Whendisable_bbox
is “none”, pixel coordinates outside of the bounding box are set to NaN only ifwcs_from
or (and)wcs_to
sets world coordinates to NaN when input pixel coordinates are outside of the bounding box.
- Returns:
pixmap – A three dimensional array representing the transformation between the two. The last dimension is of length two and contains the x and y coordinates of a pixel center, repectively. The other two coordinates correspond to the two coordinates of the image the first WCS is from.
- Return type:
numpy.ndarray
- Raises:
ValueError – A ValueError is raised when output pixel map shape cannot be determined from provided inputs.
Notes
When
shape
is not provided andwcs_from.array_shape
is not set (i.e., it is None), calc_pixmap will attempt to determine pixel map shape from thebounding_box
property of the inputwcs_from
object. Ifbounding_box
is not available, a ValueError will be raised.