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_fromandwcs_toWCS have the same units.- Parameters:
wcs_from (object) – 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. Ifshapeparameter is provided, it will take precedence over this object’sarray_shapevalue.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.ndarrayorder. When provided, it takes precedence over thewcs_from.array_shapeproperty.disable_bbox (str, optional) – Indicates whether to use or not to use the bounding box of either (both)
wcs_fromor (and)wcs_towhen computing pixel map. Allowable values: “to”, “from”, “both”, “none”. Whendisable_bboxis “none”, pixel coordinates outside of the bounding box are set to NaN only ifwcs_fromor (and)wcs_tosets 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>1is not recommended. Largestepsizevalues 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:
- Raises:
ValueError – A ValueError is raised when output pixel map shape cannot be determined from provided inputs.
Notes
When
shapeis not provided andwcs_from.array_shapeis not set (i.e., it is None), calc_pixmap will attempt to determine pixel map shape from thebounding_boxproperty of the inputwcs_fromobject. Ifbounding_boxis not available, a ValueError will be raised.