148 """!Assemble a set of amps into a single CCD size image
149 @param[in] assembleInput -- Either a dictionary of amp
150 lsst.afw.image.Exposures or a single
151 lsst.afw.image.Exposure containing all raw
152 amps. If a dictionary of amp exposures,
153 the key should be the amp name.
154 @return assembledCcd -- An lsst.afw.image.Exposure of the assembled
157 @throws TypeError with the following string:
160 <DT> Expected either a dictionary of amp exposures or a single raw
162 <DD> The input exposures to be assembled do not adhere to the
166 @throws RuntimeError with the following string:
169 <DT> No ccd detector found
170 <DD> The detector set on the input exposure is not set.
174 if isinstance(assembleInput, dict):
179 ccd = next(iter(assembleInput.values())).getDetector()
181 def getNextExposure(amp):
182 return assembleInput[amp.getName()]
183 elif hasattr(assembleInput,
"getMaskedImage"):
185 ccd = assembleInput.getDetector()
187 def getNextExposure(amp):
190 raise TypeError(
"Expected either a dictionary of amp exposures or a single raw exposure")
193 raise RuntimeError(
"No ccd detector found")
195 if not self.config.doTrim:
196 outBox = cameraGeomUtils.calcRawCcdBBox(ccd)
198 outBox = ccd.getBBox()
199 outExposure = afwImage.ExposureF(outBox)
200 outMI = outExposure.getMaskedImage()
202 if self.config.doTrim:
203 assemble = cameraGeom.assembleAmplifierImage
205 assemble = cameraGeom.assembleAmplifierRawImage
208 inMI = getNextExposure(amp).getMaskedImage()
209 assemble(outMI, inMI, amp)
216 if not self.config.doTrim:
217 ccd = cameraGeom.makeUpdatedDetector(ccd)
219 outExposure.setDetector(ccd)
225 """Set exposure non-image attributes, including wcs and metadata and
226 display exposure (if requested)
228 Call after assembling the pixels
230 @param[in,out] outExposure assembled exposure:
231 - removes unwanted keywords
232 - sets wcs, filter, and detector
233 @param[in] inExposure input exposure
235 if inExposure.hasWcs():
236 outExposure.setWcs(inExposure.getWcs())
238 exposureMetadata = inExposure.getMetadata()
240 if exposureMetadata.exists(key):
241 exposureMetadata.remove(key)
242 outExposure.setMetadata(exposureMetadata)
246 outExposure.info.id = inExposure.info.id
247 outExposure.setFilter(inExposure.getFilter())
248 outExposure.getInfo().setVisitInfo(inExposure.getInfo().getVisitInfo())
250 frame = getDebugFrame(self._display,
"assembledExposure")
252 afwDisplay.Display(frame=frame).mtv(outExposure, title=
"postprocessExposure")