Coverage for tests/test_psfCandidateSelection.py: 36%
39 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-26 11:30 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-26 11:30 +0000
1#
2# LSST Data Management System
3# Copyright 2008-2017 AURA/LSST
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
22import os
23import unittest
24import logging
26import lsst.afw.image as afwImage
27import lsst.utils.tests
28import lsst.meas.extensions.piff.piffPsfDeterminer
29from lsst.utils import getPackageDir
30from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig
33class PsfFlagTestCase(lsst.utils.tests.TestCase):
35 def setUp(self):
36 # Load sample input from disk
37 expPath = os.path.join(getPackageDir("pipe_tasks"), "tests", "data", "v695833-e0-c000-a00.sci.fits")
38 self.exposure = afwImage.ExposureF(expPath)
39 # set log level so that warnings do not display
40 logging.getLogger("lsst.characterizeImage").setLevel(logging.ERROR)
42 def tearDown(self):
43 del self.exposure
45 def testFlags(self):
46 # Test that all of the flags are defined and there is no reservation by default
47 # also test that used sources are a subset of candidate sources
48 config = CharacterizeImageConfig()
49 config.measurePsf.psfDeterminer = 'piff'
50 config.measurePsf.psfDeterminer['piff'].spatialOrder = 0
51 config.measureApCorr.sourceSelector["science"].doSignalToNoise = False
52 task = CharacterizeImageTask(config=config)
53 results = task.run(self.exposure)
54 used = 0
55 reserved = 0
56 for source in results.sourceCat:
57 if source.get("calib_psf_used"):
58 used += 1
59 self.assertTrue(source.get("calib_psf_candidate"))
60 if source.get("calib_psf_reserved"):
61 reserved += 1
62 self.assertGreater(used, 0)
63 self.assertEqual(reserved, 0)
66class MemoryTester(lsst.utils.tests.MemoryTestCase):
67 pass
70def setup_module(module):
71 lsst.utils.tests.init()
74if __name__ == "__main__": 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 lsst.utils.tests.init()
76 unittest.main()