-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.py
287 lines (277 loc) · 11.9 KB
/
test.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
280
281
282
283
284
285
286
287
import pathlib
import sp3
import unittest
dirname = pathlib.Path(__file__).resolve().parent
class TestSp3(unittest.TestCase):
def assertRelativeAlmostEqual(
self, first: float, second: float, maximum_relative_error: float = 1e-9
):
if first == 0.0 and second == 0.0:
return
self.assertLess(
abs((first - second) / (first if second == 0.0 else second)),
maximum_relative_error,
)
def assertVectorEqual(
self, first: tuple[float, float, float], second: tuple[float, float, float]
):
for index in range(0, 3):
self.assertRelativeAlmostEqual(first[index], second[index])
def test_emr21000(self):
# https://cddis.nasa.gov/archive/gnss/products/2100/emr21000.sp3.Z
product = sp3.Product.from_file(dirname / "test_products" / "emr21000.sp3")
self.assertEqual(product.version, sp3.Version.C)
self.assertEqual(product.file_type, sp3.FileType.GPS)
self.assertEqual(product.time_system, sp3.timesystem.TimeSystem.GPS)
self.assertEqual(product.data_used, b"U")
self.assertEqual(product.coordinate_system, b"IGS14")
self.assertEqual(product.orbit_type, b"FIT")
self.assertEqual(product.agency, b"EMR")
self.assertListEqual(
product.comments,
[
b"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
b"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
b"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
b"PCV:IGS14_1935 OL/AL:FES2004 NONE YN ORB:CoN CLK:CoN",
],
)
self.assertEqual(len(product.satellites), 32)
for satellite in product.satellites:
self.assertEqual(len(satellite.records), 96)
self.assertEqual(product.satellites[0].id, b"G01")
self.assertEqual(
product.satellites[0].records[0].time.isoformat(),
"2020-04-04T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[0].position,
(21163886.281, 13420060.103, 9081657.071),
)
self.assertRelativeAlmostEqual(
product.satellites[0].records[0].clock, -0.000348529159 # type: ignore
)
self.assertEqual(
product.satellites[0].records[-1].time.isoformat(),
"2020-04-05T23:44:42+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[-1].position,
(20683557.342, 12721489.456, 10936561.064),
)
self.assertRelativeAlmostEqual(
product.satellites[0].records[-1].clock, -0.000349505066 # type: ignore
)
self.assertEqual(product.satellites[-1].id, b"G32")
self.assertEqual(
product.satellites[-1].records[0].time.isoformat(),
"2020-04-04T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[-1].records[0].position,
(-14732619.696, 15325155.155, 15908182.296),
)
self.assertRelativeAlmostEqual(
product.satellites[-1].records[0].clock, 0.000252210148 # type: ignore
)
self.assertEqual(
product.satellites[-1].records[-1].time.isoformat(),
"2020-04-05T23:44:42+00:00",
)
self.assertVectorEqual(
product.satellites[-1].records[-1].position,
(-13358975.068, 15143246.089, 17254577.670),
)
self.assertRelativeAlmostEqual(
product.satellites[-1].records[-1].clock, 0.000252946982 # type: ignore
)
def test_nsgf_orb_ajisai_211220_v00(self):
# https://cddis.nasa.gov/archive/slr/products/orbits/ajisai/211220/nsgf.orb.ajisai.211220.v00.sp3.gz
product = sp3.Product.from_file(
dirname / "test_products" / "nsgf.orb.ajisai.211220.v00.sp3"
)
self.assertEqual(product.version, sp3.Version.C)
self.assertEqual(product.file_type, sp3.FileType.LEO)
self.assertEqual(product.time_system, sp3.timesystem.TimeSystem.UTC)
self.assertEqual(product.data_used, b"SLR")
self.assertEqual(product.coordinate_system, b"ECF")
self.assertEqual(product.orbit_type, b"FIT")
self.assertEqual(product.agency, b"NSGF")
self.assertListEqual(
product.comments,
[
b"Earth-centered-fixed orbital predictions from SGF ILRS AC",
b"The underlying ECF frame is that of IERS/ITRF",
b"Note: Solution based on 4-day long arc",
],
)
self.assertEqual(len(product.satellites), 1)
for satellite in product.satellites:
self.assertEqual(len(satellite.records), 1478)
self.assertEqual(product.satellites[0].id, b"L50")
self.assertEqual(
product.satellites[0].records[0].time.isoformat(),
"2021-12-16T00:00:00+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[0].position,
(-4586301.149, 2383308.229, 5926669.233),
)
self.assertVectorEqual(
product.satellites[0].records[0].velocity, # type: ignore
(-2050.9432000, -6356.8161000, 976.0648100),
)
self.assertIsNone(product.satellites[0].records[0].clock)
self.assertEqual(
product.satellites[0].records[-1].time.isoformat(),
"2021-12-20T02:28:00+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[-1].position,
(-4568661.503, 3087193.619, 5610808.976),
)
self.assertVectorEqual(
product.satellites[0].records[-1].velocity, # type: ignore
(-5109.7022000, -3939.3079000, -1982.5136000),
)
self.assertIsNone(product.satellites[0].records[-1].clock)
def test_igr21882(self):
# https://cddis.nasa.gov/archive/gnss/products/2188/igr21882.sp3.Z
product = sp3.Product.from_file(dirname / "test_products" / "igr21882.sp3")
self.assertEqual(product.version, sp3.Version.C)
self.assertEqual(product.file_type, sp3.FileType.GPS)
self.assertEqual(product.time_system, sp3.timesystem.TimeSystem.GPS)
self.assertEqual(product.data_used, b"ORBIT")
self.assertEqual(product.coordinate_system, b"IGb14")
self.assertEqual(product.orbit_type, b"HLM")
self.assertEqual(product.agency, b"IGS")
self.assertListEqual(
product.comments,
[
b"RAPID ORBIT COMBINATION FROM WEIGHTED AVERAGE OF:",
b"cod emr esa gfz jpl ngs sio usn whu",
b"REFERENCED TO IGS TIME (IGST) AND TO WEIGHTED MEAN POLE:",
b"PCV:IGS14_2186 OL/AL:FES2004 NONE Y ORB:CMB CLK:CMB",
],
)
self.assertEqual(len(product.satellites), 32)
for satellite in product.satellites:
self.assertEqual(len(satellite.records), 96)
self.assertEqual(product.satellites[0].id, b"G01")
self.assertEqual(
product.satellites[0].records[0].time.isoformat(),
"2021-12-13T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[0].position,
(12439850.240, -21691270.701, -8699268.697),
)
self.assertRelativeAlmostEqual(
product.satellites[0].records[0].clock, 0.000484801109 # type: ignore
)
self.assertEqual(
product.satellites[0].records[-1].time.isoformat(),
"2021-12-14T23:44:42+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[-1].position,
(11796938.686, -21224988.119, -10617300.036),
)
self.assertRelativeAlmostEqual(
product.satellites[0].records[-1].clock, 0.000483931034 # type: ignore
)
self.assertEqual(product.satellites[-1].id, b"G32")
self.assertEqual(
product.satellites[-1].records[0].time.isoformat(),
"2021-12-13T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[-1].records[0].position,
(15677566.080, 16199844.556, -14073948.839),
)
self.assertRelativeAlmostEqual(
product.satellites[-1].records[0].clock, -0.000034780613 # type: ignore
)
self.assertEqual(
product.satellites[-1].records[-1].time.isoformat(),
"2021-12-14T23:44:42+00:00",
)
self.assertVectorEqual(
product.satellites[-1].records[-1].position,
(15454109.950, 14960247.378, -15586329.017),
)
self.assertRelativeAlmostEqual(
product.satellites[-1].records[-1].clock, -0.000035242731 # type: ignore
)
def test_esa0mgnfin_20213460000_01d_05m_orb(self):
# http://navigation-office.esa.int/products/gnss-products/2188/ESA0MGNFIN_20213460000_01D_05M_ORB.SP3.gz
product = sp3.Product.from_file(
dirname / "test_products" / "ESA0MGNFIN_20213460000_01D_05M_ORB.SP3"
)
self.assertEqual(product.version, sp3.Version.D)
self.assertEqual(product.file_type, sp3.FileType.MIXED)
self.assertEqual(product.time_system, sp3.timesystem.TimeSystem.GPS)
self.assertEqual(product.data_used, b"ORBIT")
self.assertEqual(product.coordinate_system, b"ITRF")
self.assertEqual(product.orbit_type, b"BHN")
self.assertEqual(product.agency, b"ESOC")
self.assertListEqual(
product.comments,
[
b"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
b"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
b"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
b"PCV:IGS OL/AL:EOT11A NONE YN ORB:CoN CLK:CoN",
],
)
self.assertEqual(len(product.satellites), 116)
for satellite in product.satellites:
self.assertEqual(len(satellite.records), 289)
self.assertEqual(product.satellites[0].id, b"G13")
self.assertEqual(
product.satellites[0].records[0].time.isoformat(),
"2021-12-11T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[0].position,
(-13462439.424, 8521400.998, 21070022.207),
)
self.assertRelativeAlmostEqual(
product.satellites[0].records[0].clock, 0.000228071998 # type: ignore
)
self.assertEqual(
product.satellites[0].records[-1].time.isoformat(),
"2021-12-12T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[0].records[-1].position,
(-13576824.587, 7863384.875, 21253921.516),
)
self.assertRelativeAlmostEqual(
product.satellites[0].records[-1].clock, 0.000228574284 # type: ignore
)
self.assertEqual(product.satellites[-1].id, b"J04")
self.assertEqual(
product.satellites[-1].records[0].time.isoformat(),
"2021-12-11T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[-1].records[0].position,
(-25955007.071, 27861480.331, 24376352.859),
)
self.assertRelativeAlmostEqual(
product.satellites[-1].records[0].clock, 0.000109181452 # type: ignore
)
self.assertEqual(
product.satellites[-1].records[-1].time.isoformat(),
"2021-12-12T23:59:42+00:00",
)
self.assertVectorEqual(
product.satellites[-1].records[-1].position,
(-26000797.533, 27896444.575, 24260130.997),
)
self.assertRelativeAlmostEqual(
product.satellites[-1].records[-1].clock, 0.000110384373 # type: ignore
)
if __name__ == "__main__":
unittest.main()