23 __all__ = [
"MaskedImage",
"VariancePixel"]
29 from ..image.fitsIoWithOptions
import imageReadFitsWithOptions, exposureWriteFitsWithOptions
30 from ..slicing
import supportSlicing
31 from .maskedImage
import MaskedImageI, MaskedImageF, MaskedImageD, MaskedImageU, MaskedImageL
34 VariancePixel = np.float32
39 def set(self, value, mask=None, variance=None):
40 """Assign a tuple of scalars to the entirety of all three planes. 42 if mask
is None and variance
is None:
44 value, mask, variance = value
53 self.variance.
set(variance)
55 def _set(self, index, value, origin):
56 """Set the pixel at the given index to a triple (value, mask, variance). 60 index : `geom.Point2I` 61 Position of the pixel to assign to. 63 A tuple of (value, mask, variance) scalars. 64 origin : `ImageOrigin` 65 Coordinate system of ``index`` (`PARENT` or `LOCAL`). 67 self.image[index, origin] = value[0]
68 self.mask[index, origin] = value[1]
69 self.variance[index, origin] = value[2]
71 def _get(self, index, origin):
72 """Return a triple (value, mask, variance) at the given index. 76 index : `geom.Point2I` 77 Position of the pixel to assign to. 78 origin : `ImageOrigin` 79 Coordinate system of ``index`` (`PARENT` or `LOCAL`). 81 return (self.image[index, origin],
82 self.mask[index, origin],
83 self.variance[index, origin])
86 """Return a tuple (value, mask, variance) numpy arrays.""" 87 return (self.image.array
if self.image
else None,
88 self.mask.array
if self.mask
else None,
89 self.variance.array
if self.variance
else None)
92 return MaskedImageF(self,
True)
95 return MaskedImageD(self,
True)
102 string =
"image={},\nmask={}, maskPlaneDict={}\nvariance={}, bbox={}" 103 return string.format(self.image.array,
105 self.mask.getMaskPlaneDict(),
110 return "{}.{}=({})".
format(self.__module__, self.__class__.__name__,
str(self))
112 readFitsWithOptions = classmethod(imageReadFitsWithOptions)
114 writeFitsWithOptions = exposureWriteFitsWithOptions
117 MaskedImage.register(np.int32, MaskedImageI)
118 MaskedImage.register(np.float32, MaskedImageF)
119 MaskedImage.register(np.float64, MaskedImageD)
120 MaskedImage.register(np.uint16, MaskedImageU)
121 MaskedImage.register(np.uint64, MaskedImageL)
122 MaskedImage.alias(
"I", MaskedImageI)
123 MaskedImage.alias(
"F", MaskedImageF)
124 MaskedImage.alias(
"D", MaskedImageD)
125 MaskedImage.alias(
"U", MaskedImageU) 126 MaskedImage.alias("L", MaskedImageL)
128 for cls
in set(MaskedImage.values()):
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
def set(self, value, mask=None, variance=None)