Coverage for tests/test_isPrimaryFlag.py : 92%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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
25import lsst.afw.image as afwImage
26import lsst.utils.tests
27from lsst.utils import getPackageDir
28from lsst.log import Log
29from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig
30from lsst.pipe.tasks.calibrate import CalibrateTask, CalibrateConfig
33class IsPrimaryTestCase(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 Log.getLogger("calibrate").setLevel(Log.ERROR)
42 def tearDown(self):
43 del self.exposure
45 def testIsPrimaryFlag(self):
46 """Tests detect_isPrimary column gets added when run, and that sources
47 labelled as detect_isPrimary are not sky sources and have no children.
48 """
49 charImConfig = CharacterizeImageConfig()
50 charImTask = CharacterizeImageTask(config=charImConfig)
51 charImResults = charImTask.run(self.exposure)
52 calibConfig = CalibrateConfig()
53 calibConfig.doAstrometry = False
54 calibConfig.doPhotoCal = False
55 calibTask = CalibrateTask(config=calibConfig)
56 calibResults = calibTask.run(charImResults.exposure)
57 outputCat = calibResults.outputCat
58 self.assertTrue("detect_isPrimary" in outputCat.schema.getNames())
59 # make sure all sky sources are flagged as not primary
60 self.assertEqual(sum((outputCat["detect_isPrimary"]) & (outputCat["sky_source"])), 0)
61 # make sure all parent sources are flagged as not primary
62 self.assertEqual(sum((outputCat["detect_isPrimary"]) & (outputCat["deblend_nChild"] > 0)), 0)
65class MemoryTester(lsst.utils.tests.MemoryTestCase):
66 pass
69def setup_module(module):
70 lsst.utils.tests.init()
73if __name__ == "__main__": 73 ↛ 74line 73 didn't jump to line 74, because the condition on line 73 was never true
74 lsst.utils.tests.init()
75 unittest.main()