Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ class AlardLuptonSubtractBaseConfig(lsst.pex.config.Config):
doc="Mask planes from the template to propagate to the image difference"
"with '_TEMPLATE' appended to the name."
)
preserveMaskPlanes = lsst.pex.config.ListField(
dtype=str,
default=("INJECTED", "INJECTED_CORE", "INJECTED_TEMPLATE", "INJECTED_CORE_TEMPLATE"),
doc="Mask planes to preserve without dilation when convolving the image.",
)
allowKernelSourceDetection = lsst.pex.config.Field(
dtype=bool,
default=False,
Expand Down Expand Up @@ -899,9 +904,29 @@ def _convolveExposure(self, exposure, kernel, convolutionControl,
nInterp = _interpolateImage(convolvedExposure.maskedImage,
self.config.badMaskPlanes)
self.metadata["nInterpolated"] = nInterp

# Snapshot the footprints of mask planes that must not be dilated by
# the convolution.
preservePlanes = [mp for mp in self.config.preserveMaskPlanes
if mp in convolvedExposure.mask.getMaskPlaneDict()]
maskResetDict = {
mp: (convolvedExposure.mask.array
& convolvedExposure.mask.getPlaneBitMask(mp)) > 0
for mp in preservePlanes
}

convolvedImage = lsst.afw.image.MaskedImageF(convolvedExposure.getBBox())
lsst.afw.math.convolve(convolvedImage, convolvedExposure.maskedImage, kernel, convolutionControl)
convolvedExposure.setMaskedImage(convolvedImage)

# Undo the convolution's dilation of the preserved planes: clear the
# dilated bits, then restore each mask plane for the pixels that were
# previously set.
self._clearMask(convolvedExposure.mask, clearMaskPlanes=preservePlanes)
for maskPlane, maskSetPixels in maskResetDict.items():
bit = convolvedExposure.mask.getPlaneBitMask(maskPlane)
convolvedExposure.mask.array[maskSetPixels] |= bit

if bbox is None:
return convolvedExposure
else:
Expand Down
Loading