Coverage for tests/test_skySources.py: 41%
40 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-15 10:50 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-15 10:50 +0000
1# This file is part of pipe_tasks.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
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
30from lsst.pipe.tasks.calibrate import CalibrateTask, CalibrateConfig
33class SkySourcesTestCase(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.calibrate").setLevel(logging.ERROR)
42 def tearDown(self):
43 del self.exposure
45 def testDoSkySources(self):
46 """Tests sky_source column gets added when run.
47 """
48 self._checkSkySourceColumnExistence(doSkySources=True)
49 self._checkSkySourceColumnExistence(doSkySources=False)
51 def _checkSkySourceColumnExistence(self, doSkySources):
52 """Implements sky_source column checking.
54 Parameters
55 ----------
56 doSkySource : `bool`
57 Value of the config flag determining whether to insert sky sources.
58 """
59 charImConfig = CharacterizeImageConfig()
60 charImConfig.measurePsf.psfDeterminer = 'piff'
61 charImConfig.measurePsf.psfDeterminer['piff'].spatialOrder = 0
62 charImTask = CharacterizeImageTask(config=charImConfig)
63 charImResults = charImTask.run(self.exposure)
64 calibConfig = CalibrateConfig()
65 calibConfig.doAstrometry = False
66 calibConfig.doPhotoCal = False
67 calibConfig.doSkySources = doSkySources
68 calibTask = CalibrateTask(config=calibConfig)
69 calibResults = calibTask.run(charImResults.exposure)
70 if doSkySources:
71 self.assertTrue('sky_source' in calibResults.outputCat.schema.getNames())
72 else:
73 self.assertFalse('sky_source' in calibResults.outputCat.schema.getNames())
76class MemoryTester(lsst.utils.tests.MemoryTestCase):
77 pass
80def setup_module(module):
81 lsst.utils.tests.init()
84if __name__ == "__main__": 84 ↛ 85line 84 didn't jump to line 85, because the condition on line 84 was never true
85 lsst.utils.tests.init()
86 unittest.main()