63 """Assemble a set of amps into a single CCD size image.
67 assembleInput : `dict` [`str`, `lsst.afw.image.Exposure`] or \
68 `lsst.afw.image.Exposure`
69 Either a dictionary of amp exposures, or a single exposure
70 containing all raw amps. If a dictionary of amp exposures, the key
71 should be the amp name.
75 assembledCcd : `lsst.afw.image.Exposure`
76 An exposure of the assembled amp sections.
81 Raised if the input exposures to be assembled do not adhere to the
84 Raised if the detector set on the input exposure is not set.
87 if isinstance(assembleInput, dict):
92 ccd = next(iter(assembleInput.values())).getDetector()
94 def getNextExposure(amp):
95 return assembleInput[amp.getName()]
96 elif hasattr(assembleInput,
"getMaskedImage"):
98 ccd = assembleInput.getDetector()
100 def getNextExposure(amp):
103 raise TypeError(
"Expected either a dictionary of amp exposures or a single raw exposure")
106 raise RuntimeError(
"No ccd detector found")
108 if not self.config.doTrim:
109 outBox = cameraGeomUtils.calcRawCcdBBox(ccd)
111 outBox = ccd.getBBox()
112 outExposure = afwImage.ExposureF(outBox)
113 outMI = outExposure.getMaskedImage()
115 if self.config.doTrim:
116 assemble = cameraGeom.assembleAmplifierImage
118 assemble = cameraGeom.assembleAmplifierRawImage
121 inMI = getNextExposure(amp).getMaskedImage()
122 assemble(outMI, inMI, amp)
129 if not self.config.doTrim:
130 ccd = cameraGeom.makeUpdatedDetector(ccd)
132 outExposure.setDetector(ccd)
138 """Set exposure non-image attributes, including wcs and metadata and
139 display exposure (if requested).
141 Call after assembling the pixels.
145 outExposure : `lsst.afw.image.Exposure`
146 The exposure to modify by copying metadata (after removing unwanted
147 keywords), wcs, filter, and detector from ``inExposure``.
148 inExposure : `lsst.afw.image.Exposure`
149 The input exposure providing metadata, wcs, filter, and detector.
151 if inExposure.hasWcs():
152 outExposure.setWcs(inExposure.getWcs())
154 exposureMetadata = inExposure.getMetadata()
156 if exposureMetadata.exists(key):
157 exposureMetadata.remove(key)
158 outExposure.setMetadata(exposureMetadata)
162 outExposure.info.id = inExposure.info.id
163 outExposure.setFilter(inExposure.getFilter())
164 outExposure.getInfo().setVisitInfo(inExposure.getInfo().getVisitInfo())
166 frame = getDebugFrame(self._display,
"assembledExposure")
168 afwDisplay.Display(frame=frame).mtv(outExposure, title=
"postprocessExposure")