Skip to content

Commit 28014bc

Browse files
committed
handle missing directory outliers
1 parent 4d3b72d commit 28014bc

2 files changed

Lines changed: 41 additions & 11 deletions

File tree

gnss_lib_py/utils/ephemeris_downloader.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@
112112
113113
"""
114114

115-
# CLK: 2020, 7, 2
116-
117115
__authors__ = "Shubh Gupta, Ashwin Kanhere, Derek Knowles"
118116
__date__ = "13 July 2021"
119117

@@ -171,7 +169,6 @@ def load_ephemeris(file_type, gps_millis,
171169
constellations,
172170
file_paths,
173171
verbose)
174-
175172
try:
176173
downloaded_paths = _download_ephemeris(file_type,
177174
needed_files,
@@ -180,22 +177,53 @@ def load_ephemeris(file_type, gps_millis,
180177
# try second options for some files
181178
if verbose:
182179
print(err)
183-
print("Retrying download...")
184180
if "Connection timed out" in str(err): #pragma: no cover
185-
pass
186-
elif "WUM0MGXFIN" in str(err):
181+
if verbose:
182+
print("Retrying download.")
183+
elif "WUM0MGXFIN" in str(err) and file_type == "clk":
184+
if verbose:
185+
print("Retrying download with GFZ0MGXRAP.")
187186
needed_files = [(x[0],x[1].replace("WUM0MGXFIN","GFZ0MGXRAP"))
188187
for x in needed_files]
189-
elif "wum" in str(err):
188+
elif "wum" in str(err) and file_type == "clk":
189+
if verbose:
190+
print("Retrying download with gbm.")
190191
needed_files = [(x[0],x[1].replace("wum","gbm"))
191192
for x in needed_files]
192-
elif "BRDM00DLR_R" in str(err):
193+
elif "BRDM00DLR" in str(err) and file_type == "rinex_nav":
194+
if verbose:
195+
print("Retrying download with BRDC00IGS.")
196+
needed_files = [(x[0],x[1].replace("BRDM00DLR_S","BRDC00IGS_R"))
197+
for x in needed_files]
193198
needed_files = [(x[0],x[1].replace("BRDM00DLR_R","BRDC00IGS_R"))
194199
for x in needed_files]
195200

201+
try:
202+
# second download attempt
196203
downloaded_paths = _download_ephemeris(file_type,
197204
needed_files,
198-
download_directory, verbose)
205+
download_directory,
206+
verbose)
207+
except ftplib.error_perm as err:
208+
# on Nov 26, 2013 - Dec 5, 2013 the entire DDD/YYp/ directory
209+
# is missing, so use gps and glonass only in that case.
210+
if "BRDC00IGS_R" in str(err) and file_type == "rinex_nav":
211+
if verbose:
212+
print("Retrying download with gps/glonass only.")
213+
_,needed_gps = _verify_ephemeris(file_type,
214+
gps_millis,
215+
["gps"],
216+
verbose=verbose)
217+
_,needed_glonass = _verify_ephemeris(file_type,
218+
gps_millis,
219+
["glonass"],
220+
verbose=verbose)
221+
needed_files = needed_gps + needed_glonass
222+
# third download attempt
223+
downloaded_paths = _download_ephemeris(file_type,
224+
needed_files,
225+
download_directory,
226+
verbose)
199227

200228
if verbose:
201229
if len(existing_paths) > 0:

tests/utils/test_ephemeris_downloader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,14 @@ def test_ftp_download(ephem_download_path):
482482
remove_download_eph(ephem_download_path)
483483

484484
# test when BRDM00DLR_R doesn't exist and is replaced
485+
# use case between Nov 26, 2013 - Dec 5, 2013 when the entire
486+
# DDD/YYp/ directory is missing
485487
paths = ed.load_ephemeris("rinex_nav",
486-
tc.datetime_to_gps_millis(datetime(2016,6,24,12,
488+
tc.datetime_to_gps_millis(datetime(2013,12,3,12,
487489
tzinfo=timezone.utc)),
488490
download_directory=ephem_download_path,
489491
verbose=True)
490-
assert os.path.getsize(paths[0]) > 1E6
492+
assert os.path.getsize(paths[0]) > 1E5
491493
remove_download_eph(ephem_download_path)
492494

493495
def download_igs(requests_url):

0 commit comments

Comments
 (0)