22 from __future__
import absolute_import, division, print_function
25 from builtins
import object
31 from .
import addToCoadd, setCoaddEdgeBits
39 badMaskPlanes = pexConfig.ListField(
41 doc=
"mask planes that, if set, the associated pixel should not be included in the coadd",
42 default=(
"NO_DATA",
"SAT"),
47 """Coadd by weighted addition 49 This class may be subclassed to implement other coadd techniques. 50 Typically this is done by overriding addExposure. 52 ConfigClass = CoaddConfig
54 def __init__(self, bbox, wcs, badMaskPlanes, logName="coadd.utils.Coadd"):
57 @param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I): 58 coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin() 59 @param[in] wcs: WCS of coadd exposure (lsst.afw.math.Wcs) 60 @param[in] badMaskPlanes: mask planes to pay attention to when rejecting masked pixels. 61 Specify as a collection of names. 62 badMaskPlanes should always include "NO_DATA". 63 @param[in] logName: name by which messages are logged 65 self.
_log = Log.getLogger(logName)
68 self.
_badPixelMask = afwImage.Mask.getPlaneBitMask(badMaskPlanes)
69 self.
_coadd = afwImage.ExposureF(bbox, wcs)
79 def fromConfig(cls, bbox, wcs, config, logName="coadd.utils.Coadd"):
82 @param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I): 83 coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin() 84 @param[in] wcs: WCS of coadd exposure (lsst.afw.math.Wcs) 85 @param[in] config: coadd config; an instance of CoaddConfig 86 @param[in] logName: name by which messages are logged 91 badMaskPlanes=config.badMaskPlanes,
96 """Add an Exposure to the coadd 98 @param[in] exposure: Exposure to add to coadd; this should be: 99 - background-subtracted or background-matched to the other images being coadded 100 - psf-matched to the desired PSF model (optional) 101 - warped to match the coadd 102 - photometrically scaled to the desired flux magnitude 103 @param[in] weightFactor: extra weight factor for this exposure 106 - overlapBBox: region of overlap between exposure and coadd in parent coordinates (afwGeom.Box2I) 107 - weight: weight with which exposure was added to coadd; weight = weightFactor / clipped mean variance 109 Subclasses may override to preprocess the exposure or change the way it is added to the coadd. 111 maskedImage = exposure.getMaskedImage()
114 statObj = afwMath.makeStatistics(maskedImage.getVariance(), maskedImage.getMask(),
116 meanVar = statObj.getResult(afwMath.MEANCLIP)[0]
117 weight = weightFactor / float(meanVar)
118 if math.isnan(weight):
119 raise RuntimeError(
"Weight is NaN (weightFactor=%s; mean variance=%s)" % (weightFactor, meanVar))
122 filter = exposure.getFilter()
123 self.
_filterDict.setdefault(filter.getName(), filter)
125 self.
_log.info(
"Add exposure to coadd with weight=%0.3g", weight)
130 return overlapBBox, weight
133 """Get the coadd exposure for all exposures you have coadded so far 135 If all exposures in this coadd have the same-named filter then that filter is set in the coadd. 136 Otherwise the coadd will have the default unknown filter. 138 @warning: the Calib is not be set. 141 coaddMaskedImage = self.
_coadd.getMaskedImage()
142 scaledMaskedImage = coaddMaskedImage.Factory(coaddMaskedImage,
True)
152 scaledExposure.setFilter(list(self.
_filterDict.values())[0])
153 return scaledExposure
156 """Return a collection of all the filters seen so far in in addExposure 161 """Return the bad pixel mask 166 """Return the bounding box of the coadd 171 """Return the wcs of the coadd 176 """Return the weight map for all exposures you have coadded so far 178 The weight map is a float Image of the same dimensions as the coadd; the value of each pixel 179 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< Wcs const > wcs=std::shared_ptr< Wcs 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")