Coverage for tests / test_psfCandidateSelection.py: 36%

37 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-24 08:38 +0000

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 

24 

25import lsst.afw.image as afwImage 

26import lsst.utils.tests 

27import lsst.meas.extensions.piff.piffPsfDeterminer 

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

29 

30TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

31 

32 

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

34 

35 def setUp(self): 

36 # Load sample input from disk 

37 expPath = os.path.join(TESTDIR, "data", "v695833-e0-c000-a00.sci.fits") 

38 self.exposure = afwImage.ExposureF(expPath) 

39 

40 def tearDown(self): 

41 del self.exposure 

42 

43 def testFlags(self): 

44 # Test that all of the flags are defined and there is no reservation by default 

45 # also test that used sources are a subset of candidate sources 

46 config = CharacterizeImageConfig() 

47 config.measurePsf.psfDeterminer = 'piff' 

48 config.measurePsf.psfDeterminer['piff'].spatialOrder = 0 

49 config.measureApCorr.sourceSelector["science"].doSignalToNoise = False 

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) 

62 

63 

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

65 pass 

66 

67 

68def setup_module(module): 

69 lsst.utils.tests.init() 

70 

71 

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