decode_context
- jwst.resample.resample_utils.decode_context(context, x, y)[source]
Get 0-based indices of input images that contributed to (resampled) output pixel with coordinates
x
andy
.- Parameters:
context (numpy.ndarray) – A 3D
ndarray
of integral data type.x (int, list of integers, numpy.ndarray of integers) – X-coordinate of pixels to decode (3rd index into the
context
array)y (int, list of integers, numpy.ndarray of integers) – Y-coordinate of pixels to decode (2nd index into the
context
array)
- Returns:
A list of
numpy.ndarray
objects each containing indices of input imagesthat have contributed to an output pixel with coordinates
x
andy
.The length of returned list is equal to the number of input coordinate
arrays
x
andy
.
Examples
An example context array for an output image of array shape
(5, 6)
obtained by resampling 80 input images.>>> import numpy as np >>> from jwst.resample.resample_utils import decode_context >>> con = np.array( ... [[[0, 0, 0, 0, 0, 0], ... [0, 0, 0, 36196864, 0, 0], ... [0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0], ... [0, 0, 537920000, 0, 0, 0]], ... [[0, 0, 0, 0, 0, 0,], ... [0, 0, 0, 67125536, 0, 0], ... [0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0], ... [0, 0, 163856, 0, 0, 0]], ... [[0, 0, 0, 0, 0, 0], ... [0, 0, 0, 8203, 0, 0], ... [0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0], ... [0, 0, 32865, 0, 0, 0]]], ... dtype=np.int32 ... ) >>> decode_context(con, [3, 2], [1, 4]) [array([ 9, 12, 14, 19, 21, 25, 37, 40, 46, 58, 64, 65, 67, 77]), array([ 9, 20, 29, 36, 47, 49, 64, 69, 70, 79])]