Skip to content

Commit 5c55814

Browse files
authored
Merge pull request #423 from lsst/tickets/DM-52071
DM-52071: Clear difference_image pixels with NO_DATA set
2 parents 44844d7 + 2a354c6 commit 5c55814

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

python/lsst/ip/diffim/detectAndMeasure.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,24 @@ def setDefaults(self):
348348
self.subtractInitialBackground.useApprox = False
349349
self.subtractInitialBackground.statisticsProperty = "MEDIAN"
350350
self.subtractInitialBackground.doFilterSuperPixels = True
351+
self.subtractInitialBackground.ignoredPixelMask = ["BAD",
352+
"EDGE",
353+
"DETECTED",
354+
"DETECTED_NEGATIVE",
355+
"NO_DATA",
356+
]
351357
# Use a larger binsize for the final background subtraction, to reduce
352358
# over-subtraction of bright objects.
353359
self.subtractFinalBackground.binSize = 40
354360
self.subtractFinalBackground.useApprox = False
355361
self.subtractFinalBackground.statisticsProperty = "MEDIAN"
356362
self.subtractFinalBackground.doFilterSuperPixels = True
363+
self.subtractFinalBackground.ignoredPixelMask = ["BAD",
364+
"EDGE",
365+
"DETECTED",
366+
"DETECTED_NEGATIVE",
367+
"NO_DATA",
368+
]
357369
# DiaSource Detection
358370
self.detection.thresholdPolarity = "both"
359371
self.detection.thresholdValue = 5.0
@@ -752,6 +764,12 @@ def processResults(self, science, matchedTemplate, difference, sources, idFactor
752764
if self.config.doForcedMeasurement:
753765
self.measureForcedSources(diaSources, science, difference.getWcs())
754766

767+
# Clear the image plane for regions with NO_DATA.
768+
# These regions are most often caused by insufficient template coverage.
769+
# Do this for the final difference image after detection and measurement
770+
# since the subtasks should all be configured to handle NO_DATA properly
771+
difference.image.array[difference.mask.array & difference.mask.getPlaneBitMask('NO_DATA') > 0] = 0
772+
755773
measurementResults.subtractedMeasuredExposure = difference
756774

757775
if self.config.doMaskStreaks and self.config.writeStreakInfo:

0 commit comments

Comments
 (0)