/
test_surface_intercept_point.py
279 lines (248 loc) · 8.5 KB
/
test_surface_intercept_point.py
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# -*- coding: utf-8 -*-
'''Test WGC surface intercpt point calculation.'''
import pytest
from webgeocalc import SurfaceInterceptPoint
from webgeocalc.errors import CalculationInvalidAttr, CalculationUndefinedAttr
@pytest.fixture
def kernels():
'''Cassini kernel set.'''
return 5
@pytest.fixture
def time():
'''Input time.'''
return '2012-10-19T08:24:00.000'
@pytest.fixture
def target():
'''Input target.'''
return 'ENCELADUS'
@pytest.fixture
def target_frame():
'''Input target frame.'''
return 'IAU_ENCELADUS'
@pytest.fixture
def observer():
'''Input observer.'''
return 'CASSINI'
@pytest.fixture
def direction_vector_type_1():
'''Input direction vector type 1.'''
return 'INSTRUMENT_BORESIGHT'
@pytest.fixture
def direction_vector_type_2():
'''Input direction vector type 2.'''
return 'REFERENCE_FRAME_AXIS'
@pytest.fixture
def direction_vector_type_3():
'''Input direction vector type 3.'''
return 'VECTOR_IN_INSTRUMENT_FOV'
@pytest.fixture
def direction_vector_type_4():
'''Input direction vector type 4.'''
return 'VECTOR_IN_REFERENCE_FRAME'
@pytest.fixture
def direction_instrument():
'''Input direction instrument.'''
return 'CASSINI_ISS_NAC'
@pytest.fixture
def direction_frame():
'''Input direction frame.'''
return 'CASSINI_ISS_NAC'
@pytest.fixture
def direction_frame_axis():
'''Input direction axis.'''
return 'Z'
@pytest.fixture
def corr():
'''Input aberration correction.'''
return 'NONE'
@pytest.fixture
def state():
'''Input state.'''
return 'LATITUDINAL'
@pytest.fixture
def params_1(kernels, time, target, target_frame, observer, direction_vector_type_1,
direction_instrument, corr, state):
'''Input parameters from WGC API example 1.'''
return {
'kernels': kernels,
'times': time,
'target': target,
'target_frame': target_frame,
'observer': observer,
'direction_vector_type': direction_vector_type_1,
'direction_instrument': direction_instrument,
'aberration_correction': corr,
'state_representation': state,
}
@pytest.fixture
def payload_1(kernels, time, target, target_frame, observer, direction_vector_type_1,
direction_instrument, corr, state):
'''Payload from WGC API example 1.'''
return {
"kernels": [{
"type": "KERNEL_SET",
"id": kernels,
}],
"timeSystem": "UTC",
"timeFormat": "CALENDAR",
"times": [
time,
],
"calculationType": "SURFACE_INTERCEPT_POINT",
"target": target,
"shape1": "ELLIPSOID",
"targetFrame": target_frame,
"observer": observer,
"directionVectorType": direction_vector_type_1,
"directionInstrument": direction_instrument,
"aberrationCorrection": corr,
"stateRepresentation": state,
}
@pytest.fixture
def params_2(kernels, time, target, target_frame, observer, direction_vector_type_2,
direction_frame, direction_frame_axis, corr):
'''Input parameters from WGC API example 2.'''
return {
'kernels': kernels,
'times': time,
'target': target,
'target_frame': target_frame,
'observer': observer,
'direction_vector_type': direction_vector_type_2,
'direction_frame': direction_frame,
'direction_frame_axis': direction_frame_axis,
'aberration_correction': corr,
}
@pytest.fixture
def payload_2(kernels, time, target, target_frame, observer, direction_vector_type_2,
direction_frame, direction_frame_axis, corr):
'''Payload from WGC API example 2.'''
return {
"kernels": [{
"type": "KERNEL_SET",
"id": kernels,
}],
"timeSystem": "UTC",
"timeFormat": "CALENDAR",
"times": [
time,
],
"calculationType": "SURFACE_INTERCEPT_POINT",
"target": target,
"shape1": "ELLIPSOID",
"targetFrame": target_frame,
"observer": observer,
"directionVectorType": direction_vector_type_2,
"directionFrame": direction_frame,
"directionFrameAxis": direction_frame_axis,
"aberrationCorrection": corr,
"stateRepresentation": "RECTANGULAR",
}
@pytest.fixture
def params_3(kernels, time, target, target_frame, observer, direction_vector_type_3,
direction_instrument, corr):
'''Input parameters from WGC API example 3.'''
return {
'kernels': kernels,
'times': time,
'target': target,
'target_frame': target_frame,
'observer': observer,
'direction_vector_type': direction_vector_type_3,
"direction_instrument": direction_instrument,
'direction_vector_x': 0,
'direction_vector_y': 0,
'direction_vector_z': 1,
'aberration_correction': corr,
}
@pytest.fixture
def payload_3(kernels, time, target, target_frame, observer, direction_vector_type_3,
direction_instrument, corr):
'''Payload from WGC API example 3.'''
return {
"kernels": [{
"type": "KERNEL_SET",
"id": kernels,
}],
"timeSystem": "UTC",
"timeFormat": "CALENDAR",
"times": [
time,
],
"calculationType": "SURFACE_INTERCEPT_POINT",
"target": target,
"shape1": "ELLIPSOID",
"targetFrame": target_frame,
"observer": observer,
"directionVectorType": direction_vector_type_3,
"directionInstrument": direction_instrument,
"directionVectorX": 0,
"directionVectorY": 0,
"directionVectorZ": 1,
"aberrationCorrection": corr,
"stateRepresentation": "RECTANGULAR",
}
@pytest.fixture
def params_4(kernels, time, target, target_frame, observer, direction_vector_type_4,
direction_frame, corr):
'''Input parameters from WGC API example 4.'''
return {
'kernels': kernels,
'times': time,
'target': target,
'target_frame': target_frame,
'observer': observer,
'direction_vector_type': direction_vector_type_4,
"direction_frame": direction_frame,
'direction_vector_ra': 0,
'direction_vector_dec': 90,
'aberration_correction': corr,
}
@pytest.fixture
def payload_4(kernels, time, target, target_frame, observer, direction_vector_type_4,
direction_frame, corr):
'''Payload from WGC API example 4.'''
return {
"kernels": [{
"type": "KERNEL_SET",
"id": kernels,
}],
"timeSystem": "UTC",
"timeFormat": "CALENDAR",
"times": [
time,
],
"calculationType": "SURFACE_INTERCEPT_POINT",
"target": target,
"shape1": "ELLIPSOID",
"targetFrame": target_frame,
"observer": observer,
"directionVectorType": direction_vector_type_4,
"directionFrame": direction_frame,
"directionVectorRA": 0,
"directionVectorDec": 90,
"aberrationCorrection": corr,
"stateRepresentation": "RECTANGULAR",
}
def test_surface_direction_point_payload_boresight(params_1, payload_1):
'''Test surface direction point payload with INSTRUMENT_BORESIGHT.'''
assert SurfaceInterceptPoint(**params_1).payload == payload_1
def test_surface_direction_point_payload_reference_frame_axis(params_2, payload_2):
'''Test surface direction point payload with REFERENCE_FRAME_AXIS.'''
assert SurfaceInterceptPoint(**params_2).payload == payload_2
def test_surface_direction_point_payload_vector_in_instrument_fov(params_3, payload_3):
'''Test surface direction point payload with VECTOR_IN_INSTRUMENT_FOV.'''
assert SurfaceInterceptPoint(**params_3).payload == payload_3
def test_surface_direction_point_payload_vector_in_reference_frame(params_4, payload_4):
'''Test surface direction point payload with VECTOR_IN_REFERENCE_FRAME.'''
assert SurfaceInterceptPoint(**params_4).payload == payload_4
def test_surface_direction_point_attr_error(params_1):
'''Test errors when surface direction point attributes is invalid.'''
with pytest.raises(CalculationInvalidAttr):
SurfaceInterceptPoint(shape_1='POINT', **params_1)
def test_surface_direction_point_payload_vector_in_instrument_fov_err(params_3):
'''Test errors when VECTOR_IN_INSTRUMENT_FOV is invalid.'''
del params_3['direction_vector_x']
with pytest.raises(CalculationUndefinedAttr):
# Missing 'direction_vector_x'
SurfaceInterceptPoint(**params_3)