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 and wcs_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 (or pixel_shape) property will be used to define the shape of the pixel map array. If shape parameter is provided, it will take precedence over this object’s array_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 the wcs_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. When disable_bbox is “none”, pixel coordinates outside of the bounding box are set to NaN only if wcs_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 and wcs_from.array_shape is not set (i.e., it is None), calc_pixmap will attempt to determine pixel map shape from the bounding_box property of the input wcs_from object. If bounding_box is not available, a ValueError will be raised.