Coverage for tests/test_photodiodeCorrection.py: 25%

53 statements  

« prev     ^ index     » next       coverage.py v7.0.0, created at 2022-12-20 10:00 +0000

1# This file is part of ip_isr. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

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 GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22import unittest 

23import tempfile 

24 

25import lsst.afw.cameraGeom as cameraGeom 

26import lsst.geom as geom 

27import lsst.utils.tests 

28 

29from lsst.ip.isr import PhotodiodeCorrection 

30 

31 

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

33 def setUp(self): 

34 

35 self.pairs = ['[3021120600588, 3021120600589]', 

36 '[3021120600639, 3021120600640]', 

37 '[3021120600711, 3021120600712]', 

38 '[3021120600774, 3021120600775]', 

39 '[3021120600612, 3021120600613]', 

40 '[3021120600675, 3021120600676]'] 

41 

42 self.corrections = [0.0008682616635145324, 0.0008634151174990838, 

43 0.0008343013803181451, 0.0007904133024002547, 

44 0.0007386119393599833, 0.000780670380485576] 

45 

46 camBuilder = cameraGeom.Camera.Builder("fakeCam") 

47 detBuilder = camBuilder.add('det_a', 1) 

48 detBuilder.setSerial("123") 

49 

50 bbox = geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(100, 100)) 

51 orientation = cameraGeom.Orientation() 

52 pixelSize = lsst.geom.Extent2D(1, 1) 

53 detBuilder.setBBox(bbox) 

54 detBuilder.setOrientation(orientation) 

55 detBuilder.setPixelSize(pixelSize) 

56 

57 self.camera = camBuilder 

58 self.detector = detBuilder 

59 

60 def testDataOnly(self): 

61 calib = PhotodiodeCorrection() 

62 for i, pair in enumerate(self.pairs): 

63 calib.abscissaCorrections[pair] = self.corrections[i] 

64 

65 outPath = tempfile.mktemp() + '.yaml' 

66 calib.writeText(outPath) 

67 newCorrection = PhotodiodeCorrection().readText(outPath) 

68 self.assertEqual(calib, newCorrection) 

69 

70 outPath = tempfile.mktemp() + '.fits' 

71 calib.writeFits(outPath) 

72 newCorrection = PhotodiodeCorrection().readFits(outPath) 

73 self.assertEqual(calib, newCorrection) 

74 

75 def testFullyPopulated(self): 

76 calib = PhotodiodeCorrection(detector=self.detector, 

77 camera=self.camera) 

78 

79 for i, pair in enumerate(self.pairs): 

80 calib.abscissaCorrections[pair] = self.corrections[i] 

81 

82 outPath = tempfile.mktemp() + '.yaml' 

83 calib.writeText(outPath) 

84 newCorrection = PhotodiodeCorrection().readText(outPath) 

85 self.assertEqual(calib, newCorrection) 

86 

87 outPath = tempfile.mktemp() + '.fits' 

88 calib.writeFits(outPath) 

89 newCorrection = PhotodiodeCorrection().readFits(outPath) 

90 self.assertEqual(calib, newCorrection) 

91 

92 

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

94 pass 

95 

96 

97def setup_module(module): 

98 lsst.utils.tests.init() 

99 

100 

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

102 import sys 

103 setup_module(sys.modules[__name__]) 

104 unittest.main()