From 44079dcd4ff385e80cb6d5955fa95ae74b48c7fb Mon Sep 17 00:00:00 2001 From: Lauren MacArthur Date: Tue, 3 Jan 2023 21:04:51 -0800 Subject: [PATCH] Test maxPsfTraceRadiusDelta fail for coaddition In order to trigger the deselection of a detector for inclusion in a coadd, it must fail the config.makeWarp.select.maxPsfTraceRadiusDelta threshold check. None of the detecotrs in this repo currently fail to pass with the current default of 0.7 pixels. Overridding that to 0.2 here forces a single failure, thus exercising this selection criterion. A unittest is also added to check that the failed dataId is not listed in the coaddInputs() list of the coadd. --- bin/pipeline.sh | 1 + python/lsst/ci/hsc/gen3/data.py | 8 ++++ tests/test_psfModelTraceFail.py | 74 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/test_psfModelTraceFail.py diff --git a/bin/pipeline.sh b/bin/pipeline.sh index 1835c40..c68d588 100755 --- a/bin/pipeline.sh +++ b/bin/pipeline.sh @@ -64,6 +64,7 @@ pipetask --long-log --log-level="$loglevel" qgraph \ -b "$repo"/butler.yaml \ --input "$INPUTCOLL" --output "$COLLECTION" \ -p "$DRP_PIPE_DIR/pipelines/HSC/DRP-ci_hsc.yaml" \ + -c makeWarp:select.maxPsfTraceRadiusDelta=0.2 \ --save-qgraph "$QGRAPH_FILE" pipetask --long-log --log-level="$loglevel" run \ diff --git a/python/lsst/ci/hsc/gen3/data.py b/python/lsst/ci/hsc/gen3/data.py index b51a78e..1facedc 100644 --- a/python/lsst/ci/hsc/gen3/data.py +++ b/python/lsst/ci/hsc/gen3/data.py @@ -53,3 +53,11 @@ {'visit': 903988, 'detector': 23, 'physical_filter': 'HSC-I'}, {'visit': 903988, 'detector': 24, 'physical_filter': 'HSC-I'}, ] +# The following lists the dataIds that fail the PSF Model robustness check +# with the config override makeWarp.select.maxPsfTraceRadiusDelta=0.2 set. +# This list is sensitive to (at least) the PSF algorithms and dataset under +# consideration, so may require updating if either of those change in the +# context of this repository. +PSF_MODEL_ROBUSTNESS_FAILURE_DATA_IDS = [ + {'visit': 903334, 'detector': 22, 'physical_filter': 'HSC-R'}, +] diff --git a/tests/test_psfModelTraceFail.py b/tests/test_psfModelTraceFail.py new file mode 100644 index 0000000..ac05798 --- /dev/null +++ b/tests/test_psfModelTraceFail.py @@ -0,0 +1,74 @@ +# This file is part of ci_hsc_gen3. +# +# Developed for the LSST Data Management System. +# This product includes software developed by the LSST Project +# (https://www.lsst.org). +# See the COPYRIGHT file at the top-level directory of this distribution +# for details of code ownership. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import unittest + +import lsst.utils.tests + +from lsst.ci.hsc.gen3 import PSF_MODEL_ROBUSTNESS_FAILURE_DATA_IDS +from lsst.daf.butler import Butler, DataCoordinate +from lsst.utils import getPackageDir + + +class TestPsfModelTraceRadiusFails(lsst.utils.tests.TestCase): + """Test the deselection of detectors based on PSF model robustness check. + """ + def setUp(self): + self.butler = Butler(os.path.join(getPackageDir("ci_hsc_gen3"), "DATA"), writeable=False, + collections=["HSC/calib/2013-06-17", "HSC/runs/ci_hsc"]) + self.skymap = "discrete/ci_hsc" + self.tract = 0 + self.patch = 69 + self.band = "r" + self.coaddDataId = DataCoordinate.standardize( + instrument="HSC", skymap=self.skymap, tract=self.tract, patch=self.patch, band=self.band, + universe=self.butler.registry.dimensions, + ) + + def tearDown(self): + del self.butler + del self.skymap + del self.tract + del self.patch + del self.band + del self.coaddDataId + + def testFailedPsfTraceRadiusDeltaNotInCoadd(self): + """Check that the detectors failing the maxPsfTraceRadiusDelta + criterion are not included in the coadd. + """ + coadd = self.butler.get("deepCoadd_calexp", self.coaddDataId) + inputCcds = coadd.getInfo().getCoaddInputs().ccds + for failedDataId in PSF_MODEL_ROBUSTNESS_FAILURE_DATA_IDS: + visit = failedDataId["visit"] + detector = failedDataId["detector"] + failedMask = (inputCcds["visit"] == visit) & (inputCcds["ccd"] == detector) + self.assertTrue(sum(failedMask) == 0) + + +class MemoryTester(lsst.utils.tests.MemoryTestCase): + pass + + +if __name__ == "__main__": + lsst.utils.tests.init() + unittest.main()