Coverage for python/lsst/cbp/coordinateConverterConfig.py: 27%

45 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-14 19:53 +0000

1# This file is part of cbp. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

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

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

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

12# (at your option) any later version. 

13# 

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

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

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21"""CoordinateConverterConfig class: configuration for 

22a CoordinateConverter 

23""" 

24 

25__all__ = ["CoordinateConverterConfig"] 

26 

27import numpy as np 

28 

29from lsst.geom import degrees 

30 

31 

32class CoordinateConverterConfig: 

33 """Configuration for the CoordinateConverter. 

34 

35 :ref:`Configuration <lsst.cbp.configuration>` for the 

36 lsst.cbp.CoordinateConverter. 

37 

38 Parameters 

39 ---------- 

40 telPupilOffset : `float` 

41 Offset of the telescope :ref:`pupil plane 

42 <lsst.cbp.pupil_position>` from the center of the telescope 

43 (mm, positive if closer to the sky). 

44 telPupilDiameter : `float` 

45 Diameter of telescope pupil (mm). 

46 telPupilObscurationDiameter : `float` 

47 Diameter of the telescope central obscuration at the 

48 `pupil plane <lsst.cbp.pupil_position>` (mm). 

49 telFocalPlaneDiameter : `float` 

50 Diameter of telescope flocal plane (mm). 

51 telFlipX : `bool` 

52 True if the x axis of the telescope focal plane 

53 is :ref:`flipped <lsst.cbp.flipped_x_axis>` 

54 with respect to the pupil frame. 

55 telAzimuthOffsetDeg : `float` 

56 Azimuth `offset`_ (degrees). 

57 telAzimuthScale : `float` 

58 Azimuth `scale`_; must be ±1 

59 (in order to handle wrap correctly). 

60 telAltitudeOffsetDeg : `float` (optional) 

61 Telescope altitude `offset`_ (degrees); defaults to 0. 

62 telAltitudeScale : `float` (optional) 

63 Telescope altitude `scale`_; defaults to 1. 

64 telAltitudeLimitsDeg : pair of `float` 

65 Telescope minimum, maximum allowed observed altitude (degrees). 

66 telRotOffsetDeg : `float` 

67 Telescope camera rotator offset (degrees). 

68 telRotScale : `float` 

69 Telescope camera rotator scale; must be ±1 

70 (in order to handle wrap correctly). 

71 defaultDetector : `str` 

72 Name of default detector. 

73 

74 cbpPosition : triplet of `float` 

75 CBP x, y, z position of center of CBP relative to the center 

76 of the telescope, in the base frame (mm). 

77 cbpFocalLength : `float` 

78 Effective focal length of the CBP (mm); 

79 635 mm is an estimate for the LSST's CBP. 

80 cbpFlipX : `bool` 

81 True if the x axis of the CBP focal plane is flipped 

82 with respect to the pupil frame? 

83 cbpAzimuthOffsetDeg : `float` 

84 CBP azimuth `offset`_ (degrees). 

85 cbpAzimuthScale : `float` 

86 CBP azimuth `scale`_; must be ±1 

87 (in order to handle wrap correctly). 

88 cbpAltitudeOffsetDeg : `float` (optional) 

89 CBP altitude `offset`_ (degrees); defaults to 0. 

90 cbpAltitudeScale : `float` (optional) 

91 CBP altitude `scale`_; defaults to 1. 

92 cbpAltitudeLimitsDeg : pair of `float` 

93 CBP minimum, maximum allowed observed altitude (degrees). 

94 

95 Raises 

96 ------ 

97 ValueError 

98 Raised if ``telAzimuthScale``, ``cbpAzimuthScale`` 

99 and/or ``telRotScale`` is not ±1. 

100 ValueError 

101 Raised if items with multiple values have the wrong length. 

102 

103 Notes 

104 ----- 

105 .. _offset: 

106 

107 .. _scale: 

108 

109 **Offset and Scale:** 

110 

111 Azimuth, altitude and rotator offset and scale define the mapping 

112 between :ref:`internal angle <lsst.cbp.internal_angles>` 

113 and :ref:`observed angle <lsst.cbp.observed_angles>` as follows:: 

114 

115 observed angle = internal angle * scale + offset 

116 

117 .. _fields: 

118 

119 **Attributes** 

120 

121 telPupilOffset : `float` 

122 Offset of the telescope :ref:`pupil plane 

123 <lsst.cbp.pupil_position>` from the center of the telescope 

124 (mm, + if closer to the sky). 

125 telPupilDiameter : `float` 

126 Diameter of telescope pupil (mm). 

127 telPupilObscurationDiameter : `float` 

128 Diameter of the telescope central obscuration at the 

129 `pupil plane <lsst.cbp.pupil_position>` (mm). 

130 telFocalPlaneDiameter : `float` 

131 Diameter of telescope flocal plane (mm). 

132 telFlipX : `bool` 

133 True if the x axis of the telescope focal plane 

134 is :ref:`flipped <lsst.cbp.flipped_x_axis>` 

135 with respect to the pupil frame. 

136 telAzAltOffset : pair of `lsst.geom.Angle` 

137 Telescope azimuth and altitude `offset`_ (degrees). 

138 telAzAltScale : pair of `float` 

139 Telescope azimuth and altitude `scale`_; 

140 azimuth scale is ±1. 

141 telAltitudeLimits : pair of `lsst.geom.Angle` 

142 Telescope minimum, maximum allowed observed altitude. 

143 telRotOffset : `lsst.geom.Angle` 

144 Telescope camera rotator offset. 

145 telRotScale : `float` 

146 Telescope camera rotator scale; must be ±1. 

147 defaultDetector : `str` 

148 Name of default detector. 

149 

150 cbpFocalLength : `float` 

151 Effective focal length of the CBP (mm); 

152 635 mm is an estimate for the LSST's CBP. 

153 cbpFlipX : `bool` 

154 True if the x axis of the CBP focal plane is flipped 

155 with respect to the pupil frame? 

156 cbpAzAltOffset : pair of `lsst.geom.Angle` 

157 CBP azimuth and altitude `offset`_ (degrees). 

158 cbpAzAltScale : pair of `float` 

159 CBP azimuth and altitude `scale`_; azimuth scale is ±1. 

160 cbpAltitudeLimits : pair of `lsst.geom.Angle` 

161 CBP minimum, maximum allowed observed altitude. 

162 """ 

