25import lsst.pipe.base.connectionTypes
as cT
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",),
51 outputExp = cT.Output(
53 doc=
"Output binned image.",
54 storageClass=
"ExposureF",
55 dimensions=(
"instrument",
"detector"),
60 pipelineConnections=VisualizeBinExpConnections):
61 """Configuration for focal plane visualization.
63 binning = pexConfig.Field(
66 doc="Binning factor to apply to each input exposure's image data.",
68 detectorKeyword = pexConfig.Field(
71 doc=
"Metadata keyword to use to find detector if not available from input.",
76 pipeBase.CmdLineTask):
77 """Bin the detectors of an exposure.
79 The outputs of this task should be passed to
80 VisualizeMosaicExpTask to be mosaicked into a full focal plane
83 ConfigClass = VisualizeBinExpConfig
84 _DefaultName = 'VisualizeBinExp'
86 def run(self, inputExp, camera):
87 """Bin input image, attach associated detector.
92 Input exposure data to bin.
94 Input camera to use for mosaic geometry.
98 output : `lsst.pipe.base.Struct`
99 Results struct
with attribute:
104 if inputExp.getDetector()
is None:
105 detectorId = inputExp.getMetadata().get(self.config.detectorKeyword)
106 if detectorId
is not None:
107 inputExp.setDetector(camera[detectorId])
109 binned = inputExp.getMaskedImage()
110 binned = afwMath.binImage(binned, self.config.binning)
111 outputExp = afwImage.makeExposure(binned)
113 outputExp.setInfo(inputExp.getInfo())
115 return pipeBase.Struct(
121 dimensions=(
"instrument", )):
122 inputExps = cT.Input(
124 doc=
"Input binned images mosaic.",
125 storageClass=
"ExposureF",
126 dimensions=(
"instrument",
"detector"),
129 camera = cT.PrerequisiteInput(
131 doc=
"Input camera to use for mosaic geometry.",
132 storageClass=
"Camera",
133 dimensions=(
"instrument",),
137 outputData = cT.Output(
138 name=
"calexpFocalPlane",
139 doc=
"Output binned mosaicked frame.",
140 storageClass=
"ImageF",
141 dimensions=(
"instrument", ),
146 pipelineConnections=VisualizeMosaicExpConnections):
147 """Configuration for focal plane visualization.
149 binning = pexConfig.Field(
152 doc="Binning factor previously applied to input exposures.",
157 pipeBase.CmdLineTask):
158 """Task to mosaic binned products.
160 The config.binning parameter must match that used in the
161 VisualizeBinExpTask. Otherwise there will be a mismatch between
162 the input image size
and the expected size of that image
in the
163 full focal plane frame.
165 ConfigClass = VisualizeMosaicExpConfig
166 _DefaultName = 'VisualizeMosaicExp'
169 """Make an image of an entire focal plane.
174 CCD exposures, binned by `binning`. The keys are the
175 detectorIDs, with the values the binned image exposure.
180 Image mosaicked
from the individual binned images
for each
183 image = afwUtils.makeImageFromCamera(
186 imageFactory=afwImage.ImageF,
191 def run(self, inputExps, camera):
192 """Mosaic inputs together to create focal plane image.
197 Input exposure data to bin.
199 Input camera to use for mosaic geometry.
203 output : `lsst.pipe.base.Struct`
204 Results struct
with attribute:
209 expDict = {exp.getDetector().getId(): exp for exp
in inputExps}
212 return pipeBase.Struct(
218 """Source of images for makeImageFromCamera"""
225 """Provide image of CCD to makeImageFromCamera
230 Detector ID to get image data for.
232 Type of image to construct.
234 Binsize to use to recompute dimensions.
239 Appropriately rotated, binned,
and transformed
240 image to be mosaicked.
242 Camera detector that the returned image data
245 detId = detector.getId()
248 dims = detector.getBBox().getDimensions()/binSize
249 image = imageFactory(*[int(xx)
for xx
in dims])
253 if hasattr(image,
"getMaskedImage"):
254 image = image.getMaskedImage()
255 if hasattr(image,
"getMask"):
256 mask = image.getMask()
257 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
258 image = image.clone()
259 image.getImage().getArray()[isBad] = self.
background
260 if hasattr(image,
"getImage"):
261 image = image.getImage()
265 image = afwMath.rotateImageBy90(image, detector.getOrientation().getNQuarter())
266 return image, detector
def __init__(self, exposures)
def getCcdImage(self, detector, imageFactory, binSize)
def run(self, inputExp, camera)
def run(self, inputExps, camera)
def makeCameraImage(self, inputExps, camera, binning)