Hide keyboard shortcuts

Hot-keys 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

1# 

2# LSST Data Management System 

3# Copyright 2015-2017 LSST Corporation. 

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 sys 

24import unittest 

25 

26import lsst.afw.math as afwMath 

27import lsst.daf.persistence as dafPersist 

28from lsst.obs.lsstSim import LsstSimIsrTask 

29import lsst.utils.tests 

30 

31 

32class LsstSimIsrTaskTestCase(unittest.TestCase): 

33 """A test case for LsstSimIsrTask 

34 """ 

35 

36 def setUp(self): 

37 self.butler = dafPersist.Butler(root=os.path.join(os.path.dirname(__file__), "data")) 

38 self.ampRef = self.butler.dataRef("raw", level=None, 

39 dataId=dict(visit=85471048, snap=0, raft='0,3', 

40 sensor='0,1', channel='1,0')) 

41 

42 def tearDown(self): 

43 del self.butler 

44 del self.ampRef 

45 

46 def testRunDataRef(self): 

47 """Test LsstSimIsrTask on amp-sized images in tests/data/ 

48 

49 applyToSensorRef is not intended to take single amp-sized exposures, but will 

50 run if the doAssembleCcd config parameter is False. 

51 However, the exposure is not trimmed, and gain not reset. 

52 """ 

53 config = LsstSimIsrTask.ConfigClass() 

54 config.doDark = False 

55 config.doFringe = False 

56 config.doAssembleCcd = False 

57 config.doSnapCombine = False 

58 config.doLinearize = False 

59 lsstIsrTask = LsstSimIsrTask(config=config) 

60 exposure = lsstIsrTask.runDataRef(self.ampRef).exposure 

61 self.assertAlmostEqual(afwMath.makeStatistics(exposure.getMaskedImage(), afwMath.MEAN).getValue(), 

62 2.855780, places=3) 

63 

64 def testRun(self): 

65 """Test LsstSimIsrTask on amp-sized images in tests/data/ 

66 

67 Do not assembleCcd. 

68 """ 

69 config = LsstSimIsrTask.ConfigClass() 

70 config.doDark = False 

71 config.doFringe = False 

72 config.doAssembleCcd = False 

73 config.doSnapCombine = False 

74 config.doLinearize = False 

75 lsstIsrTask = LsstSimIsrTask(config=config) 

76 ampExp = self.ampRef.get('raw') 

77 camera = self.ampRef.get("camera") 

78 isrData = lsstIsrTask.readIsrData(self.ampRef, ampExp) 

79 postIsrExp = lsstIsrTask.run(ampExp, camera=camera, **isrData.getDict()).exposure 

80 self.assertAlmostEqual(ampExp.getMetadata().getScalar('GAIN'), 

81 postIsrExp.getMetadata().getScalar('GAIN')) 

82 self.assertAlmostEqual(ampExp.getDimensions()[0], postIsrExp.getDimensions()[0]) 

83 self.assertAlmostEqual(ampExp.getDimensions()[1], postIsrExp.getDimensions()[1]) 

84 self.assertAlmostEqual(afwMath.makeStatistics(postIsrExp.getMaskedImage(), afwMath.MEAN).getValue(), 

85 2.855780, places=3) 

86 

87 

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

89 pass 

90 

91 

92def setup_module(module): 

93 lsst.utils.tests.init() 

94 

95 

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

97 setup_module(sys.modules[__name__]) 

98 unittest.main()