22__all__ = [
'VisualizeBinExpConfig',
'VisualizeBinExpTask',
23 'VisualizeMosaicExpConfig',
'VisualizeMosaicExpTask']
29import lsst.pipe.base.connectionTypes
as cT
36 dimensions=(
"instrument",
"detector")):
39 doc=
"Input exposure data to mosaic.",
40 storageClass=
"ExposureF",
41 dimensions=(
"instrument",
"detector"),
43 camera = cT.PrerequisiteInput(
45 doc=
"Input camera to use for mosaic geometry.",
46 storageClass=
"Camera",
47 dimensions=(
"instrument",),
51 outputExp = cT.Output(
53 doc=
"Output binned image.",
54 storageClass=
"ExposureF",
55 dimensions=(
"instrument",
"detector"),
60 pipelineConnections=VisualizeBinExpConnections):
61 """Configuration for focal plane visualization.
63 binning = pexConfig.Field(
66 doc="Binning factor to apply to each input exposure's image data.",
68 detectorKeyword = pexConfig.Field(
71 doc=
"Metadata keyword to use to find detector if not available from input.",
76 """Bin the detectors of an exposure.
78 The outputs of this task should be passed to
79 VisualizeMosaicExpTask to be mosaicked into a full focal plane
82 ConfigClass = VisualizeBinExpConfig
83 _DefaultName = 'VisualizeBinExp'
85 def run(self, inputExp, camera):
86 """Bin input image, attach associated detector.
91 Input exposure data to bin.
93 Input camera to use for mosaic geometry.
97 output : `lsst.pipe.base.Struct`
98 Results struct
with attribute:
103 if inputExp.getDetector()
is None:
104 detectorId = inputExp.getMetadata().get(self.config.detectorKeyword)
105 if detectorId
is not None:
106 inputExp.setDetector(camera[detectorId])
108 binned = inputExp.getMaskedImage()
112 outputExp.setInfo(inputExp.getInfo())
114 return pipeBase.Struct(
120 dimensions=(
"instrument", )):
121 inputExps = cT.Input(
123 doc=
"Input binned images mosaic.",
124 storageClass=
"ExposureF",
125 dimensions=(
"instrument",
"detector"),
128 camera = cT.PrerequisiteInput(
130 doc=
"Input camera to use for mosaic geometry.",
131 storageClass=
"Camera",
132 dimensions=(
"instrument",),
136 outputData = cT.Output(
137 name=
"calexpFocalPlane",
138 doc=
"Output binned mosaicked frame.",
139 storageClass=
"ImageF",
140 dimensions=(
"instrument", ),
145 pipelineConnections=VisualizeMosaicExpConnections):
146 """Configuration for focal plane visualization.
148 binning = pexConfig.Field(
151 doc="Binning factor previously applied to input exposures.",
156 """Task to mosaic binned products.
158 The config.binning parameter must match that used in the
159 VisualizeBinExpTask. Otherwise there will be a mismatch between
160 the input image size
and the expected size of that image
in the
161 full focal plane frame.
163 ConfigClass = VisualizeMosaicExpConfig
164 _DefaultName = 'VisualizeMosaicExp'
166 def makeCameraImage(self, inputExps, camera, binning):
167 """Make an image of an entire focal plane.
172 CCD exposures, binned by `binning`. The keys are the
173 detectorIDs, with the values the binned image exposure.
178 Image mosaicked
from the individual binned images
for each
181 image = afwUtils.makeImageFromCamera(
184 imageFactory=afwImage.ImageF,
189 def run(self, inputExps, camera):
190 """Mosaic inputs together to create focal plane image.
195 Input exposure data to bin.
197 Input camera to use for mosaic geometry.
201 output : `lsst.pipe.base.Struct`
202 Results struct
with attribute:
207 expDict = {exp.getDetector().getId(): exp for exp
in inputExps}
210 return pipeBase.Struct(
216 """Source of images for makeImageFromCamera"""
223 """Provide image of CCD to makeImageFromCamera
228 Detector ID to get image data for.
230 Type of image to construct.
232 Binsize to use to recompute dimensions.
237 Appropriately rotated, binned,
and transformed
238 image to be mosaicked.
240 Camera detector that the returned image data
243 detId = detector.getId()
246 dims = detector.getBBox().getDimensions()/binSize
247 image = imageFactory(*[int(xx)
for xx
in dims])
251 if hasattr(image,
"getMaskedImage"):
252 image = image.getMaskedImage()
253 if hasattr(image,
"getMask"):
254 mask = image.getMask()
255 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
256 image = image.clone()
257 image.getImage().getArray()[isBad] = self.
background
258 if hasattr(image,
"getImage"):
259 image = image.getImage()
264 return image, detector
An immutable representation of a camera.
A representation of a detector in a mosaic camera.
A class to contain the data, WCS, and other information needed to describe an image of the sky.
A class to represent a 2-dimensional array of pixels.
def __init__(self, exposures)
def getCcdImage(self, detector, imageFactory, binSize)
def makeCameraImage(self, inputExps, camera, binning)
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
std::shared_ptr< ImageT > rotateImageBy90(ImageT const &image, int nQuarter)
Rotate an image by an integral number of quarter turns.
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)