23 "VisualizeBinExpConfig",
24 "VisualizeBinExpTask",
25 "VisualizeMosaicExpConfig",
26 "VisualizeMosaicExpTask",
34import lsst.pipe.base.connectionTypes
as cT
41 doc=
"Input exposure data to mosaic.",
42 storageClass=
"ExposureF",
43 dimensions=(
"instrument",
"detector"),
45 camera = cT.PrerequisiteInput(
47 doc=
"Input camera to use for mosaic geometry.",
48 storageClass=
"Camera",
49 dimensions=(
"instrument",),
53 outputExp = cT.Output(
55 doc=
"Output binned image.",
56 storageClass=
"ExposureF",
57 dimensions=(
"instrument",
"detector"),
62 """Configuration for focal plane visualization."""
64 binning = pexConfig.Field(
67 doc=
"Binning factor to apply to each input exposure's image data.",
69 detectorKeyword = pexConfig.Field(
72 doc=
"Metadata keyword to use to find detector if not available from input.",
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
84 ConfigClass = VisualizeBinExpConfig
85 _DefaultName = "VisualizeBinExp"
87 def run(self, inputExp, camera):
88 """Bin input image, attach associated detector.
93 Input exposure data to bin.
95 Input camera to use for mosaic geometry.
99 output : `lsst.pipe.base.Struct`
100 Results struct
with attribute:
105 if inputExp.getDetector()
is None:
106 detectorId = inputExp.getMetadata().get(self.config.detectorKeyword)
107 if detectorId
is not None:
108 inputExp.setDetector(camera[detectorId])
110 binned = inputExp.getMaskedImage()
114 outputExp.setInfo(inputExp.getInfo())
116 return pipeBase.Struct(outputExp=outputExp)
120 inputExps = cT.Input(
122 doc=
"Input binned images mosaic.",
123 storageClass=
"ExposureF",
124 dimensions=(
"instrument",
"detector"),
127 camera = cT.PrerequisiteInput(
129 doc=
"Input camera to use for mosaic geometry.",
130 storageClass=
"Camera",
131 dimensions=(
"instrument",),
135 outputData = cT.Output(
136 name=
"calexpFocalPlane",
137 doc=
"Output binned mosaicked frame.",
138 storageClass=
"ImageF",
139 dimensions=(
"instrument",),
144 pipeBase.PipelineTaskConfig, pipelineConnections=VisualizeMosaicExpConnections
146 """Configuration for focal plane visualization."""
148 binning = pexConfig.Field(
151 doc=
"Binning factor previously applied to input exposures.",
156 """Task to mosaic binned products.
158 The config.binning parameter must match that used in the
159 VisualizeBinExpTask. Otherwise there will be a mismatch between
160 the input image size
and the expected size of that image
in the
161 full focal plane frame.
164 ConfigClass = VisualizeMosaicExpConfig
165 _DefaultName = "VisualizeMosaicExp"
168 """Make an image of an entire focal plane.
173 CCD exposures, binned by `binning`. The keys are the
174 detectorIDs, with the values the binned image exposure.
179 Image mosaicked
from the individual binned images
for each
182 image = afwUtils.makeImageFromCamera(
183 camera, imageSource=ImageSource(inputExps), imageFactory=afwImage.ImageF, binSize=binning
187 def run(self, inputExps, camera, inputIds=None):
188 """Mosaic inputs together to create focal plane image.
193 Input exposure data to bin.
195 Input camera to use for mosaic geometry.
196 inputIds : `list` [`int`], optional
197 Optional list providing exposure IDs corresponding to input
198 exposures. Will be generated via the exposure data `getDetector`
199 method
if not provided.
203 output : `lsst.pipe.base.Struct`
204 Results struct
with attribute:
210 inputIds = [exp.getDetector().getId()
for exp
in inputExps]
211 expDict = {id: exp
for id, exp
in zip(inputIds, inputExps)}
214 return pipeBase.Struct(outputData=image)
218 """Source of images for makeImageFromCamera"""
226 """Provide image of CCD to makeImageFromCamera
231 Detector ID to get image data for.
233 Type of image to construct.
235 Binsize to use to recompute dimensions.
240 Appropriately rotated, binned,
and transformed
241 image to be mosaicked.
243 Camera detector that the returned image data
246 detId = detector.getId()
249 dims = detector.getBBox().getDimensions() / binSize
250 image = imageFactory(*[int(xx)
for xx
in dims])
254 if hasattr(image,
"getMaskedImage"):
255 image = image.getMaskedImage()
256 if hasattr(image,
"getMask"):
257 mask = image.getMask()
258 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
259 image = image.clone()
260 image.getImage().getArray()[isBad] = self.
background
261 if hasattr(image,
"getImage"):
262 image = image.getImage()
267 return image, detector
afw::table::PointKey< int > dimensions
An immutable representation of a camera.
A representation of a detector in a mosaic camera.
A class to contain the data, WCS, and other information needed to describe an image of the sky.
A class to represent a 2-dimensional array of pixels.
__init__(self, exposures)
getCcdImage(self, detector, imageFactory, binSize)
makeCameraImage(self, inputExps, camera, binning)
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
std::shared_ptr< ImageT > rotateImageBy90(ImageT const &image, int nQuarter)
Rotate an image by an integral number of quarter turns.
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)