Skip to content

Commit 6b29c18

Browse files
committed
short sp3, clk file name compatibility
1 parent d646aeb commit 6b29c18

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

gnss_lib_py/utils/ephemeris_downloader.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def load_ephemeris(file_type, gps_millis,
104104
105105
"""
106106

107+
if isinstance(file_paths, (str, os.PathLike)):
108+
file_paths = [file_paths]
109+
107110
existing_paths, needed_files = _verify_ephemeris(file_type,
108111
gps_millis,
109112
constellations,
@@ -477,6 +480,9 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
477480
for path in file_paths:
478481
if os.path.split(path)[1][10:] == os.path.split(recommended_file[1])[1][10:-3]:
479482
return True, path
483+
for path in file_paths:
484+
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".sp3":
485+
return True, path
480486

481487
# sp3 from last two weeks
482488
elif possible_type == "sp3_rapid_GFZ":
@@ -498,6 +504,9 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
498504
for path in file_paths:
499505
if os.path.split(path)[1][10:] == os.path.split(recommended_file[1])[1][10:-3]:
500506
return True, path
507+
for path in file_paths:
508+
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".sp3":
509+
return True, path
501510

502511
# sp3 if longer than two weeks ago
503512
elif possible_type == "sp3_final_CODE":
@@ -519,6 +528,9 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
519528
for path in file_paths:
520529
if os.path.split(path)[1][10:] == os.path.split(recommended_file[1])[1][10:-3]:
521530
return True, path
531+
for path in file_paths:
532+
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".sp3":
533+
return True, path
522534

523535
# clk from last three days
524536
elif possible_type == "clk_rapid_CODE":
@@ -540,6 +552,9 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
540552
for path in file_paths:
541553
if os.path.split(path)[1][10:] == os.path.split(recommended_file[1])[1][10:-3]:
542554
return True, path
555+
for path in file_paths:
556+
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".clk":
557+
return True, path
543558

544559
# clk from last two weeks
545560
elif possible_type == "clk_rapid_GFZ":
@@ -561,6 +576,9 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
561576
for path in file_paths:
562577
if os.path.split(path)[1][10:] == os.path.split(recommended_file[1])[1][10:-3]:
563578
return True, path
579+
for path in file_paths:
580+
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".clk":
581+
return True, path
564582

565583
# clk if longer than two weeks ago
566584
elif possible_type == "clk_final_CODE":
@@ -582,6 +600,9 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
582600
for path in file_paths:
583601
if os.path.split(path)[1][10:] == os.path.split(recommended_file[1])[1][10:-3]:
584602
return True, path
603+
for path in file_paths:
604+
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".clk":
605+
return True, path
585606

586607
else:
587608
raise RuntimeError(possible_type,"invalid possible_type "\

tests/utils/test_ephemeris_downloader.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def remove_download_eph(ephem_download_path):
113113
@pytest.mark.parametrize('paths',
114114
[
115115
None,
116+
"",
116117
lazy_fixture("all_ephem_paths"),
117118
])
118119
def test_load_ephemeris_rinex_nav(ephem_params, ephem_path, paths):
@@ -509,19 +510,49 @@ def test_verify_ephemeris():
509510
assert len(existing_paths) == 0
510511
assert needed_files[0][0] == 'igs-ftp.bkg.bund.de'
511512

512-
def test_valid_ephemeris(all_ephem_paths):
513+
def test_valid_ephemeris(all_ephem_paths,sp3_path,clk_path):
513514
"""Extra tests for full valid coverage.
514515
515516
Parameters
516517
----------
517518
all_ephem_paths : string
518519
Location of all unit test ephemeris files.
520+
sp3_path : string
521+
String with location for the unit_test sp3 measurements
522+
clk_path : string
523+
String with location for the unit_test clk measurements
519524
520525
"""
521526

522-
date = datetime(2023,3,14).astimezone(timezone.utc).date()
527+
date = datetime(2023,3,14,2).date()
523528
valid, path = ed._valid_ephemeris_in_paths(date,
524529
["rinex_nav_today"],
525530
file_paths=all_ephem_paths)
526531
assert valid
527532
assert os.path.split(path)[-1] == "BRDC00WRD_S_20230730000_01D_MN.rnx"
533+
534+
# check sp3 and clk short file names
535+
date = datetime(2021,4,28)
536+
valid, path = ed._valid_ephemeris_in_paths(date,
537+
["sp3_rapid_CODE"],
538+
file_paths=[sp3_path,clk_path])
539+
assert valid
540+
assert os.path.split(path)[-1] == "grg21553.sp3"
541+
date = datetime(2021,4,28)
542+
valid, path = ed._valid_ephemeris_in_paths(date,
543+
["sp3_rapid_GFZ"],
544+
file_paths=[sp3_path,clk_path])
545+
assert valid
546+
assert os.path.split(path)[-1] == "grg21553.sp3"
547+
date = datetime(2021,4,28)
548+
valid, path = ed._valid_ephemeris_in_paths(date,
549+
["clk_rapid_CODE"],
550+
file_paths=[sp3_path,clk_path])
551+
assert valid
552+
assert os.path.split(path)[-1] == "grg21553.clk"
553+
date = datetime(2021,4,28)
554+
valid, path = ed._valid_ephemeris_in_paths(date,
555+
["clk_rapid_GFZ"],
556+
file_paths=[sp3_path,clk_path])
557+
assert valid
558+
assert os.path.split(path)[-1] == "grg21553.clk"

0 commit comments

Comments
 (0)