22__all__ = [
"AssembleCcdTask"]
30from lsstDebug
import getDebugFrame
34 doTrim = pexConfig.Field(
35 doc=
"trim out non-data regions?",
39 keysToRemove = pexConfig.ListField(
40 doc=
"FITS headers to remove (in addition to DATASEC, BIASSEC, TRIMSEC and perhaps GAIN)",
55 @anchor AssembleCcdTask_
57 @brief Assemble a set of amplifier images into a full detector size set of
60 @section ip_isr_assemble_Contents Contents
62 -
@ref ip_isr_assemble_Purpose
63 -
@ref ip_isr_assemble_Initialize
64 -
@ref ip_isr_assemble_IO
65 -
@ref ip_isr_assemble_Config
66 -
@ref ip_isr_assemble_Debug
67 -
@ref ip_isr_assemble_Example
69 @section ip_isr_assemble_Purpose Description
71 This task assembles sections of an image into a larger mosaic. The
72 sub-sections are typically amplifier sections
and are to be assembled
73 into a detector size pixel grid. The assembly
is driven by the entries
in
74 the raw amp information. The task can be configured to
return a detector
75 image
with non-data (e.g. overscan) pixels included. The task can also
76 renormalize the pixel values to a nominal gain of 1. The task also
77 removes exposure metadata that has context
in raw amps, but
not in trimmed
78 detectors (e.g.
'BIASSEC').
80 @section ip_isr_assemble_Initialize Task initialization
84 @section ip_isr_assemble_IO Inputs/Outputs to the assembleCcd method
88 @section ip_isr_assemble_Config Configuration parameters
90 See
@ref AssembleCcdConfig
92 @section ip_isr_assemble_Debug Debug variables
94 The command line task interface supports a flag
@c -d to
import @b debug.py
from your
96 href=
"https://developer.lsst.io/stack/debug.html">Debugging Tasks
with
97 lsstDebug</a>
for more about
@b debug.py files.
99 The available variables
in AssembleCcdTask are:
102 <DD> A dictionary containing debug point names
as keys
with frame number
103 as value. Valid keys are:
105 <DT> assembledExposure
106 <DD> display assembled exposure
110 @section ip_isr_assemble_Example A complete example of using
114 To investigate the
@ref ip_isr_assemble_Debug, put something like
120 if name ==
"lsst.ip.isr.assembleCcdTask":
121 di.display = {
'assembledExposure':2}
126 into your debug.py file
and run runAssembleTask.py
with the
@c --debug
131 Display code should be updated once we settle on a standard way of
132 controlling what
is displayed.
134 ConfigClass = AssembleCcdConfig
135 _DefaultName = "assembleCcd"
138 """!Initialize the AssembleCcdTask
140 The keys for removal specified
in the config are added to a default
141 set: (
'DATASEC',
'BIASSEC',
'TRIMSEC',
'GAIN')
143 pipeBase.Task.__init__(self, **kwargs)
145 self.allKeysToRemove = ('DATASEC',
'BIASSEC',
'TRIMSEC',
'GAIN') + tuple(self.config.keysToRemove)
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
152 amps. If a dictionary of amp exposures,
153 the key should be the amp name.
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")
A class to contain the data, WCS, and other information needed to describe an image of the sky.
def assembleCcd(self, assembleInput)
Assemble a set of amps into a single CCD size image.
def __init__(self, **kwargs)
Initialize the AssembleCcdTask.
def postprocessExposure(self, outExposure, inExposure)