Coverage for tests/test_skySources.py: 39%
42 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-04-14 10:26 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-04-14 10:26 +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 charImConfig.measureApCorr.sourceSelector["science"].doSignalToNoise = False
63 charImTask = CharacterizeImageTask(config=charImConfig)
64 charImResults = charImTask.run(self.exposure)
65 calibConfig = CalibrateConfig()
66 calibConfig.doAstrometry = False
67 calibConfig.doPhotoCal = False
68 calibConfig.doSkySources = doSkySources
69 calibConfig.doComputeSummaryStats = False
70 calibTask = CalibrateTask(config=calibConfig)
71 calibResults = calibTask.run(charImResults.exposure)
72 if doSkySources:
73 self.assertTrue('sky_source' in calibResults.outputCat.schema.getNames())
74 else:
75 self.assertFalse('sky_source' in calibResults.outputCat.schema.getNames())
78class MemoryTester(lsst.utils.tests.MemoryTestCase):
79 pass
82def setup_module(module):
83 lsst.utils.tests.init()
86if __name__ == "__main__": 86 ↛ 87line 86 didn't jump to line 87, because the condition on line 86 was never true
87 lsst.utils.tests.init()
88 unittest.main()