From d02eb5899f614269a0047a031492fc7df2c1472a Mon Sep 17 00:00:00 2001 From: Ian Sullivan Date: Thu, 6 Feb 2025 16:37:51 -0800 Subject: [PATCH] Normalize footprint metrics by the size of the footprint Also set the "good" subtraction test to have better seeing in the template than the science image, so that template convolution is the right choice. --- python/lsst/ip/diffim/subtractImages.py | 6 +++--- tests/test_subtractTask.py | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/python/lsst/ip/diffim/subtractImages.py b/python/lsst/ip/diffim/subtractImages.py index e02c38b69..f1ab71e54 100644 --- a/python/lsst/ip/diffim/subtractImages.py +++ b/python/lsst/ip/diffim/subtractImages.py @@ -520,9 +520,9 @@ def footprint_mean(sources, sky=0): footprint = record.getFootprint() heavy = lsst.afw.detection.makeHeavyFootprint(footprint, science.maskedImage) heavy_diff = lsst.afw.detection.makeHeavyFootprint(footprint, difference.maskedImage) - science_footprints[i] = heavy.getImageArray().sum() - difference_footprints[i] = abs(heavy_diff.getImageArray()).sum() - ratio[i] = (difference_footprints[i] - sky) / science_footprints[i] + science_footprints[i] = abs(heavy.getImageArray()).mean() + difference_footprints[i] = abs(heavy_diff.getImageArray()).mean() + ratio[i] = abs((difference_footprints[i] - sky)/science_footprints[i]) return science_footprints, difference_footprints, ratio sky = stars["sky_source"] diff --git a/tests/test_subtractTask.py b/tests/test_subtractTask.py index 17382f11a..226274117 100644 --- a/tests/test_subtractTask.py +++ b/tests/test_subtractTask.py @@ -891,9 +891,11 @@ def test_metadata_metrics(self): that the difference image limiting magnitude is calculated correctly, both with a "good" and "bad" seeing template. """ - science, sources = makeTestImage(psfSize=1.8, doApplyCalibration=True) - template_good, _ = makeTestImage(psfSize=2.4, doApplyCalibration=True) - template_bad, _ = makeTestImage(psfSize=9.5, doApplyCalibration=True) + science, sources = makeTestImage(psfSize=2.8, noiseLevel=1) + template_good, _ = makeTestImage(psfSize=2.4, doApplyCalibration=True, noiseLevel=0.25, + templateBorderSize=20) + template_bad, _ = makeTestImage(psfSize=9.5, doApplyCalibration=True, noiseLevel=0.25, + templateBorderSize=20) # Add a few sky objects; sky footprints are needed for some metrics. config = measAlg.SkyObjectsTask.ConfigClass() @@ -968,8 +970,8 @@ def test_metadata_metrics(self): self.assertIn('templateLimitingMagnitude', subtractTask_good.metadata) # The mean ratio metric should be much worse on the "bad" subtraction. - self.assertLess(subtractTask_good.metadata['differenceFootprintRatioMean'], 0.2) - self.assertGreater(subtractTask_bad.metadata['differenceFootprintRatioMean'], 1.0) + self.assertLess(subtractTask_good.metadata['differenceFootprintRatioMean'], 0.02) + self.assertGreater(subtractTask_bad.metadata['differenceFootprintRatioMean'], 0.25) class AlardLuptonPreconvolveSubtractTest(AlardLuptonSubtractTestBase, lsst.utils.tests.TestCase):