31 __all__ = [
'VisualizeBinExpConfig',
'VisualizeBinExpTask',
32 'VisualizeMosaicExpConfig',
'VisualizeMosaicExpTask']
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",
"calibration_label"),
50 outputExp = cT.Output(
52 doc=
"Output binned image.",
53 storageClass=
"ExposureF",
54 dimensions=(
"instrument",
"detector"),
59 pipelineConnections=VisualizeBinExpConnections):
60 """Configuration for focal plane visualization.
62 binning = pexConfig.Field(
65 doc=
"Binning factor to apply to each input exposure's image data.",
67 detectorKeyword = pexConfig.Field(
70 doc=
"Metadata keyword to use to find detector if not available from input.",
75 pipeBase.CmdLineTask):
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.
90 inputExp : `lsst.afw.image.Exposure`
91 Input exposure data to bin.
92 camera : `lsst.afw.cameraGeom.Camera`
93 Input camera to use for mosaic geometry.
97 output : `lsst.pipe.base.Struct`
98 Results struct with attribute:
101 Binned version of input image (`lsst.afw.image.Exposure`).
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())
113 outputExp.setFilter(inputExp.getFilter())
114 outputExp.setMetadata(inputExp.getMetadata())
115 outputExp.setDetector(inputExp.getDetector())
117 return pipeBase.Struct(
123 dimensions=(
"instrument", )):
124 inputExps = cT.Input(
126 doc=
"Input binned images mosaic.",
127 storageClass=
"ExposureF",
128 dimensions=(
"instrument",
"detector"),
131 camera = cT.PrerequisiteInput(
133 doc=
"Input camera to use for mosaic geometry.",
134 storageClass=
"Camera",
135 dimensions=(
"instrument",
"calibration_label"),
138 outputData = cT.Output(
139 name=
"calexpFocalPlane",
140 doc=
"Output binned mosaicked frame.",
141 storageClass=
"ImageF",
142 dimensions=(
"instrument", ),
147 pipelineConnections=VisualizeMosaicExpConnections):
148 """Configuration for focal plane visualization.
150 binning = pexConfig.Field(
153 doc=
"Binning factor previously applied to input exposures.",
158 pipeBase.CmdLineTask):
159 """Task to mosaic binned products.
161 The config.binning parameter must match that used in the
162 VisualizeBinExpTask. Otherwise there will be a mismatch between
163 the input image size and the expected size of that image in the
164 full focal plane frame.
166 ConfigClass = VisualizeMosaicExpConfig
167 _DefaultName =
'VisualizeMosaicExp'
170 """Make an image of an entire focal plane.
174 exposures: `dict` [`int`, `lsst.afw.image.Exposure`]
175 CCD exposures, binned by `binning`. The keys are the
176 detectorIDs, with the values the binned image exposure.
180 image : `lsst.afw.image.Image`
181 Image mosaicked from the individual binned images for each
184 image = afwUtils.makeImageFromCamera(
187 imageFactory=afwImage.ImageF,
192 def run(self, inputExps, camera):
193 """Mosaic inputs together to create focal plane image.
197 inputExp : `list` [`lsst.afw.image.Exposure`]
198 Input exposure data to bin.
199 camera : `lsst.afw.cameraGeom.Camera`
200 Input camera to use for mosaic geometry.
204 output : `lsst.pipe.base.Struct`
205 Results struct with attribute:
208 Binned version of input image (`lsst.afw.image.Exposure`).
210 expDict = {exp.getDetector().getId(): exp
for exp
in inputExps}
213 return pipeBase.Struct(
219 """Source of images for makeImageFromCamera"""
226 """Provide image of CCD to makeImageFromCamera
231 Detector ID to get image data for.
232 imageFactory : `lsst.afw.image.Image`
233 Type of image to construct.
235 Binsize to use to recompute dimensions.
239 image : `lsst.afw.image.Image`
240 Appropriately rotated, binned, and transformed
241 image to be mosaicked.
242 detector : `lsst.afw.cameraGeom.Detector`
243 Camera detector that the returned image data
246 detId = detector.getId()
249 dims = detector.getBBox().getDimensions()/binSize
250 image = imageFactory(*[int(xx)
for xx
in dims])
254 if hasattr(image,
"getMaskedImage"):
255 image = image.getMaskedImage()
256 if hasattr(image,
"getMask"):
257 mask = image.getMask()
258 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
259 image = image.clone()
260 image.getImage().getArray()[isBad] = self.
background
261 if hasattr(image,
"getImage"):
262 image = image.getImage()
267 return image, detector