54 def run(self, exposures):
55 """Combine one or two snaps, returning the combined image.
59 exposures : `lsst.afw.image.Exposure` or `list` [`lsst.afw.image.Exposure`]
60 One or two exposures to combine as snaps.
64 result : `lsst.pipe.base.Struct`
65 Results as a struct with attributes:
68 Snap-combined exposure.
73 Raised if input argument does not contain either 1 or 2 exposures.
76 return pipeBase.Struct(exposure=exposures)
78 if isinstance(exposures, collections.abc.Sequence)
and not isinstance(exposures, str):
81 return pipeBase.Struct(exposure=exposures[0])
83 return self.
combine(exposures[0], exposures[1])
85 raise RuntimeError(f
"Can only process 1 or 2 snaps, not {n}.")
87 raise RuntimeError(
"`exposures` must be either an afw Exposure (single snap visit), or a "
88 "list/tuple of one or two of them.")
114 """Add two snap exposures together, returning a new exposure.
118 snap0 : `lsst.afw.image.Exposure`
120 snap1 : `lsst.afw.image.Exposure`
125 combined : `lsst.afw.image.Exposure`
128 combined = snap0.Factory(snap0,
True)
129 combined.maskedImage.set(0)
131 weights = combined.maskedImage.image.Factory(combined.maskedImage.getBBox())
133 bad_mask = afwImage.Mask.getPlaneBitMask(self.config.bad_mask_planes)
134 addToCoadd(combined.maskedImage, weights, snap0.maskedImage, bad_mask, weight)
135 addToCoadd(combined.maskedImage, weights, snap1.maskedImage, bad_mask, weight)
140 combined.maskedImage /= weights
141 setCoaddEdgeBits(combined.maskedImage.getMask(), weights)
143 combined.info.setVisitInfo(self.
_merge_visit_info(snap0.visitInfo, snap1.visitInfo))
148 """Merge the visitInfo values from the two exposures.
151 * id will be the id of snap 0.
152 * date will be the average of the dates.
153 * exposure time will be the sum of the times.
157 info0, info1 : `lsst.afw.image.VisitInfo`
162 info : `lsst.afw.image.VisitInfo`
166 time = info0.exposureTime + info1.exposureTime
167 date = (info0.date.get() + info1.date.get()) / 2.0
168 result = info0.copyWith(exposureTime=time,
169 date=dafBase.DateTime(date)