28from ..image._slicing
import supportSlicing
29from ..image._disableArithmetic
import disableImageArithmetic
30from ..image._fitsIoWithOptions
import imageReadFitsWithOptions, exposureWriteFitsWithOptions
31from ._exposure
import ExposureI, ExposureF, ExposureD, ExposureU, ExposureL
32from .exposureUtils
import bbox_to_convex_polygon, bbox_contains_sky_coords
37 def _set(self, index, value, origin):
38 """Set the pixel at the given index to a triple (value, mask, variance).
43 Position of the pixel to assign to.
45 A tuple of (value, mask, variance) scalars.
46 origin : `ImageOrigin`
47 Coordinate system of ``index`` (`PARENT` or `LOCAL`).
49 self.maskedImage._set(index, value=value, origin=origin)
51 def _get(self, index, origin):
52 """Return a triple (value, mask, variance) at the given index.
57 Position of the pixel to assign to.
58 origin : `ImageOrigin`
59 Coordinate system of ``index`` (`PARENT` or `LOCAL`).
61 return self.maskedImage._get(index, origin=origin)
65 return reduceToFits(self)
68 return ExposureF(self, deep=
True)
71 return ExposureD(self, deep=
True)
74 return self.maskedImage.image
77 self.maskedImage.image = image
79 image = property(getImage, setImage)
82 return self.maskedImage.mask
85 self.maskedImage.mask = mask
87 mask = property(getMask, setMask)
90 return self.maskedImage.variance
93 self.maskedImage.variance = variance
95 variance = property(getVariance, setVariance)
98 """Get the convex polygon associated with the bounding box corners.
100 The returned polygon has additional padding to ensure that the
101 bounding box is entirely contained within it. To ensure a set
102 of coordinates are entirely contained within an exposure, run
103 ``exposure.containsSkyCoords()``. The default padding
104 size was chosen to be sufficient
for the most warped detectors at
105 the edges of the HyperSuprimeCam focal plane.
110 Pixel padding to ensure that bounding box
is entirely contained
111 within the resulting polygon.
116 Returns `
None`
if exposure does
not have a valid WCS.
121 return bbox_to_convex_polygon(self.getBBox(), self.wcs, padding=padding)
123 convex_polygon = property(getConvexPolygon)
126 """Check if a set of sky positions is in the pixel bounding box.
128 The default padding size was chosen to be sufficient for the
129 most warped detectors at the edges of the HyperSuprimeCam focal plane.
133 ra : `astropy.Quantity`, (N,)
134 Array of Right Ascension, angular units.
135 dec : `astropy.Quantity`, (N,)
136 Array of Declination, angular units.
137 padding : `int`, optional
138 Pixel padding to ensure that bounding box
is entirely contained
143 contained : `np.ndarray`, (N,)
144 Boolean array indicating which points are contained
in the
149 ValueError
if exposure does
not have a valid wcs.
152 raise ValueError(
"Exposure does not have a valid WCS.")
154 return bbox_contains_sky_coords(
161 readFitsWithOptions = classmethod(imageReadFitsWithOptions)
163 writeFitsWithOptions = exposureWriteFitsWithOptions
166Exposure.register(np.int32, ExposureI)
167Exposure.register(np.float32, ExposureF)
168Exposure.register(np.float64, ExposureD)
169Exposure.register(np.uint16, ExposureU)
170Exposure.register(np.uint64, ExposureL)
171Exposure.alias(
"I", ExposureI)
172Exposure.alias(
"F", ExposureF)
173Exposure.alias(
"D", ExposureD)
174Exposure.alias(
"U", ExposureU)
175Exposure.alias(
"L", ExposureL)
177for cls
in set(Exposure.values()):
179 disableImageArithmetic(cls)
def setImage(self, image)
def getConvexPolygon(self, padding=10)
def containsSkyCoords(self, ra, dec, padding=10)
def setVariance(self, variance)
ConvexPolygon is a closed convex polygon on the unit sphere.
daf::base::PropertySet * set