Coverage for tests/test_getInstcal.py: 30%

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

68 statements  

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 math 

24import os 

25import warnings 

26import unittest 

27 

28import lsst.utils.tests 

29from lsst.utils import getPackageDir 

30 

31import lsst.daf.persistence as dafPersist 

32from lsst.geom import arcseconds, radians 

33 

34from test_getRaw import visit229388_info 

35 

36 

37class GetInstcalTestCase(lsst.utils.tests.TestCase): 

38 

39 def setUp(self): 

40 try: 

41 datadir = getPackageDir("testdata_decam") 

42 except LookupError: 

43 message = "testdata_decam not setup. Skipping." 

44 warnings.warn(message) 

45 raise unittest.SkipTest(message) 

46 

47 self.repoPath = os.path.join(datadir, "cpData") 

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

49 self.size = (2046, 4094) 

50 self.dataId = {'visit': 229388, 'ccdnum': 1} 

51 self.filter = "z" 

52 

53 def tearDown(self): 

54 del self.butler 

55 

56 def testInstcal(self): 

57 """Test retrieval of community pipeline-processed image""" 

58 exp = self.butler.get("instcal", self.dataId, immediate=True) 

59 

60 self.assertEqual(exp.getWidth(), self.size[0]) 

61 self.assertEqual(exp.getHeight(), self.size[1]) 

62 self.assertEqual(exp.getDetector().getId(), self.dataId["ccdnum"]) 

63 self.assertEqual(exp.getFilter().getCanonicalName(), self.filter) 

64 self.assertTrue(exp.hasWcs()) 

65 magZero = 2.5 * math.log10(exp.getPhotoCalib().getInstFluxAtZeroMagnitude()) 

66 self.assertAlmostEqual(magZero, 28.957) 

67 

68 visitInfo = exp.getInfo().getVisitInfo() 

69 self.assertEqual(visitInfo.getDate(), visit229388_info['dateAvg']) 

70 self.assertEqual(visitInfo.getExposureTime(), visit229388_info['exposureTime']) 

71 self.assertEqual(visitInfo.getDarkTime(), visit229388_info['darkTime']) 

72 self.assertEqual(visitInfo.getExposureId(), int("%07d%02d" % (229388, 1))) 

73 self.assertAnglesAlmostEqual(visitInfo.getEra(), visit229388_info['era'], 

74 maxDiff=0.0001*radians) 

75 self.assertSpherePointsAlmostEqual(visitInfo.getBoresightRaDec(), visit229388_info['boresightRaDec'], 

76 maxSep=0.1*arcseconds) 

77 self.assertSpherePointsAlmostEqual(visitInfo.getBoresightAzAlt(), visit229388_info['boresightAzAlt']) 

78 self.assertAlmostEqual(visitInfo.getBoresightAirmass(), visit229388_info['boresightAirmass']) 

79 self.assertEqual(visitInfo.getBoresightRotAngle(), visit229388_info['boresightRotAngle']) 

80 self.assertEqual(visitInfo.getRotType(), visit229388_info['rotType']) 

81 observatory = visitInfo.getObservatory() 

82 self.assertAnglesAlmostEqual(observatory.getLongitude(), visit229388_info['obs_longitude']) 

83 self.assertAnglesAlmostEqual(observatory.getLatitude(), visit229388_info['obs_latitude']) 

84 self.assertAlmostEqual(observatory.getElevation(), visit229388_info['obs_elevation']) 

85 weather = visitInfo.getWeather() 

86 self.assertAlmostEqual(weather.getAirTemperature(), visit229388_info['weath_airTemperature']) 

87 self.assertAlmostEqual(weather.getAirPressure(), visit229388_info['weath_airPressure']) 

88 self.assertAlmostEqual(weather.getHumidity(), visit229388_info['weath_humidity']) 

89 

90 # Metadata should not contain WCS or TPV headers. 

91 # This is not an exhaustive list. 

92 wcs_keywords = ("PV1_1", "PV2_1", "CRPIX1", "CD2_1", "CRVAL2", "LTV1") 

93 for keyword in wcs_keywords: 

94 self.assertNotIn(keyword, exp.getMetadata().paramNames()) 

95 

96 def testCcdName(self): 

97 """Verify that we get the proper CCD for a specified ccdnum.""" 

98 dataId = {'visit': 229388, 'ccdnum': 62} 

99 exp = self.butler.get("instcal", dataId, immediate=True) 

100 self.assertEqual(exp.getDetector().getName(), "N31") 

101 visitInfo = exp.getInfo().getVisitInfo() 

102 self.assertEqual(visitInfo.getExposureId(), int("%07d%02d" % (229388, 62))) 

103 

104 

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

106 pass 

107 

108 

109def setup_module(module): 

110 lsst.utils.tests.init() 

111 

112 

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

114 lsst.utils.tests.init() 

115 unittest.main()