Skip to content

Commit

Permalink
To be rebased.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Jan 24, 2020
1 parent 48b259f commit 5f17833
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 46 deletions.
14 changes: 5 additions & 9 deletions python/lsst/ip/isr/isrFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ def makeThresholdMask(maskedImage, threshold, growFootprints=1, maskName='SAT'):


def growMasks(mask, radius=0, maskNameList=['BAD'], maskValue="BAD"):
"""Grow a mask by an amount and add to the BAD plane.
"""Grow a mask by an amount and add to the requested plane.
Parameters
----------
mask : `lsst.afw.image.Mask`
Mask image to process.
radius : scalar
Amount to grow the mask.
maskNameList : `list` [`str`]
List of mask names that should be grown.
maskNameList : `str` or `list` [`str`]
Mask names that should be grown.
maskValue : `str`
Mask plane to assign the newly masked pixels to.
"""
Expand Down Expand Up @@ -175,13 +175,9 @@ def interpolateFromMask(maskedImage, fwhm, growSaturatedFootprints=1,
mask = maskedImage.getMask()

if growSaturatedFootprints > 0 and "SAT" in maskNameList:
# If we are interpolating over an area larger than the original masked region, we need
# to expand the original mask bit to the full area to explain why we interpolated there.
growMasks(mask, radius=growSaturatedFootprints, maskNameList=['SAT'], maskValue="SAT")
# thresh = afwDetection.Threshold(mask.getPlaneBitMask("SAT"), afwDetection.Threshold.BITMASK)
# fpSet = afwDetection.FootprintSet(mask, thresh)
# # If we are interpolating over an area larger than the original masked region, we need
# # to expand the original mask bit to the full area to explain why we interpolated there.
# fpSet = afwDetection.FootprintSet(fpSet, rGrow=growSaturatedFootprints, isotropic=False)
# fpSet.setMask(mask, "SAT")

thresh = afwDetection.Threshold(mask.getPlaneBitMask(maskNameList), afwDetection.Threshold.BITMASK)
fpSet = afwDetection.FootprintSet(mask, thresh)
Expand Down
37 changes: 0 additions & 37 deletions python/lsst/ip/isr/isrTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2141,43 +2141,6 @@ def maskEdges(self, exposure, numEdgePixels=0, maskPlane="SUSPECT"):
maskBitMask
)

def maskGrowTophat(self, exposure, boxRadius=0, boxThreshold=0.25, maskPlane="BAD", maskLabel="BAD"):
"""Mask regions around large masked regions.
Parameters
----------
exposure: `lsst.afw.image.Exposure`
Exposure to process.
boxRadius : `int`, optional
Half-size of the box to use to grow masks.
boxThreshold : `float`, optional
Fraction of box footprint pixels that must be masked on
the input to mask on the output.
maskPlane : `str`, optional
Mask plane name to use for input masking.
maskLabel : `str`, optional
Mask plan to mark grown regions.
"""
if boxRadius > 0 and boxThreshold > 0.0:
maskedImage = exposure.getMaskedImage()
maskBitMask = maskedImage.getMask().getPlaneBitMask(maskPlane)

thresholdImage = afwImage.MaskedImageF(maskedImage.getDimensions())
thresholdImage.getImage().getArray()[:, :] = maskedImage.getMask().getArray()[:, :] & maskBitMask

kernelImage = afwImage.ImageD(2 * boxRadius + 1, 2 * boxRadius + 1, 1)

convControl = afwMath.ConvolutionControl(doNormalize=False,
doCopyEdge=True,
maxInterpolationDistance=0)
convolvedImage = afwImage.MaskedImageF(maskedImage.getDimensions())
afwMath.convolve(convolvedImage, thresholdImage, afwMath.FixedKernel(kernelImage), convControl)

isrFunctions.makeThresholdMask(convolvedImage,
boxThreshold * 4 * boxRadius * boxRadius,
growFootprints=0, maskName=maskLabel)
maskedImage.getMask().getArray()[:, :] |= convolvedImage.getMask().getArray()[:, :]

def maskAndInterpolateDefects(self, exposure, defectBaseList):
"""Mask and interpolate defects using mask plane "BAD", in place.
Expand Down

0 comments on commit 5f17833

Please sign in to comment.