Coverage for tests/test_isrMisc.py: 31%

55 statements  

« prev     ^ index     » next       coverage.py v7.2.1, created at 2023-03-12 03:09 -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 <https://www.lsstcorp.org/LegalNotices/>. 

21# 

22 

23import unittest 

24 

25import lsst.afw.geom as afwGeom 

26import lsst.utils.tests 

27import lsst.ip.isr.straylight as straylight 

28import lsst.ip.isr.vignette as vignette 

29import lsst.ip.isr.masking as masking 

30import lsst.ip.isr.linearize as linearize 

31 

32import lsst.ip.isr.isrMock as isrMock 

33 

34 

35class IsrMiscCases(lsst.utils.tests.TestCase): 

36 

37 def setUp(self): 

38 self.inputExp = isrMock.TrimmedRawMock().run() 

39 self.mi = self.inputExp.getMaskedImage() 

40 

41 def test_straylight(self): 

42 """Assert that the straylight task does not error when given an exposure. 

43 """ 

44 task = straylight.StrayLightTask() 

45 with self.assertRaises(NotImplementedError): 

46 task.run(self.inputExp, None) 

47 

48 def test_vignette_noWrite(self): 

49 """Assert that the vignette task does not error when given an exposure 

50 """ 

51 config = vignette.VignetteConfig() 

52 config.radius = 125.0 

53 config.xCenter = 100.0 

54 config.yCenter = 100.0 

55 

56 config.doWriteVignettePolygon = False 

57 task = vignette.VignetteTask(config=config) 

58 result = task.run(self.inputExp) 

59 

60 # DM-19707: ip_isr functionality not fully tested by unit tests 

61 self.assertIsNone(result) 

62 

63 def test_vignette_doWrite(self): 

64 """Assert that the vignette task does not error when given an exposure 

65 """ 

66 config = vignette.VignetteConfig() 

67 config.radius = 125.0 

68 config.xCenter = 100.0 

69 config.yCenter = 100.0 

70 

71 config.doWriteVignettePolygon = True 

72 task = vignette.VignetteTask(config=config) 

73 result = task.run(self.inputExp) 

74 

75 self.assertIsInstance(result, afwGeom.Polygon) 

76 

77 def test_masking(self): 

78 """Assert that the camera-specific masking task does not error when 

79 given an exposure. 

80 """ 

81 task = masking.MaskingTask() 

82 result = task.run(self.inputExp) 

83 

84 # DM-19707: ip_isr functionality not fully tested by unit tests 

85 self.assertIsNone(result) 

86 

87 def test_linearize(self): 

88 """Assert that the linearize task does not error when a linearity is requested. 

89 """ 

90 for linearityTypeName in ('LookupTable', 'Squared', 'Polynomial', 'Unknown'): 

91 result = linearize.Linearizer().getLinearityTypeByName(linearityTypeName) 

92 # These return the actual class to use, so use Equal instead of IsInstance. 

93 if linearityTypeName == 'LookupTable': 

94 self.assertEqual(result, linearize.LinearizeLookupTable, msg=f"{linearityTypeName}") 

95 elif linearityTypeName == 'Squared': 

96 self.assertEqual(result, linearize.LinearizeSquared, msg=f"{linearityTypeName}") 

97 elif linearityTypeName == 'Polynomial': 

98 self.assertEqual(result, linearize.LinearizePolynomial, msg=f"{linearityTypeName}") 

99 else: 

100 # DM-19707: ip_isr functionality not fully tested by unit tests 

101 self.assertIsNone(result) 

102 

103 

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

105 pass 

106 

107 

108def setup_module(module): 

109 lsst.utils.tests.init() 

110 

111 

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

113 lsst.utils.tests.init() 

114 unittest.main()