28from lsstDebug
import getDebugFrame
30__all__ = [
"AssembleCcdTask"]
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
@link lsst.pipe.base.cmdLineTask.CmdLineTask command line task
@endlink
95 interface supports a flag
@c -d to
import @b debug.py
from your
97 href=
"https://developer.lsst.io/stack/debug.html">Debugging Tasks
with
98 lsstDebug</a>
for more about
@b debug.py files.
100 The available variables
in AssembleCcdTask are:
103 <DD> A dictionary containing debug point names
as keys
with frame number
104 as value. Valid keys are:
106 <DT> assembledExposure
107 <DD> display assembled exposure
111 @section ip_isr_assemble_Example A complete example of using
115 To investigate the
@ref ip_isr_assemble_Debug, put something like
121 if name ==
"lsst.ip.isr.assembleCcdTask":
122 di.display = {
'assembledExposure':2}
127 into your debug.py file
and run runAssembleTask.py
with the
@c --debug
132 Display code should be updated once we settle on a standard way of
133 controlling what
is displayed.
135 ConfigClass = AssembleCcdConfig
136 _DefaultName = "assembleCcd"
139 """!Initialize the AssembleCcdTask
141 The keys for removal specified
in the config are added to a default
142 set: (
'DATASEC',
'BIASSEC',
'TRIMSEC',
'GAIN')
144 pipeBase.Task.__init__(self, **kwargs)
146 self.allKeysToRemoveallKeysToRemove = ('DATASEC',
'BIASSEC',
'TRIMSEC',
'GAIN') + tuple(self.config.keysToRemove)
149 """!Assemble a set of amps into a single CCD size image
150 @param[
in] assembleInput -- Either a dictionary of amp
151 lsst.afw.image.Exposures
or a single
153 amps. If a dictionary of amp exposures,
154 the key should be the amp name.
158 @throws TypeError
with the following string:
161 <DT> Expected either a dictionary of amp exposures
or a single raw
163 <DD> The input exposures to be assembled do
not adhere to the
167 @throws RuntimeError
with the following string:
170 <DT> No ccd detector found
171 <DD> The detector set on the input exposure
is not set.
175 if isinstance(assembleInput, dict):
180 ccd =
next(
iter(assembleInput.values())).getDetector()
182 def getNextExposure(amp):
183 return assembleInput[amp.getName()]
184 elif hasattr(assembleInput,
"getMaskedImage"):
186 ccd = assembleInput.getDetector()
188 def getNextExposure(amp):
191 raise TypeError(
"Expected either a dictionary of amp exposures or a single raw exposure")
194 raise RuntimeError(
"No ccd detector found")
196 if not self.config.doTrim:
197 outBox = cameraGeomUtils.calcRawCcdBBox(ccd)
199 outBox = ccd.getBBox()
200 outExposure = afwImage.ExposureF(outBox)
201 outMI = outExposure.getMaskedImage()
203 if self.config.doTrim:
204 assemble = cameraGeom.assembleAmplifierImage
206 assemble = cameraGeom.assembleAmplifierRawImage
209 inMI = getNextExposure(amp).getMaskedImage()
210 assemble(outMI, inMI, amp)
217 if not self.config.doTrim:
218 ccd = cameraGeom.makeUpdatedDetector(ccd)
220 outExposure.setDetector(ccd)
221 self.
postprocessExposurepostprocessExposure(outExposure=outExposure, inExposure=getNextExposure(ccd[0]))
226 """Set exposure non-image attributes, including wcs and metadata and
227 display exposure (if requested)
229 Call after assembling the pixels
231 @param[
in,out] outExposure assembled exposure:
232 - removes unwanted keywords
233 - sets wcs, filter,
and detector
234 @param[
in] inExposure input exposure
236 if inExposure.hasWcs():
237 outExposure.setWcs(inExposure.getWcs())
239 exposureMetadata = inExposure.getMetadata()
241 if exposureMetadata.exists(key):
242 exposureMetadata.remove(key)
243 outExposure.setMetadata(exposureMetadata)
247 outExposure.info.id = inExposure.info.id
248 outExposure.setFilter(inExposure.getFilter())
249 outExposure.getInfo().setVisitInfo(inExposure.getInfo().getVisitInfo())
253 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)
def mtv(data, frame=None, title="", wcs=None, *args, **kwargs)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
def getDebugFrame(debugDisplay, name)