Skip to content

Commit

Permalink
Move prepareStats to AssembleCoaddTask
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Feb 14, 2018
1 parent 84d03d9 commit 3cb5500
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
41 changes: 26 additions & 15 deletions python/lsst/pipe/tasks/assembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,31 @@ def prepareInputs(self, refList):
return pipeBase.Struct(tempExpRefList=tempExpRefList, weightList=weightList,
imageScalerList=imageScalerList)

def prepareStats(self, skyInfo, mask=None):
"""!
\brief Prepare the statistics for coadding images.
\param[in] skyInfo: Patch geometry information, from getSkyInfo
\param[in] mask: Mask to ignore when coadding
\return Tuple:
- statsCtrl: Statistics control object for coadd
- statsFlags: afwMath.Property object for statistic for coadd
"""
if mask is None:
mask = self.getBadPixelMask()
statsCtrl = afwMath.StatisticsControl()
statsCtrl.setNumSigmaClip(self.config.sigmaClip)
statsCtrl.setNumIter(self.config.clipIter)
statsCtrl.setAndMask(mask)
statsCtrl.setNanSafe(True)
statsCtrl.setWeighted(True)
statsCtrl.setCalcErrorFromInputVariance(self.config.calcErrorFromInputVariance)
for plane, threshold in self.config.maskPropagationThresholds.items():
bit = afwImage.Mask.getMaskPlane(plane)
statsCtrl.setMaskPropagationThreshold(bit, threshold)
statsFlags = afwMath.stringToStatisticsProperty(self.config.statistic)
return (statsCtrl, statsFlags)

def assemble(self, skyInfo, tempExpRefList, imageScalerList, weightList,
altMaskList=None, mask=None, supplementaryData=None):
"""!
Expand All @@ -484,21 +509,7 @@ def assemble(self, skyInfo, tempExpRefList, imageScalerList, weightList,
"""
tempExpName = self.getTempExpDatasetName(self.warpType)
self.log.info("Assembling %s %s", len(tempExpRefList), tempExpName)
if mask is None:
mask = self.getBadPixelMask()

statsCtrl = afwMath.StatisticsControl()
statsCtrl.setNumSigmaClip(self.config.sigmaClip)
statsCtrl.setNumIter(self.config.clipIter)
statsCtrl.setAndMask(mask)
statsCtrl.setNanSafe(True)
statsCtrl.setWeighted(True)
statsCtrl.setCalcErrorFromInputVariance(self.config.calcErrorFromInputVariance)
for plane, threshold in self.config.maskPropagationThresholds.items():
bit = afwImage.Mask.getMaskPlane(plane)
statsCtrl.setMaskPropagationThreshold(bit, threshold)

statsFlags = afwMath.stringToStatisticsProperty(self.config.statistic)
statsCtrl, statsFlags = self.prepareStats(skyInfo, mask=mask)

if altMaskList is None:
altMaskList = [None]*len(tempExpRefList)
Expand Down
19 changes: 0 additions & 19 deletions python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,6 @@ def assemble(self, skyInfo, tempExpRefList, imageScalerList, weightList,
coaddExposure = self.stackCoadd(dcrCoadds)
return pipeBase.Struct(coaddExposure=coaddExposure, nImage=None, dcrCoadds=dcrCoadds)

def prepareStats(self, skyInfo, mask=None):
if mask is None:
mask = self.getBadPixelMask()

statsCtrl = afwMath.StatisticsControl()
statsCtrl.setNumSigmaClip(self.config.sigmaClip)
statsCtrl.setNumIter(self.config.clipIter)
statsCtrl.setAndMask(mask)
statsCtrl.setNanSafe(True)
statsCtrl.setWeighted(True)
statsCtrl.setCalcErrorFromInputVariance(True)
for plane, threshold in self.config.maskPropagationThresholds.items():
bit = afwImage.Mask.getMaskPlane(plane)
statsCtrl.setMaskPropagationThreshold(bit, threshold)

statsFlags = afwMath.stringToStatisticsProperty(self.config.statistic)

return (statsCtrl, statsFlags)

def dcrAssembleSubregion(self, dcrModels, bbox, tempExpRefList, imageScalerList, weightList,
altMaskList, statsFlags, statsCtrl, convergenceMetric):
"""!
Expand Down

0 comments on commit 3cb5500

Please sign in to comment.