163 

164 def __init__(self, *, telPupilOffset, 

165 telPupilDiameter, telPupilObscurationDiameter, telFocalPlaneDiameter, telFlipX, 

166 telAzimuthOffsetDeg, telAzimuthScale, 

167 telAltitudeOffsetDeg=0, telAltitudeScale=1, telAltitudeLimitsDeg, 

168 telRotOffsetDeg, telRotScale, 

169 defaultDetector, 

170 cbpPosition, cbpFocalLength, cbpFlipX, 

171 cbpAzimuthOffsetDeg, cbpAzimuthScale, 

172 cbpAltitudeOffsetDeg=0, cbpAltitudeScale=1, cbpAltitudeLimitsDeg): 

173 self.telPupilOffset = telPupilOffset 

174 self.telPupilDiameter = telPupilDiameter 

175 self.telPupilObscurationDiameter = telPupilObscurationDiameter 

176 self.telFocalPlaneDiameter = telFocalPlaneDiameter 

177 self.telFlipX = telFlipX 

178 self.telAzAltOffset = (telAzimuthOffsetDeg*degrees, telAltitudeOffsetDeg*degrees) 

179 if abs(telAzimuthScale) != 1: 

180 raise ValueError("telAzimuthScale={} must be +/-1".format(telAzimuthScale)) 

181 self.telAzAltScale = (telAzimuthScale, telAltitudeScale) 

182 if len(telAltitudeLimitsDeg) != 2: 

183 raise ValueError("telAltitudeLimitsDeg={!r} must have length 2".format(telAltitudeLimitsDeg)) 

184 self.telAltitudeLimits = tuple(val*degrees for val in telAltitudeLimitsDeg) 

185 self.telRotOffset = telRotOffsetDeg*degrees 

186 if abs(telRotScale) != 1: 

187 raise ValueError("telRotScale={} must be +/-1".format(telRotScale)) 

188 self.telRotScale = telRotScale 

189 

190 self.defaultDetector = defaultDetector 

191 

192 self.cbpPosition = cbpPosition 

193 self.cbpFocalLength = cbpFocalLength 

194 self.cbpFlipX = cbpFlipX 

195 self.cbpAzAltOffset = (cbpAzimuthOffsetDeg*degrees, cbpAltitudeOffsetDeg*degrees) 

196 if abs(cbpAzimuthScale) != 1: 

197 raise ValueError("cbpAzimuthScale={} must be +/-1".format(cbpAzimuthScale)) 

198 self.cbpAzAltScale = (cbpAzimuthScale, cbpAltitudeScale) 

199 if len(cbpAltitudeLimitsDeg) != 2: 

200 raise ValueError("cbpAltitudeLimitsDeg={!r} must have length 2".format(cbpAltitudeLimitsDeg)) 

201 self.cbpAltitudeLimits = tuple(val*degrees for val in cbpAltitudeLimitsDeg) 

202 

203 @property 

204 def cbpPosition(self): 

205 """The position of the CBP in the base frame (mm, read/write).""" 

206 return self._cbpPosition 

207 

208 @property 

209 def cbpDistance(self): 

210 """The distance from the telescope to the CBP (mm, read only).""" 

211 return self._cbpDistance 

212 

213 @cbpPosition.setter 

214 def cbpPosition(self, cbpPosition): 

215 """Set the position of the CBP. 

216 

217 Parameters 

218 ---------- 

219 cbpPosition : triplet of `float` 

220 CBP x, y, z position of center of CBP relative to the center 

221 of the telescope, in the base frame (mm). 

222 """ 

223 if len(cbpPosition) != 3: 

224 raise ValueError("cbpPosition={!r} must have length 2".format(cbpPosition)) 

225 self._cbpPosition = np.array(cbpPosition) 

226 self._cbpDistance = np.linalg.norm(self.cbpPosition)