Skip to content

Commit

Permalink
Extend template mask check to neighboring pixels
Browse files Browse the repository at this point in the history
Exclude sources from being used for PSF matching if any of the 3x3 central pixels are masked.
  • Loading branch information
isullivan committed Sep 18, 2024
1 parent eed2622 commit 0b9d46f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ def _sourceSelector(self, sources, mask):
return selectSources

@staticmethod
def _checkMask(mask, sources, excludeMaskPlanes):
"""Exclude sources that are located on masked pixels.
def _checkMask(mask, sources, excludeMaskPlanes, checkAdjacent=True):
"""Exclude sources that are located on or adjacent to masked pixels.
Parameters
----------
Expand All @@ -842,11 +842,18 @@ def _checkMask(mask, sources, excludeMaskPlanes):

excludePixelMask = mask.getPlaneBitMask(setExcludeMaskPlanes)

xv = np.rint(sources.getX() - mask.getX0())
yv = np.rint(sources.getY() - mask.getY0())
xv = (np.rint(sources.getX() - mask.getX0())).astype(int)
yv = (np.rint(sources.getY() - mask.getY0())).astype(int)

mv = mask.array[yv.astype(int), xv.astype(int)]
flags = np.bitwise_and(mv, excludePixelMask) == 0
flags = np.ones(len(sources), dtype=bool)
if checkAdjacent:
pixRange = (0, -1, 1)
else:
pixRange = (0,)
for j in pixRange:
for i in pixRange:
mv = mask.array[yv + j, xv + i]
flags *= np.bitwise_and(mv, excludePixelMask) == 0
return flags

def _prepareInputs(self, template, science, visitSummary=None):
Expand Down

0 comments on commit 0b9d46f

Please sign in to comment.