596 def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs):
597 """Warp coadds from multiple tracts to form a template for image diff.
599 Where the tracts overlap, the resulting template image is averaged.
600 The PSF on the template
is created by combining the CoaddPsf on each
601 template image into a meta-CoaddPsf.
606 Coadds to be mosaicked
608 Template Bounding box of the detector geometry onto which to
609 resample the coaddExposures
611 Template WCS onto which to resample the coaddExposures
612 dataIds : `list` of `lsst.daf.butler.DataCoordinate`
613 Record of the tract
and patch of each coaddExposure.
615 Any additional keyword parameters.
619 result : `lsst.pipe.base.Struct` containing
620 - ``outputExposure`` : a template coadd exposure assembled out of patches
623 tractsSchema = afwTable.ExposureTable.makeMinimalSchema()
624 tractKey = tractsSchema.addField(
'tract', type=np.int32, doc=
'Which tract')
625 patchKey = tractsSchema.addField(
'patch', type=np.int32, doc=
'Which patch')
626 weightKey = tractsSchema.addField(
'weight', type=float, doc=
'Weight for each tract, should be 1')
630 bbox.grow(self.config.templateBorderSize)
637 for coaddExposure, dataId
in zip(coaddExposures, dataIds):
640 warped = self.warper.
warpExposure(finalWcs, coaddExposure, maxBBox=finalBBox)
643 if not np.any(np.isfinite(warped.image.array)):
644 self.log.
info(
"No overlap for warped %s. Skipping" % dataId)
647 exp = afwImage.ExposureF(finalBBox, finalWcs)
648 exp.maskedImage.set(np.nan, afwImage.Mask.getPlaneBitMask(
"NO_DATA"), np.nan)
649 exp.maskedImage.assign(warped.maskedImage, warped.getBBox())
651 maskedImageList.append(exp.maskedImage)
653 record = tractsCatalog.addNew()
654 record.setPsf(coaddExposure.getPsf())
655 record.setWcs(coaddExposure.getWcs())
656 record.setPhotoCalib(coaddExposure.getPhotoCalib())
657 record.setBBox(coaddExposure.getBBox())
659 record.set(tractKey, dataId[
'tract'])
660 record.set(patchKey, dataId[
'patch'])
661 record.set(weightKey, 1.)
664 if nPatchesFound == 0:
665 raise pipeBase.NoWorkFound(
"No patches found to overlap detector")
670 statsCtrl.setNanSafe(
True)
671 statsCtrl.setWeighted(
True)
672 statsCtrl.setCalcErrorFromInputVariance(
True)
674 templateExposure = afwImage.ExposureF(finalBBox, finalWcs)
675 templateExposure.maskedImage.set(np.nan, afwImage.Mask.getPlaneBitMask(
"NO_DATA"), np.nan)
676 xy0 = templateExposure.getXY0()
679 weightList, clipped=0, maskMap=[])
680 templateExposure.maskedImage.setXY0(xy0)
684 boolmask = templateExposure.mask.array & templateExposure.mask.getPlaneBitMask(
'NO_DATA') == 0
686 centerCoord = afwGeom.SpanSet.fromMask(maskx, 1).computeCentroid()
688 ctrl = self.config.coaddPsf.makeControl()
689 coaddPsf = CoaddPsf(tractsCatalog, finalWcs, centerCoord, ctrl.warpingKernelName, ctrl.cacheSize)
691 raise RuntimeError(
"CoaddPsf could not be constructed")
693 templateExposure.setPsf(coaddPsf)
694 templateExposure.setFilter(coaddExposure.getFilter())
695 templateExposure.setPhotoCalib(coaddExposure.getPhotoCalib())
696 return pipeBase.Struct(outputExposure=templateExposure)
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Pass parameters to a Statistics object.
Custom catalog class for ExposureRecord/Table.
A floating-point coordinate rectangle geometry.
An integer coordinate rectangle.
std::shared_ptr< lsst::afw::image::Image< PixelT > > statisticsStack(std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT > > > &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
A function to compute some statistics of a stack of Images.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
int warpExposure(DestExposureT &destExposure, SrcExposureT const &srcExposure, WarpingControl const &control, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()))
Warp (remap) one exposure to another.
def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs)