Coverage for tests/test_psfCandidateSelection.py: 36%
37 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-24 01:40 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-24 01:40 -0800
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
28from lsst.utils import getPackageDir
29from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig
32class PsfFlagTestCase(lsst.utils.tests.TestCase):
34 def setUp(self):
35 # Load sample input from disk
36 expPath = os.path.join(getPackageDir("pipe_tasks"), "tests", "data", "v695833-e0-c000-a00.sci.fits")
37 self.exposure = afwImage.ExposureF(expPath)
38 # set log level so that warnings do not display
39 logging.getLogger("lsst.characterizeImage").setLevel(logging.ERROR)
41 def tearDown(self):
42 del self.exposure
44 def testFlags(self):
45 # Test that all of the flags are defined and there is no reservation by default
46 # also test that used sources are a subset of candidate sources
47 config = CharacterizeImageConfig()
48 config.measurePsf.psfDeterminer = 'piff'
49 config.measurePsf.psfDeterminer['piff'].spatialOrder = 0
50 task = CharacterizeImageTask(config=config)
51 results = task.run(self.exposure)
52 used = 0
53 reserved = 0
54 for source in results.sourceCat:
55 if source.get("calib_psf_used"):
56 used += 1
57 self.assertTrue(source.get("calib_psf_candidate"))
58 if source.get("calib_psf_reserved"):
59 reserved += 1
60 self.assertGreater(used, 0)
61 self.assertEqual(reserved, 0)
64class MemoryTester(lsst.utils.tests.MemoryTestCase):
65 pass
68def setup_module(module):
69 lsst.utils.tests.init()
72if __name__ == "__main__": 72 ↛ 73line 72 didn't jump to line 73, because the condition on line 72 was never true
73 lsst.utils.tests.init()
74 unittest.main()