Coverage for tests/test_isrMisc.py: 38%

Shortcuts 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

46 statements  

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_doWrite(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 = 0.0 

54 config.yCenter = 100.0 

55 

56 config.doWriteVignettePolygon = True 

57 task = vignette.VignetteTask(config=config) 

58 result = task.run(self.inputExp) 

59 

60 self.assertIsInstance(result, afwGeom.Polygon) 

61 

62 def test_masking(self): 

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

64 given an exposure. 

65 """ 

66 task = masking.MaskingTask() 

67 result = task.run(self.inputExp) 

68 

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

70 self.assertIsNone(result) 

71 

72 def test_linearize(self): 

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

74 """ 

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

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

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

78 if linearityTypeName == 'LookupTable': 

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

80 elif linearityTypeName == 'Squared': 

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

82 elif linearityTypeName == 'Polynomial': 

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

84 else: 

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

86 self.assertIsNone(result) 

87 

88 

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

90 pass 

91 

92 

93def setup_module(module): 

94 lsst.utils.tests.init() 

95 

96 

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

98 lsst.utils.tests.init() 

99 unittest.main()