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 math 

24import os 

25import warnings 

26import unittest 

27 

28import lsst.utils.tests 

29from lsst.utils import getPackageDir 

30 

31import lsst.pex.exceptions as pexExcept 

32import lsst.daf.persistence as dafPersist 

33from lsst.geom import arcseconds, radians 

34 

35from test_getRaw import visit229388_info 

36 

37 

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

39 

40 def setUp(self): 

41 try: 

42 datadir = getPackageDir("testdata_decam") 

43 except pexExcept.NotFoundError: 

44 message = "testdata_decam not setup. Skipping." 

45 warnings.warn(message) 

46 raise unittest.SkipTest(message) 

47 

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

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

50 self.size = (2046, 4094) 

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

52 self.filter = "z" 

53 

54 def tearDown(self): 

55 del self.butler 

56 

57 def testInstcal(self): 

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

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

60 

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

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

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

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

65 self.assertTrue(exp.hasWcs()) 

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

67 self.assertAlmostEqual(magZero, 28.957) 

68 

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

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

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

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

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

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

75 maxDiff=0.0001*radians) 

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

77 maxSep=0.1*arcseconds) 

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

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

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

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

82 observatory = visitInfo.getObservatory() 

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

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

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

86 weather = visitInfo.getWeather() 

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

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

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

90 

91 # Metadata should not contain WCS or TPV headers. 

92 # This is not an exhaustive list. 

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

94 for keyword in wcs_keywords: 

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

96 

97 def testCcdName(self): 

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

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

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

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

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

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

104 

105 

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

107 pass 

108 

109 

110def setup_module(module): 

111 lsst.utils.tests.init() 

112 

113 

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

115 lsst.utils.tests.init() 

116 unittest.main()