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 :
0 commit comments