130 """Create a tempExp from inputs
132 We iterate over the multiple calexps in a single exposure to construct
133 the warp ("tempExp") of that exposure to the supplied tract/patch.
135 Pixels that receive no pixels are set to NAN; this is not correct
136 (violates LSST algorithms group policy), but will be fixed up by
137 interpolating after the coaddition.
139 @param calexpRefList: List of data references for calexps that (may)
140 overlap the patch of interest
141 @param skyInfo: Struct from CoaddBaseTask.getSkyInfo() with geometric
142 information about the patch
143 @param visitId: integer identifier for visit, for the table that will
145 @return warped exposure, or None if no pixels overlap
147 inputRecorder = self.inputRecorder.makeCoaddTempExpRecorder(visitId)
148 coaddTempExp = afwImage.ExposureF(skyInfo.bbox, skyInfo.wcs)
149 coaddTempExp.getMaskedImage().set(numpy.nan, afwImage.MaskU.getPlaneBitMask(
"NO_DATA"), numpy.inf)
151 didSetMetadata =
False
152 modelPsf = self.config.modelPsf.apply()
if self.config.doPsfMatch
else None
153 for calExpInd, calExpRef
in enumerate(calexpRefList):
154 self.log.info(
"Processing calexp %d of %d for this tempExp: id=%s" %
155 (calExpInd+1, len(calexpRefList), calExpRef.dataId))
157 ccdId = calExpRef.get(
"ccdExposureId", immediate=
True)
165 calExpRef = calExpRef.butlerSubset.butler.dataRef(
"calexp", dataId=calExpRef.dataId,
166 tract=skyInfo.tractInfo.getId())
167 calExp = self.getCalExp(calExpRef, bgSubtracted=self.config.bgSubtracted)
168 exposure = self.warpAndPsfMatch.run(calExp, modelPsf=modelPsf, wcs=skyInfo.wcs,
169 maxBBox=skyInfo.bbox).exposure
171 mimg = exposure.getMaskedImage()
172 mimg *= (coaddTempExp.getCalib().getFluxMag0()[0] / exposure.getCalib().getFluxMag0()[0])
175 coaddTempExp.getMaskedImage(), exposure.getMaskedImage(), self.getBadPixelMask())
176 totGoodPix += numGoodPix
177 self.log.logdebug(
"Calexp %s has %d good pixels in this patch (%.1f%%)" %
178 (calExpRef.dataId, numGoodPix, 100.0*numGoodPix/skyInfo.bbox.getArea()))
179 if numGoodPix > 0
and not didSetMetadata:
180 coaddTempExp.setCalib(exposure.getCalib())
181 coaddTempExp.setFilter(exposure.getFilter())
182 didSetMetadata =
True
184 self.log.warn(
"Error processing calexp %s; skipping it: %s" % (calExpRef.dataId, e))
186 inputRecorder.addCalExp(calExp, ccdId, numGoodPix)
188 inputRecorder.finish(coaddTempExp, totGoodPix)
189 if totGoodPix > 0
and didSetMetadata:
190 coaddTempExp.setPsf(modelPsf
if self.config.doPsfMatch
else
191 CoaddPsf(inputRecorder.coaddInputs.ccds, skyInfo.wcs))
193 self.log.info(
"coaddTempExp has %d good pixels (%.1f%%)" %
194 (totGoodPix, 100.0*totGoodPix/skyInfo.bbox.getArea()))
195 return coaddTempExp
if totGoodPix > 0
and didSetMetadata
else None
CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
int copyGoodPixels(lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > &destImage, lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const &srcImage, lsst::afw::image::MaskPixel const badPixelMask)
copy good pixels from one masked image to another