Skip to content

Commit 1d4010f

Browse files
committed
Add simple test for bad NO_DATA region
1 parent d2ec5ff commit 1d4010f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_detection.py

+24
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,30 @@ def checkExposure(original, doTempLocalBackground, doTempWideBackground):
216216
checkExposure(original, False, True)
217217
checkExposure(original, True, True)
218218

219+
def test_removeBadPixels(self):
220+
"""Test that if we set a NO_DATA region on top of a source,
221+
One fewer sources is detected than when we don't do that."""
222+
badMaskPlanes = ["NO_DATA", ]
223+
exposure_regular, schema, numX, numY, starSigma = self._create_exposure()
224+
exposure_removed = exposure_regular.clone()
225+
226+
# Define a region on one test exposure we will set to NO_DATA, blocking out one source
227+
region = lsst.geom.Box2I(exposure_removed.getXY0(), lsst.geom.Extent2I(25, 35))
228+
exposure_removed[region].mask.array |= exposure_removed.mask.getPlaneBitMask(badMaskPlanes)
229+
230+
config = SourceDetectionTask.ConfigClass()
231+
config.reEstimateBackground = False
232+
config.thresholdType = "stdev"
233+
config.excludeMaskPlanes = badMaskPlanes
234+
task = SourceDetectionTask(config=config, schema=schema)
235+
236+
# The regular test exposure finds 25 sources
237+
self._check_detectFootprints(exposure_regular, numX, numY, starSigma, task, config, doSmooth=True)
238+
239+
# Modify numx and numy, which check_detectFootprints multiplies, to yield 24 instead of 25
240+
self.assertEqual(numX, numY)
241+
self._check_detectFootprints(exposure_removed, numX-1, numY+1, starSigma, task, config, doSmooth=True)
242+
219243

220244
class TestMemory(lsst.utils.tests.MemoryTestCase):
221245
pass

0 commit comments

Comments
 (0)