Coverage for tests/test_psfCandidateSelection.py: 35%

38 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-04-15 03:16 -0700

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 

25 

26import lsst.afw.image as afwImage 

27import lsst.utils.tests 

28from lsst.utils import getPackageDir 

29from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig 

30 

31 

32class PsfFlagTestCase(lsst.utils.tests.TestCase): 

33 

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) 

40 

41 def tearDown(self): 

42 del self.exposure 

43 

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 config.measureApCorr.sourceSelector["science"].doSignalToNoise = False 

51 task = CharacterizeImageTask(config=config) 

52 results = task.run(self.exposure) 

53 used = 0 

54 reserved = 0 

55 for source in results.sourceCat: 

56 if source.get("calib_psf_used"): 

57 used += 1 

58 self.assertTrue(source.get("calib_psf_candidate")) 

59 if source.get("calib_psf_reserved"): 

60 reserved += 1 

61 self.assertGreater(used, 0) 

62 self.assertEqual(reserved, 0) 

63 

64 

65class MemoryTester(lsst.utils.tests.MemoryTestCase): 

66 pass 

67 

68 

69def setup_module(module): 

70 lsst.utils.tests.init() 

71 

72 

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()