calc_pixmap

stcal.resample.utils.calc_pixmap(wcs_from, wcs_to, shape=None, disable_bbox='to', stepsize=1, order=1)[source]

Calculate pixel coordinates of one WCS corresponding to the native pixel grid of another WCS.

Note

This function assumes that output frames of wcs_from and wcs_to WCS have the same units.

Parameters:
  • wcs_from (object) – 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 (object) – 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 (str, 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. Allowable values: “to”, “from”, “both”, “none”. 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.

  • stepsize (int, optional) – If stepsize>1, perform the full WCS calculation on a sparser grid and use interpolation to fill in the rest of the pixels. This option speeds up pixel map computation by reducing the number of WCS calls, though at the cost of reduced pixel map accuracy. The loss of accuracy is typically negligible if the underlying distortion correction is smooth, but if the distortion is non-smooth, stepsize>1 is not recommended. Large stepsize values are automatically reduced to no more than 1/10 of image size. Default 1.

  • order (int, optional) – Order of the 2D spline to interpolate the sparse pixel mapping if stepsize>1. Supported values are: 1 (bilinear) or 3 (bicubic). This Parameter is ignored when stepsize <= 1. Default 1.

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, respectively. 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.