Skip to content

Commit 4a34147

Browse files
committed
Passes some tests finally
1 parent f80bb31 commit 4a34147

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

laika/astro_dog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def download_parse_orbit(self, gps_time: GPSTime, skip_before_epoch=None) -> dic
217217
ephems = parse_sp3_orbits(files, self.valid_const, skip_before_epoch)
218218
return ephems
219219

220-
def get_orbit_data(self, time: GPSTime, only_predictions=False):
220+
def get_orbit_data(self, time: GPSTime):
221221
ephems_sp3 = self.download_parse_orbit(time)
222222
if sum([len(v) for v in ephems_sp3.values()]) < 5:
223223
raise RuntimeError(f'No orbit data found. For Time {time.as_datetime()} constellations {self.valid_const} valid ephem types {self.valid_ephem_types}')

laika/downloader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,13 @@ def download_orbits_gps(time, cache_dir, ephem_types):
324324

325325
folder_path = "%i/" % time.week
326326
filenames = []
327+
compression = '.gz'
327328

328329
if time.week < 2238:
329-
assert EphemerisType.FINAL_ORBIT in ephem_types, "Only final orbits are available before 2238"
330-
compression = '.Z'
331-
filenames.extend(['igs{wwww}{dow}.sp3'.format(wwww=time.week, dow=time.dow)])
330+
assert EphemerisType.FINAL_ORBIT in ephem_types, f"Only final orbits are available before 2238, {ephem_types}"
331+
filenames.extend(['COD0MGXFIN_{yyyy}{doy:03d}0000_01D_05M_ORB.SP3'.format(yyyy=time.year, doy=time.doy)])
332332
else:
333333
# TODO deal with version number
334-
compression = '.gz'
335334
ephem_strs = {
336335
EphemerisType.FINAL_ORBIT: ['COD0OPSFIN_{yyyy}{doy:03d}0000_01D_05M_ORB.SP3'.format(yyyy=time.year, doy=time.doy)],
337336
EphemerisType.RAPID_ORBIT: ['COD0OPSRAP_{yyyy}{doy:03d}0000_01D_05M_ORB.SP3'.format(yyyy=time.year, doy=time.doy)],
@@ -349,6 +348,7 @@ def download_orbits_gps(time, cache_dir, ephem_types):
349348

350349
folder_file_names = [(folder_path, filename) for filename in filenames]
351350
ret = download_and_cache_file_return_first_success(url_bases, folder_file_names, cache_dir+'cddis_products/', compression=compression)
351+
print(filenames)
352352
return ret
353353

354354

laika/ephemeris.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def all_orbits():
4242

4343
@classmethod
4444
def from_file_name(cls, file_name: str):
45-
if "/final" in file_name or "/igs" in file_name or 'OPSFIN' in file_name:
45+
if "MGXFIN" in file_name or 'OPSFIN' in file_name:
4646
return EphemerisType.FINAL_ORBIT
47-
if "/rapid" in file_name or "/igr" in file_name or 'OPSRAP' in file_name:
47+
if 'OPSRAP' in file_name:
4848
return EphemerisType.RAPID_ORBIT
49-
if "/ultra" in file_name or "/igu" in file_name or "COD0OPSULT" in file_name or 'OPSULT' in file_name:
49+
if 'OPSULT' in file_name:
5050
return EphemerisType.ULTRA_RAPID_ORBIT
5151
raise RuntimeError(f"Ephemeris type not found in filename: {file_name}")
5252

@@ -325,8 +325,9 @@ def parse_sp3_orbits(file_names, supported_constellations, skip_until_epoch: GPS
325325

326326
def read_prn_data(data, prn, deg=16, deg_t=1):
327327
np_data_prn = np.array(data[prn], dtype=object)
328-
# Currently, don't even bother with satellites that have unhealthy times
329-
if len(np_data_prn) == 0 or (np_data_prn[:, 5] > .99).any():
328+
# > .99 is unhealthy time
329+
np_data_prn = np_data_prn[np_data_prn[:, 5] < .99]
330+
if len(np_data_prn) == 0:
330331
return []
331332
ephems = []
332333
for i in range(len(np_data_prn) - deg):

tests/test_ephemerides.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
import numpy as np
22
import unittest
33

4+
from datetime import datetime
45
from laika.ephemeris import EphemerisType, read_prn_data
56
from laika.gps_time import GPSTime
7+
from laika.constants import SECS_IN_DAY
68
from laika import AstroDog
79

8-
gps_times_list = [[1999, 415621.0],
9-
[2045, 455457.0],
10-
[1985, 443787.0]]
10+
gps_times_list = [[2100, 415621.0],
11+
[2200, 455457.0],
12+
[2300, 443787.0]]
1113

12-
svIds = ['G01', 'G31', 'R08']
14+
svIds = ['G07', 'G31', 'R08']
1315
gps_times = [GPSTime(*gps_time_list) for gps_time_list in gps_times_list]
1416

1517

1618
class TestAstroDog(unittest.TestCase):
17-
'''
1819
def test_nav_vs_orbit_now(self):
19-
dog_orbit = AstroDog(valid_ephem_types=EphemerisType.orbits())
20+
dog_orbit = AstroDog(valid_ephem_types=EphemerisType.all_orbits())
2021
dog_nav = AstroDog(valid_ephem_types=EphemerisType.NAV)
2122
gps_time = GPSTime.from_datetime(datetime.utcnow()) - SECS_IN_DAY*2
2223
for svId in svIds:
2324
sat_info_nav = dog_nav.get_sat_info(svId, gps_time)
2425
sat_info_orbit = dog_orbit.get_sat_info(svId, gps_time)
25-
np.testing.assert_allclose(sat_info_nav[0], sat_info_orbit[0], rtol=0, atol=5)
26-
np.testing.assert_allclose(sat_info_nav[1], sat_info_orbit[1], rtol=0, atol=.1)
26+
np.testing.assert_allclose(sat_info_nav[0], sat_info_orbit[0], rtol=0, atol=5e2)
27+
np.testing.assert_allclose(sat_info_nav[1], sat_info_orbit[1], rtol=0, atol=1e0)
2728
np.testing.assert_allclose(sat_info_nav[2], sat_info_orbit[2], rtol=0, atol=1e-7)
28-
np.testing.assert_allclose(sat_info_nav[3], sat_info_orbit[3], rtol=0, atol=1e-11)
29-
'''
29+
np.testing.assert_allclose(sat_info_nav[3], sat_info_orbit[3], rtol=0, atol=1e-10)
3030

3131
def test_nav_vs_orbit_old(self):
3232
dog_orbit = AstroDog(valid_ephem_types=EphemerisType.all_orbits())
3333
dog_nav = AstroDog(valid_ephem_types=EphemerisType.NAV)
3434
for gps_time in gps_times:
3535
for svId in svIds:
36-
print(svId, gps_time)
3736
sat_info_nav = dog_nav.get_sat_info(svId, gps_time)
3837
assert sat_info_nav is not None
3938
sat_info_orbit = dog_orbit.get_sat_info(svId, gps_time)

tests/test_fetch_sat_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_no_block_satellite_when_get_info_from_not_available_period(self):
3030
self.assertIsNotNone(sat_info)
3131

3232
def test_get_all_sat_info_gps(self):
33-
time = GPSTime.from_datetime(datetime(2020, 5, 1, 12, 0, 0))
33+
time = GPSTime.from_datetime(datetime(2024, 5, 1, 12, 0, 0))
3434
all_ephem_types = (EphemerisType.FINAL_ORBIT, EphemerisType.RAPID_ORBIT, EphemerisType.ULTRA_RAPID_ORBIT, EphemerisType.NAV)
3535
kwargs_list = [
3636
*[{"valid_const": [ConstellationId.GPS], "valid_ephem_types": ephem_type} for ephem_type in all_ephem_types],

0 commit comments

Comments
 (0)