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 2016 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# 

22 

23import os 

24import unittest 

25import warnings 

26 

27import lsst.daf.persistence as dafPersist 

28import lsst.pex.exceptions as pexExcept 

29import lsst.utils.tests 

30from lsst.ip.isr import Linearizer, LinearizeLookupTable 

31from lsst.utils import getPackageDir 

32 

33 

34class ButlerTestCase(unittest.TestCase): 

35 """Testing butler policy setup""" 

36 

37 def setUp(self): 

38 try: 

39 datadir = getPackageDir("testdata_decam") 

40 except pexExcept.NotFoundError: 

41 message = "testdata_decam not setup. Skipping." 

42 warnings.warn(message) 

43 raise unittest.SkipTest(message) 

44 

45 self.repoPath = os.path.join(datadir, "rawData") 

46 self.butler = dafPersist.Butler(root=self.repoPath) 

47 

48 def tearDown(self): 

49 del self.butler 

50 

51 def testButlerSubsetLevel(self): 

52 """Test if subset is gathered correctly for the specified level""" 

53 subset = self.butler.subset("raw", level="sensor", visit=229388, ccdnum=1) 

54 print("ButlerSubset.cache: %s" % subset.cache) 

55 self.assertEqual(len(subset), 1) 

56 

57 subset = self.butler.subset("raw", level="sensor", visit=229388) 

58 print("ButlerSubset.cache: %s" % subset.cache) 

59 self.assertEqual(len(subset), 2) 

60 

61 subset = self.butler.subset("raw", level="visit", visit=229388) 

62 print("ButlerSubset.cache: %s" % subset.cache) 

63 self.assertEqual(len(subset), 1) 

64 

65 def testGetCamera(self): 

66 """Test that we can get a camera""" 

67 camera = self.butler.get("camera") 

68 self.assertEqual(len(camera), 62) 

69 self.assertEqual(camera[1].getName(), "S29") 

70 self.assertEqual(camera[62].getName(), "N31") 

71 

72 def testGetLinearizer(self): 

73 """Test that we can get a linearizer""" 

74 camera = self.butler.get("camera") 

75 for ccdnum in (1, 62): 

76 detector = camera[ccdnum] 

77 linearizer = Linearizer(table=self.butler.get("linearizer", 

78 dataId=dict(ccdnum=ccdnum), 

79 immediate=True), 

80 detector=detector) 

81 for amp in detector: 

82 self.assertEqual(linearizer.linearityType[amp.getName()], LinearizeLookupTable.LinearityType) 

83 linearizer.validate(detector=detector) 

84 for badccdnum in (0, 63): 

85 with self.assertRaises(Exception): 

86 self.butler.get("linearizer", dataId=dict(ccdnum=badccdnum), immediate=True) 

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()