Coverage for tests/test_colorterms.py: 27%

47 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-05 10:48 +0000

1# 

2# LSST Data Management System 

3# 

4# Copyright 2008-2016 AURA/LSST. 

5# 

6# This product includes software developed by the 

7# LSST Project (http://www.lsst.org/). 

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 LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <https://www.lsstcorp.org/LegalNotices/>. 

22# 

23import os.path 

24import numbers 

25import unittest 

26 

27import lsst.utils.tests 

28import lsst.pipe.tasks.photoCal as photoCal 

29 

30 

31def setup_module(module): 

32 lsst.utils.tests.init() 

33 

34 

35class ColortermOverrideTestCase(unittest.TestCase): 

36 """Test that the HSC colorterms have been set consistently.""" 

37 def setUp(self): 

38 """Test that colorterms specific to HSC override correctly""" 

39 colortermsFile = os.path.join(os.path.dirname(__file__), "../config", "colorterms.py") 

40 self.photoCalConf = photoCal.PhotoCalConfig() 

41 self.photoCalConf.colorterms.load(colortermsFile) 

42 

43 def testHscColorterms(self): 

44 """Test that the colorterm libraries are formatted correctly""" 

45 hscReferenceFilters = ["g", "r", "i", "z", "y"] 

46 hscPhysicalFilters = ["HSC-G", "HSC-R", "HSC-I", "HSC-Z", "HSC-Y"] 

47 for filter in hscPhysicalFilters: 

48 ct = self.photoCalConf.colorterms.getColorterm(filter, photoCatName="hsc") # exact match 

49 self.assertIn(ct.primary, hscReferenceFilters) 

50 self.assertIn(ct.secondary, hscReferenceFilters) 

51 self.assertIsInstance(ct.c0, numbers.Number) 

52 self.assertIsInstance(ct.c1, numbers.Number) 

53 self.assertIsInstance(ct.c2, numbers.Number) 

54 

55 def testSdssColorterms(self): 

56 """Test that the colorterm libraries are formatted correctly""" 

57 sdssReferenceFilters = ["g", "r", "i", "z", "y"] 

58 hscPhysicalFilters = ["HSC-G", "HSC-R", "HSC-I", "HSC-I2", "HSC-Z", "HSC-Y", "NB0816", "NB0921"] 

59 for filter in hscPhysicalFilters: 

60 ct = self.photoCalConf.colorterms.getColorterm(filter, photoCatName="sdss") # exact match 

61 self.assertIn(ct.primary, sdssReferenceFilters) 

62 self.assertIn(ct.secondary, sdssReferenceFilters) 

63 self.assertIsInstance(ct.c0, numbers.Number) 

64 self.assertIsInstance(ct.c1, numbers.Number) 

65 self.assertIsInstance(ct.c2, numbers.Number) 

66 

67 def testPs1Colorterms(self): 

68 """Test that the colorterm libraries are formatted correctly""" 

69 ps1ReferenceFilters = ["g", "r", "i", "z", "y"] 

70 hscPhysicalFilters = ["HSC-G", "HSC-R", "HSC-R2", "HSC-I", "HSC-I2", "HSC-Z", "HSC-Y", 

71 "IB0945", "NB0387", "NB0468", "NB0515", "NB0527", "NB0656", 

72 "NB0718", "NB0816", "NB0921", "NB0973", "NB1010"] 

73 

74 for filter in hscPhysicalFilters: 

75 ct = self.photoCalConf.colorterms.getColorterm(filter, photoCatName="ps1") # exact match 

76 self.assertIn(ct.primary, ps1ReferenceFilters) 

77 self.assertIn(ct.secondary, ps1ReferenceFilters) 

78 self.assertIsInstance(ct.c0, numbers.Number) 

79 self.assertIsInstance(ct.c1, numbers.Number) 

80 self.assertIsInstance(ct.c2, numbers.Number) 

81 

82 

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

84 pass 

85 

86 

87if __name__ == "__main__": 87 ↛ 88line 87 didn't jump to line 88, because the condition on line 87 was never true

88 lsst.utils.tests.init() 

89 unittest.main()