30 from .
import addToCoadd, setCoaddEdgeBits
36 badMaskPlanes = pexConfig.ListField(
38 doc=
"mask planes that, if set, the associated pixel should not be included in the coadd",
39 default=(
"NO_DATA",
"SAT"),
44 """Coadd by weighted addition 46 This class may be subclassed to implement other coadd techniques. 47 Typically this is done by overriding addExposure. 49 ConfigClass = CoaddConfig
51 def __init__(self, bbox, wcs, badMaskPlanes, logName="coadd.utils.Coadd"):
54 @param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I): 55 coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin() 56 @param[in] wcs: WCS of coadd exposure (lsst.afw.geom.SKyWcs) 57 @param[in] badMaskPlanes: mask planes to pay attention to when rejecting masked pixels. 58 Specify as a collection of names. 59 badMaskPlanes should always include "NO_DATA". 60 @param[in] logName: name by which messages are logged 62 self.
_log = Log.getLogger(logName)
65 self.
_badPixelMask = afwImage.Mask.getPlaneBitMask(badMaskPlanes)
66 self.
_coadd = afwImage.ExposureF(bbox, wcs)
76 def fromConfig(cls, bbox, wcs, config, logName="coadd.utils.Coadd"):
79 @param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I): 80 coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin() 81 @param[in] wcs: WCS of coadd exposure (lsst.afw.geom.SKyWcs) 82 @param[in] config: coadd config; an instance of CoaddConfig 83 @param[in] logName: name by which messages are logged 88 badMaskPlanes=config.badMaskPlanes,
93 """Add an Exposure to the coadd 95 @param[in] exposure: Exposure to add to coadd; this should be: 96 - background-subtracted or background-matched to the other images being coadded 97 - psf-matched to the desired PSF model (optional) 98 - warped to match the coadd 99 - photometrically scaled to the desired flux magnitude 100 @param[in] weightFactor: extra weight factor for this exposure 103 - overlapBBox: region of overlap between exposure and coadd in parent coordinates (afwGeom.Box2I) 104 - weight: weight with which exposure was added to coadd; weight = weightFactor / clipped mean variance 106 Subclasses may override to preprocess the exposure or change the way it is added to the coadd. 108 maskedImage = exposure.getMaskedImage()
111 statObj = afwMath.makeStatistics(maskedImage.getVariance(), maskedImage.getMask(),
113 meanVar = statObj.getResult(afwMath.MEANCLIP)[0]
114 weight = weightFactor / float(meanVar)
115 if math.isnan(weight):
116 raise RuntimeError(
"Weight is NaN (weightFactor=%s; mean variance=%s)" % (weightFactor, meanVar))
119 filter = exposure.getFilter()
120 self.
_filterDict.setdefault(filter.getName(), filter)
122 self.
_log.info(
"Add exposure to coadd with weight=%0.3g", weight)
127 return overlapBBox, weight
130 """Get the coadd exposure for all exposures you have coadded so far 132 If all exposures in this coadd have the same-named filter then that filter is set in the coadd. 133 Otherwise the coadd will have the default unknown filter. 135 @warning: the Calib is not be set. 138 coaddMaskedImage = self.
_coadd.getMaskedImage()
139 scaledMaskedImage = coaddMaskedImage.Factory(coaddMaskedImage,
True)
149 scaledExposure.setFilter(list(self.
_filterDict.values())[0])
150 return scaledExposure
153 """Return a collection of all the filters seen so far in in addExposure 158 """Return the bad pixel mask 163 """Return the bounding box of the coadd 168 """Return the wcs of the coadd 173 """Return the weight map for all exposures you have coadded so far 175 The weight map is a float Image of the same dimensions as the coadd; the value of each pixel 176 is the sum of the weights of all exposures that contributed to that pixel.
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 >())
def addExposure(self, exposure, weightFactor=1.0)
def getBadPixelMask(self)
def fromConfig(cls, bbox, wcs, config, logName="coadd.utils.Coadd")
def __init__(self, bbox, wcs, badMaskPlanes, logName="coadd.utils.Coadd")