Skip to content

Commit 6933296

Browse files
committed
start of updated downloader
1 parent c14fdac commit 6933296

1 file changed

Lines changed: 95 additions & 10 deletions

File tree

gnss_lib_py/utils/ephemeris_downloader.py

Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,52 @@
3737
rapid solution from GFZ is downloaded (GFZ0MGXRAP). The GFZ rapid
3838
solution became available starting GPS week 2038 or Jan 27, 2019. The
3939
GFZ rapid solution includes: GPS+GLO+GAL+BDS+QZS
40+
More about the GFZ solution can be found on their MGEX website [8]_.
4041
4142
If the SP3 or CLK date requested is more than two weeks previous to the
4243
current date, then the CODE final solution is downloaded (COD0MGXFIN).
43-
The CODE final solutions became available starting GPS week 1962 or
44-
Aug 13, 2017. The CODE final solution includes: GPS+GLO+GAL+BDS+QZS
44+
The CODE final SP3 solutions became available starting GPS week 1962 or
45+
Aug 13, 2017.
46+
47+
The CODE final CLK solution becomes available GPS week 2113
48+
or July 5th, 2020.
49+
50+
The CODE final solution includes: GPS+GLO+GAL+BDS+QZS
51+
More about the CODE solution can be found in their papers [6]_[7]_.
52+
53+
WUM0MGXFIN for CLK from week 2035 to week 2112
54+
55+
for week 2034??
56+
57+
wum for CLK from week 1962 to week 2033
58+
59+
com available week 1690 and after for SP3
60+
week 1710 and after for clk and both end on week 1961.
61+
More about the CODE com solution can be found in their papers [9]_[10]_.
62+
63+
gbm available week 2017 day 772 and after
4564
4665
Details on the MGEX precise orbit and clock products can be found on the
4766
IGS website [4]_.
4867
68+
IGS files can be viewed online using their file browser [5]_.
69+
4970
References
5071
----------
5172
.. [1] https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/daily_30second_data.html
5273
.. [2] https://igs.org/mgex/data-products/#bce
5374
.. [3] https://network.igs.org/
5475
.. [4] https://igs.org/mgex/data-products/#orbit_clock
55-
76+
.. [5] https://igs.bkg.bund.de/browseFiles
77+
.. [6] http://dx.doi.org/10.1016/j.asr.2020.04.038
78+
.. [7] http://dx.doi.org/10.7892/boris.75882.3
79+
.. [8] https://www.gfz-potsdam.de/en/section/space-geodetic-techniques/projects/mgex
80+
.. [9] http://doi.org/10.1007/1345_2015_161
81+
.. [10] http://doi.org/10.1007/s00190-016-0968-8
5682
"""
5783

84+
# CLK: 2020, 7, 2
85+
5886
__authors__ = "Shubh Gupta, Ashwin Kanhere, Derek Knowles"
5987
__date__ = "13 July 2021"
6088

@@ -87,7 +115,7 @@ def load_ephemeris(file_type, gps_millis,
87115
GPS milliseconds for which downloaded ephemeris should be
88116
obtained.
89117
constellations : list, set, or array-like
90-
Constellations for which to download ephemeris.
118+
Constellations for which to download ephemeris, i.e. ["gps"].
91119
file_paths : list, string or path-like
92120
Paths to existing ephemeris files if they exist.
93121
download_directory : string or path-like
@@ -138,7 +166,7 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
138166
GPS milliseconds for which downloaded ephemeris should be
139167
obtained.
140168
constellations : list, set, or array-like
141-
Constellations for which to download ephemeris.
169+
Constellations for which to download ephemeris, i.e. ["gps"].
142170
file_paths : string or path-like
143171
Paths to existing ephemeris files if they exist.
144172
verbose : bool
@@ -165,6 +193,10 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
165193
possible_types = []
166194

167195
if file_type == "rinex_nav":
196+
if date < datetime(2013,1,1):
197+
raise RuntimeError("gnss_lib_py cannot automatically " \
198+
+ "download rinex nav files for "\
199+
+ "times before Jan 1, 2013")
168200
if datetime.utcnow().date() == date:
169201
possible_types = ["rinex_nav_today"]
170202
else:
@@ -185,20 +217,32 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
185217
possible_types += ["rinex_nav_multi_s"]
186218

187219
if file_type == "sp3":
220+
if date < datetime(2017,8,13):
221+
raise RuntimeError("gnss_lib_py cannot automatically " \
222+
+ "download sp3 files for "\
223+
+ "times before Aug 13, 2017")
188224
if datetime.utcnow().date() - timedelta(days=3) < date:
189225
possible_types += ["sp3_rapid_CODE"]
190226
elif datetime.utcnow().date() - timedelta(days=14) < date:
191227
possible_types += ["sp3_rapid_GFZ"]
192-
else:
228+
elif date >= datetime(2017, 8, 13).date():
193229
possible_types += ["sp3_final_CODE"]
230+
else:
231+
possible_types += ["sp3_final_GFZ"]
194232

195233
if file_type == "clk":
234+
if date < datetime(2017,8,13):
235+
raise RuntimeError("gnss_lib_py cannot automatically " \
236+
+ "download clk files for "\
237+
+ "times before Aug 13, 2017")
196238
if datetime.utcnow().date() - timedelta(days=3) < date:
197239
possible_types += ["clk_rapid_CODE"]
198240
elif datetime.utcnow().date() - timedelta(days=14) < date:
199241
possible_types += ["clk_rapid_GFZ"]
200-
else:
242+
elif date >= datetime(2017, 8, 13).date():
201243
possible_types += ["clk_final_CODE"]
244+
else:
245+
possible_types += ["clk_final_GFZ"]
202246

203247
already_exists, filepath = _valid_ephemeris_in_paths(date,
204248
possible_types, file_paths)
@@ -401,7 +445,6 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
401445
if os.path.split(path)[1][-22:] == recommended_file[1][-25:-3]:
402446
return True, path
403447

404-
405448
# rinex that only contains GPS
406449
elif possible_type == "rinex_nav_gps":
407450
recommended_file = ("gdc.cddis.eosdis.nasa.gov",
@@ -508,7 +551,7 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
508551
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".sp3":
509552
return True, path
510553

511-
# sp3 if longer than two weeks ago
554+
# sp3 if longer than two weeks ago and more recent than Aug 13, 2017
512555
elif possible_type == "sp3_final_CODE":
513556
gps_week, _ = tc.datetime_to_tow(datetime.combine(date,
514557
time(tzinfo=timezone.utc)))
@@ -532,6 +575,27 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
532575
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".sp3":
533576
return True, path
534577

578+
# sp3 before Aug 13, 2017
579+
elif possible_type == "sp3_final_GFZ":
580+
gps_week, _ = tc.datetime_to_tow(datetime.combine(date,
581+
time(tzinfo=timezone.utc)))
582+
recommended_file = ("gdc.cddis.eosdis.nasa.gov",
583+
"/gnss/products/" \
584+
+ str(gps_week).zfill(4) + "/" \
585+
+ "gbm" + str(gps_week).zfill(4) \
586+
+ str((timetuple.tm_wday+1)%7) \
587+
+ ".sp3.Z")
588+
recommended_files.append(recommended_file)
589+
if file_paths is None:
590+
return False, recommended_file
591+
# check compatible file types
592+
for path in file_paths:
593+
if os.path.split(path)[1] + ".Z" == os.path.split(recommended_file[1])[1]:
594+
return True, path
595+
for path in file_paths:
596+
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1]:
597+
return True, path
598+
535599
# clk from last three days
536600
elif possible_type == "clk_rapid_CODE":
537601
gps_week, _ = tc.datetime_to_tow(datetime.combine(date,
@@ -580,7 +644,7 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
580644
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".clk":
581645
return True, path
582646

583-
# clk if longer than two weeks ago
647+
# clk if longer than two weeks ago and more recent than Aug 13, 2017
584648
elif possible_type == "clk_final_CODE":
585649
gps_week, _ = tc.datetime_to_tow(datetime.combine(date,
586650
time(tzinfo=timezone.utc)))
@@ -604,6 +668,27 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
604668
if os.path.split(path)[1][3:] == str(gps_week).zfill(4) + str((timetuple.tm_wday+1)%7) + ".clk":
605669
return True, path
606670

671+
# clk before Aug 13, 2017
672+
elif possible_type == "clk_final_GFZ":
673+
gps_week, _ = tc.datetime_to_tow(datetime.combine(date,
674+
time(tzinfo=timezone.utc)))
675+
recommended_file = ("gdc.cddis.eosdis.nasa.gov",
676+
"/gnss/products/" \
677+
+ str(gps_week).zfill(4) + "/" \
678+
+ "gbm" + str(gps_week).zfill(4) \
679+
+ str((timetuple.tm_wday+1)%7) \
680+
+ ".clk.Z")
681+
recommended_files.append(recommended_file)
682+
if file_paths is None:
683+
return False, recommended_file
684+
# check compatible file types
685+
for path in file_paths:
686+
if os.path.split(path)[1] + ".Z" == os.path.split(recommended_file[1])[1]:
687+
return True, path
688+
for path in file_paths:
689+
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1]:
690+
return True, path
691+
607692
else:
608693
raise RuntimeError(possible_type,"invalid possible_type "\
609694
+"for valid ephemeris")

0 commit comments

Comments
 (0)