Coverage for tests/test_ticket2162.py: 38%

31 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-11 03:10 -0700

1# 

2# LSST Data Management System 

3# Copyright 2008, 2009, 2010 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 unittest 

24 

25import lsst.daf.base as dafBase 

26import lsst.utils.tests 

27from lsst.afw.geom import makeSkyWcs 

28 

29 

30def headerToPropertyList(header): 

31 pl = dafBase.PropertyList() 

32 for key, value in header.items(): 

33 pl.add(key, value) 

34 return pl 

35 

36 

37class WcsTestCase(unittest.TestCase): 

38 

39 def setUp(self): 

40 # Actual WCS from processing Suprime-Cam 

41 self.width = 2048 

42 self.height = 4177 

43 self.header = {'NAXIS': 2, 

44 'EQUINOX': 2000.0000000000, 

45 'RADESYS': "FK5", 

46 'CRPIX1': -3232.7544925483, 

47 'CRPIX2': 4184.4881091129, 

48 'CD1_1': -5.6123808607273e-05, 

49 'CD1_2': 2.8951544956703e-07, 

50 'CD2_1': 2.7343044348306e-07, 

51 'CD2_2': 5.6100888336445e-05, 

52 'CRVAL1': 5.6066137655191, 

53 'CRVAL2': -0.60804032498548, 

54 'CUNIT1': "deg", 

55 'CUNIT2': "deg", 

56 'A_ORDER': 5, 

57 'A_0_2': 1.9749832126246e-08, 

58 'A_0_3': 9.3734869173527e-12, 

59 'A_0_4': 1.8812994578840e-17, 

60 'A_0_5': -2.3524013652433e-19, 

61 'A_1_1': -9.8443908806559e-10, 

62 'A_1_2': -4.9278297504858e-10, 

63 'A_1_3': -2.8491604610001e-16, 

64 'A_1_4': 2.3185723720750e-18, 

65 'A_2_0': 4.9546089730708e-08, 

66 'A_2_1': -8.8592221672777e-12, 

67 'A_2_2': 3.3560100338765e-16, 

68 'A_2_3': 3.0469486185035e-21, 

69 'A_3_0': -4.9332471706700e-10, 

70 'A_3_1': -5.3126029725748e-16, 

71 'A_3_2': 4.7795824885726e-18, 

72 'A_4_0': 1.3128844828963e-16, 

73 'A_4_1': 4.4014452170715e-19, 

74 'A_5_0': 2.1781986904162e-18, 

75 'B_ORDER': 5, 

76 'B_0_2': -1.0607653075899e-08, 

77 'B_0_3': -4.8693887937365e-10, 

78 'B_0_4': -1.0363305097301e-15, 

79 'B_0_5': 1.9621640066919e-18, 

80 'B_1_1': 3.0340657679481e-08, 

81 'B_1_2': -5.0763819284853e-12, 

82 'B_1_3': 2.8987281654754e-16, 

83 'B_1_4': 1.8253389678593e-19, 

84 'B_2_0': -2.4772849184248e-08, 

85 'B_2_1': -4.9775588352207e-10, 

86 'B_2_2': -3.6806326254887e-16, 

87 'B_2_3': 4.4136985315418e-18, 

88 'B_3_0': -1.7807191001742e-11, 

89 'B_3_1': -2.4136396882531e-16, 

90 'B_3_2': 2.9165413645768e-19, 

91 'B_4_0': 4.1029951148438e-16, 

92 'B_4_1': 2.3711874424169e-18, 

93 'B_5_0': 4.9333635889310e-19, 

94 'AP_ORDER': 5, 

95 'AP_0_1': -5.9740855298291e-06, 

96 'AP_0_2': -2.0433429597268e-08, 

97 'AP_0_3': -8.6810071023434e-12, 

98 'AP_0_4': -2.4974690826778e-17, 

99 'AP_0_5': 1.9819631102516e-19, 

100 'AP_1_0': -4.5896648256716e-05, 

101 'AP_1_1': -1.5248993348644e-09, 

102 'AP_1_2': 5.0283116166943e-10, 

103 'AP_1_3': 4.3796281513144e-16, 

104 'AP_1_4': -2.1447889127908e-18, 

105 'AP_2_0': -4.7550300344365e-08, 

106 'AP_2_1': 1.0924172283232e-11, 

107 'AP_2_2': -4.9862026098260e-16, 

108 'AP_2_3': -5.4470851768869e-20, 

109 'AP_3_0': 5.0130654116966e-10, 

110 'AP_3_1': 6.8649554020012e-16, 

111 'AP_3_2': -4.2759588436342e-18, 

112 'AP_4_0': -3.6306802581471e-16, 

113 'AP_4_1': -5.3885285875084e-19, 

114 'AP_5_0': -1.8802693525108e-18, 

115 'BP_ORDER': 5, 

116 'BP_0_1': -2.6627855995942e-05, 

117 'BP_0_2': 1.1143451873584e-08, 

118 'BP_0_3': 4.9323396530135e-10, 

119 'BP_0_4': 1.1785185735421e-15, 

120 'BP_0_5': -1.6169957016415e-18, 

121 'BP_1_0': -5.7914490267576e-06, 

122 'BP_1_1': -3.0565765766244e-08, 

123 'BP_1_2': 5.7727475030971e-12, 

124 'BP_1_3': -4.0586821113726e-16, 

125 'BP_1_4': -2.0662723654322e-19, 

126 'BP_2_0': 2.3705520015164e-08, 

127 'BP_2_1': 5.0530823594352e-10, 

128 'BP_2_2': 3.8904979943489e-16, 

129 'BP_2_3': -3.8346209540986e-18, 

130 'BP_3_0': 1.9505421473262e-11, 

131 'BP_3_1': 1.7583146713289e-16, 

132 'BP_3_2': -3.4876779564534e-19, 

133 'BP_4_0': -3.3690937119054e-16, 

134 'BP_4_1': -2.0853007589561e-18, 

135 'BP_5_0': -5.5344298912288e-19, 

136 'CTYPE1': "RA---TAN-SIP", 

137 'CTYPE2': "DEC--TAN-SIP", 

138 } 

139 

140 def testInputInvariance(self): 

141 pl = headerToPropertyList(self.header) 

142 makeSkyWcs(pl, strip=False) 

143 for key, value in self.header.items(): 

144 self.assertEqual(value, pl.getScalar(key), 

145 f"{key} not invariant: {value} vs {pl.getScalar(key)}") 

146 

147 def testRepeat(self): 

148 pl = headerToPropertyList(self.header) 

149 wcs1 = makeSkyWcs(pl, strip=False) 

150 wcs2 = makeSkyWcs(pl, strip=False) 

151 self.assertEqual(wcs1, wcs2) 

152 

153 

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

155 pass 

156 

157 

158def setup_module(module): 

159 lsst.utils.tests.init() 

160 

161 

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

163 lsst.utils.tests.init() 

164 unittest.main()