25 import 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",
"calibration_label"),
50 outputExp = cT.Output(
52 doc=
"Output binned image.",
53 storageClass=
"ExposureF",
54 dimensions=(
"instrument",
"detector"),
59 pipelineConnections=VisualizeBinExpConnections):
60 """Configuration for focal plane visualization.
62 binning = pexConfig.Field(
65 doc=
"Binning factor to apply to each input exposure's image data.",
67 detectorKeyword = pexConfig.Field(
70 doc=
"Metadata keyword to use to find detector if not available from input.",
75 pipeBase.CmdLineTask):
76 """Bin the detectors of an exposure.
78 The outputs of this task should be passed to
79 VisualizeMosaicExpTask to be mosaicked into a full focal plane
82 ConfigClass = VisualizeBinExpConfig
83 _DefaultName =
'VisualizeBinExp'
85 def run(self, inputExp, camera):
86 """Bin input image, attach associated detector.
90 inputExp : `lsst.afw.image.Exposure`
91 Input exposure data to bin.
92 camera : `lsst.afw.cameraGeom.Camera`
93 Input camera to use for mosaic geometry.
97 output : `lsst.pipe.base.Struct`
98 Results struct with attribute:
101 Binned version of input image (`lsst.afw.image.Exposure`).
103 if inputExp.getDetector()
is None:
104 detectorId = inputExp.getMetadata().get(self.config.detectorKeyword)
105 if detectorId
is not None:
106 inputExp.setDetector(camera[detectorId])
108 binned = inputExp.getMaskedImage()
112 outputExp.setInfo(inputExp.getInfo())
114 return pipeBase.Struct(
120 dimensions=(
"instrument", )):
121 inputExps = cT.Input(
123 doc=
"Input binned images mosaic.",
124 storageClass=
"ExposureF",
125 dimensions=(
"instrument",
"detector"),
128 camera = cT.PrerequisiteInput(
130 doc=
"Input camera to use for mosaic geometry.",
131 storageClass=
"Camera",
132 dimensions=(
"instrument",
"calibration_label"),
135 outputData = cT.Output(
136 name=
"calexpFocalPlane",
137 doc=
"Output binned mosaicked frame.",
138 storageClass=
"ImageF",
139 dimensions=(
"instrument", ),
144 pipelineConnections=VisualizeMosaicExpConnections):
145 """Configuration for focal plane visualization.
147 binning = pexConfig.Field(
150 doc=
"Binning factor previously applied to input exposures.",
155 pipeBase.CmdLineTask):
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.
163 ConfigClass = VisualizeMosaicExpConfig
164 _DefaultName =
'VisualizeMosaicExp'
167 """Make an image of an entire focal plane.
171 exposures: `dict` [`int`, `lsst.afw.image.Exposure`]
172 CCD exposures, binned by `binning`. The keys are the
173 detectorIDs, with the values the binned image exposure.
177 image : `lsst.afw.image.Image`
178 Image mosaicked from the individual binned images for each
181 image = afwUtils.makeImageFromCamera(
184 imageFactory=afwImage.ImageF,
189 def run(self, inputExps, camera):
190 """Mosaic inputs together to create focal plane image.
194 inputExp : `list` [`lsst.afw.image.Exposure`]
195 Input exposure data to bin.
196 camera : `lsst.afw.cameraGeom.Camera`
197 Input camera to use for mosaic geometry.
201 output : `lsst.pipe.base.Struct`
202 Results struct with attribute:
205 Binned version of input image (`lsst.afw.image.Exposure`).
207 expDict = {exp.getDetector().getId(): exp
for exp
in inputExps}
208 image = self.
makeCameraImagemakeCameraImage(expDict, camera, self.config.binning)
210 return pipeBase.Struct(
216 """Source of images for makeImageFromCamera"""
223 """Provide image of CCD to makeImageFromCamera
228 Detector ID to get image data for.
229 imageFactory : `lsst.afw.image.Image`
230 Type of image to construct.
232 Binsize to use to recompute dimensions.
236 image : `lsst.afw.image.Image`
237 Appropriately rotated, binned, and transformed
238 image to be mosaicked.
239 detector : `lsst.afw.cameraGeom.Detector`
240 Camera detector that the returned image data
243 detId = detector.getId()
246 dims = detector.getBBox().getDimensions()/binSize
247 image = imageFactory(*[int(xx)
for xx
in dims])
250 image = self.
exposuresexposures[detector.getId()]
251 if hasattr(image,
"getMaskedImage"):
252 image = image.getMaskedImage()
253 if hasattr(image,
"getMask"):
254 mask = image.getMask()
255 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
256 image = image.clone()
257 image.getImage().getArray()[isBad] = self.
backgroundbackground
258 if hasattr(image,
"getImage"):
259 image = image.getImage()
264 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)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
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)