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

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

# 

# LSST Data Management System 

# Copyright 2008-2017 LSST Corporation. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <http://www.lsstcorp.org/LegalNotices/>. 

# 

 

"""Test ability to get an eimage from the butler. 

**Note that this is an lsstSim specific test and 

should not be considered generalizable. 

""" 

import os 

import unittest 

 

import numpy as np 

 

import lsst.utils 

import lsst.geom as geom 

from lsst.afw.image import RotType 

import lsst.utils.tests 

import lsst.daf.persistence as dafPersistence 

from lsst.afw.coord import Observatory, Weather 

from lsst.daf.base import DateTime 

 

obsLsstSimDir = lsst.utils.getPackageDir('obs_lsstSim') 

InputDir = os.path.join(obsLsstSimDir, 'tests', 'data') 

 

 

class GetEimageTestCase(lsst.utils.tests.TestCase): 

"""Test the accessors for various bits of metadata attached to eimages. 

The exposure is read in setUpClass. The different methods of VisitInfo 

are tested separately to simplify error reporting. 

""" 

@classmethod 

def setUpClass(cls): 

# For lsstSim specific reasons, we need to specify the raft and sensor 

dataId = dict(visit=840, raft='2,2', sensor='1,1') 

butler = dafPersistence.Butler(InputDir) 

cls.exposure = butler.get('eimage', dataId=dataId) 

cls.visit_info = cls.exposure.getInfo().getVisitInfo() 

 

@classmethod 

def tearDownClass(cls): 

del cls.exposure 

del cls.visit_info 

 

def test_getWcs(self): 

"""Test whether the Exposure has a Wcs attached.""" 

 

# Test for a Wcs object 

self.assertIsNotNone(self.exposure.getWcs()) 

 

def test_getBoresightAirmass(self): 

self.assertEqual(1.00015190967402, self.visit_info.getBoresightAirmass()) 

 

def test_getBoresightAzAlt(self): 

coord = geom.SpherePoint(0.0, 89.0, geom.degrees) 

self.assertEqual(coord, self.visit_info.getBoresightAzAlt()) 

 

def test_getBoresightRaDec(self): 

coord = geom.SpherePoint(53.0091385, -27.4389488, geom.degrees) 

self.assertEqual(coord, self.visit_info.getBoresightRaDec()) 

 

def test_getBoresightRotAngle(self): 

# Note test eimage header has ROTANG=236.983652. boresightRotAngle is -ROTANG. 

angle = geom.Angle(-236.983652, geom.degrees) 

self.assertAnglesAlmostEqual(angle, self.visit_info.getBoresightRotAngle()) 

 

def test_getDarkTime(self): 

self.assertEqual(30.0, self.visit_info.getDarkTime()) 

 

def test_getDate(self): 

date = DateTime("1994-01-02T01:46:59.520000913", DateTime.TAI) 

self.assertEqual(date, self.visit_info.getDate()) 

 

def test_getEra(self): 

# numpy.isnan fails on afw:Angle, so just get a number out and test that. 

self.assertTrue(np.isnan(self.visit_info.getEra().asRadians())) 

 

def test_getExposureId(self): 

self.assertEqual(430204, self.visit_info.getExposureId()) 

 

def test_getExposureTime(self): 

self.assertEqual(30.0, self.visit_info.getExposureTime()) 

 

def test_getObservatory(self): 

observatory = Observatory(geom.Angle(-70.749417, geom.degrees), 

geom.Angle(-30.244633, geom.degrees), 2663) 

self.assertEqual(observatory, self.visit_info.getObservatory()) 

 

def test_getRotType(self): 

self.assertEqual(RotType.SKY, self.visit_info.getRotType()) 

 

def test_getWeather(self): 

def test_weather(w1, w2): 

"""Test equality of two Weather objects 

@param[in] w1 First Weather object 

@param[in] w2 Second Weather object 

""" 

humid_bool = np.isnan(w1.getHumidity()) and np.isnan(w2.getHumidity()) 

if not humid_bool: 

humid_bool = (w1.getHumidity() == w2.getHumidity()) 

self.assertEqual(w1.getAirTemperature(), w2.getAirTemperature()) 

self.assertEqual(w1.getAirPressure(), w2.getAirPressure()) 

self.assertTrue(humid_bool) 

 

weather = Weather(20, 69327.64145580001, 40.) 

test_weather(weather, self.visit_info.getWeather()) 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

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

pass 

 

 

134 ↛ 135line 134 didn't jump to line 135, because the condition on line 134 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()