Skip to content

Commit

Permalink
Rename DcrModel config options, and raise for invalid values.
Browse files Browse the repository at this point in the history
  • Loading branch information
isullivan committed Oct 25, 2018
1 parent 55d4575 commit c0de044
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ class DcrAssembleCoaddConfig(CompareWarpAssembleCoaddConfig):
doc="Weight exposures by airmass? Useful if there are relatively few high-airmass observations.",
default=True,
)
modelWidth = pexConfig.Field(
dtype=int,
doc="Width of the region around detected sources to include in the DcrModel."
"Set to a negative number to disable, which will include all pixels.",
modelWeightsWidth = pexConfig.Field(
dtype=float,
doc="Width of the region around detected sources to include in the DcrModel.",
default=3,
)
useModelWeights = pexConfig.Field(
dtype=bool,
doc="Width of the region around detected sources to include in the DcrModel.",
default=True,
)
splitSubfilters = pexConfig.Field(
dtype=bool,
doc="Calculate DCR for two evenly-spaced wavelengths in each subfilter."
Expand Down Expand Up @@ -354,7 +358,10 @@ def run(self, skyInfo, tempExpRefList, imageScalerList, weightList,
for subBBox in self._subBBoxIter(skyInfo.bbox, subregionSize):
modelIter = 0
self.log.info("Computing coadd over %s", subBBox)
modelWeights = self.calculateModelWeights(templateCoadd.maskedImage[subBBox])
if self.config.useModelWeights:
modelWeights = self.calculateModelWeights(templateCoadd.maskedImage[subBBox])
else:
return 1.
convergenceMetric = self.calculateConvergence(dcrModels, subBBox, tempExpRefList,
imageScalerList, weightList, spanSetMaskList,
stats.ctrl)
Expand Down Expand Up @@ -487,7 +494,7 @@ def dcrAssembleSubregion(self, dcrModels, bbox, tempExpRefList, imageScalerList,
Relative weight to give the new solution when updating the model.
modelWeights : `numpy.ndarray` or `float`
A 2D array of weight values that tapers smoothly to zero away from detected sources.
Or a placeholder value of 1.0 if ``self.config.modelWidth`` is set to a negative number.
Set to a placeholder value of 1.0 if ``self.config.useModelWeights`` is False.
"""
bboxGrow = afwGeom.Box2I(bbox)
bboxGrow.grow(self.bufferSize)
Expand Down Expand Up @@ -796,14 +803,19 @@ def calculateModelWeights(self, maskedImage):
-------
weights : `numpy.ndarray` or `float`
A 2D array of weight values that tapers smoothly to zero away from detected sources.
Or a placeholder value of 1.0 if ``self.config.modelWidth`` is set to a negative number.
Set to a placeholder value of 1.0 if ``self.config.useModelWeights`` is False.
Raises
------
ValueError
If ``useModelWeights`` is set and ``modelWeightsWidth`` is negative.
"""
if self.config.modelWidth < 0:
return 1.
if self.config.modelWeightsWidth < 0:
raise ValueError("modelWeightsWidth must not be negative if useModelWeights is set")
convergeMask = maskedImage.mask.getPlaneBitMask(self.config.convergenceMaskPlanes)
convergeMaskPixels = maskedImage.mask.array & convergeMask > 0
weights = np.zeros_like(maskedImage.image.array)
weights[convergeMaskPixels] = 1.
weights = ndimage.filters.gaussian_filter(weights, self.config.modelWidth)
weights = ndimage.filters.gaussian_filter(weights, self.config.modelWeightsWidth)
weights /= np.max(weights)
return weights

0 comments on commit c0de044

Please sign in to comment.