Skip to content

Commit d79cc65

Browse files
committed
add secondary download options
1 parent d4cff64 commit d79cc65

7 files changed

Lines changed: 1528 additions & 22 deletions

File tree

data/unit_test/clk/WUM0MGXFIN_20190730000_01D_30S_CLK.CLK

Lines changed: 267 additions & 0 deletions
Large diffs are not rendered by default.

data/unit_test/clk/com19402.clk

Lines changed: 370 additions & 0 deletions
Large diffs are not rendered by default.

data/unit_test/clk/gbm20340.clk

Lines changed: 365 additions & 0 deletions
Large diffs are not rendered by default.

data/unit_test/clk/wum19923.clk

Lines changed: 245 additions & 0 deletions
Large diffs are not rendered by default.

data/unit_test/sp3/com19402.sp3

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#cP2017 3 14 0 0 0.00000000 97 d+D IGS14 FIT AIUB
2+
## 1940 172800.00000000 900.00000000 57826 0.0000000000000
3+
+ 76 G01G02G03G04G05G06G07G08G09G10G11G12G13G14G15G16G17
4+
+ G18G19G20G21G22G23G24G25G26G27G28G29G30G31G32R01R02
5+
+ R03R04R05R07R08R09R10R11R13R14R15R16R17R18R19R20R21
6+
+ R22R23R24E01E02E08E09E11E12E14E18E19E22E24E26E30C06
7+
+ C07C08C09C10C12C13C14J01 0 0 0 0 0 0 0 0 0
8+
++ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
9+
++ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
10+
++ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
11+
++ 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0
12+
++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
13+
%c M cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
14+
%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
15+
%f 1.2500000 1.025000000 0.00000000000 0.000000000000000
16+
%f 0.0000000 0.000000000 0.00000000000 0.000000000000000
17+
%i 0 0 0 0 0 0 0 0 0
18+
%i 0 0 0 0 0 0 0 0 0
19+
/* CODE MGEX orbits and clocks
20+
/* of DOY 17073
21+
/*
22+
/* PCV:IGS14 OL/AL:FES2004 NONE YN ORB:CoN CLK:CoN
23+
* 2017 3 14 0 0 0.00000000
24+
PG01 14000.457738 -21359.123323 6675.390241 51.239715
25+
PG02 -16273.905423 1779.532326 -20355.139566 459.417415
26+
PG03 17551.114209 -12969.316353 -15129.546849 -106.958887
27+
PG04 20101.384788 8361.308042 -15626.922154 999999.999999
28+
PG05 -26463.243312 1780.539029 -2891.748478 -55.937238
29+
PG06 -10180.970298 -12989.096093 -20784.412589 324.231587
30+
PG07 5895.089429 -24838.971002 6634.480758 373.492790
31+
PG08 14420.505976 -5805.292676 21604.418663 -52.686977
32+
PG09 -4444.422158 -22016.074161 -14198.357357 321.575538
33+
PG10 14379.543985 11584.348288 19152.589095 -94.464868
34+
PG11 11450.952138 -18753.602526 14388.826505 -674.783913
35+
PG12 -20594.214901 10233.704874 -13242.603164 387.062408
36+
PG13 -17600.438810 -3451.705135 19448.050645 -73.707190
37+
PG14 18244.964167 17444.117810 -8254.666430 -62.630306
38+
PG15 -13251.165761 8814.969318 21119.461093 -345.494060
39+
PG16 26581.608536 726.893110 -3323.143903 28.811952
40+
PG17 -14958.270466 -22050.862158 462.433415 -188.019711
41+
PG18 3362.945949 15895.641312 21589.174097 604.451042
42+
PG19 -17644.511332 -18101.194125 -7902.583416 -510.539787
43+
PG20 -19969.441286 13252.364288 11299.369080 463.941824
44+
PG21 631.492940 23893.847469 12206.673956 -517.487573
45+
PG22 23162.573492 -10166.551030 -7980.099947 73.980846
46+
PG23 7428.772631 -14658.716691 -20560.076565 -207.504772
47+
PG24 -14724.508861 19847.069064 9320.650096 -31.835842
48+
PG25 -7000.741246 15047.372664 -20824.312450 -351.712063
49+
PG26 22612.209273 5793.021701 -12751.524258 -518.633617
50+
PG27 19650.253478 7065.825640 16494.065496 223.644589
51+
PG28 -10182.341101 -13423.334234 21164.900808 596.720685
52+
PG29 921.313329 20888.200089 -16397.641457 620.536117
53+
PG30 -3883.119665 -19919.500192 17064.193793 160.243971
54+
PG31 11041.843849 11165.096966 -21288.210279 213.655938
55+
PG32 16273.711212 21018.403933 95.306456 -351.301438
56+
PR01 765.909598 11576.791802 22715.388423 9.069106
57+
PR02 19084.326877 11504.387944 12488.833775 240.061894
58+
PR03 24640.724988 4510.001407 -4876.426504 95.060668
59+
PR04 15439.313307 -5364.194762 -19575.346569 207.561464
60+
PR05 -2168.787850 -11845.333903 -22496.557256 -86.801510
61+
PR07 -24567.672089 -4295.700689 5309.096754 3.641262
62+
PR08 -15907.316907 5087.033567 19330.868625 -26.821831
63+
PR09 -5193.027238 -10095.140303 22848.973562 6.838792
64+
PR10 -17910.751123 6321.257215 17041.786896 18.254035
65+
PR11 -18908.540893 17114.602386 1081.128914 3.349562
66+
PR13 7306.915663 7877.877492 -23156.169146 2.035001
67+
PR14 18454.454435 -7605.837483 -15863.143255 460.412945
68+
PR15 19365.182385 -16343.685356 -3373.249688 4.548753
69+
PR16 8659.930613 -18565.507448 15250.003680 59.847366
70+
PR17 11907.157150 5856.302696 21793.446444 29.984093
71+
PR18 7124.129773 -12117.750083 21286.803754 142.728282
72+
PR19 -1686.481456 -24099.133681 8186.516245 -176.731018
73+
PR20 -9647.580212 -21225.537992 -10267.328567 -280.572537
74+
PR21 -11861.073789 -5998.767139 -21768.101298 106.836982
75+
PR22 -6485.835949 13446.786594 -20714.087472 230.493594
76+
PR23 3105.297210 24546.983656 -6222.162873 74.905150
77+
PR24 9983.736040 21193.888061 10095.885504 -148.076900
78+
PE01 -6905.389677 -14747.274450 24715.860890 -18.059275
79+
PE02 6928.706992 14733.655844 -24721.168249 -0.073730
80+
PE08 28041.502002 8493.001495 -4194.263869 6885.769030
81+
PE09 -21030.553693 6326.232844 19854.991777 7046.017260
82+
PE11 -13559.735989 13889.895857 -22347.368725 1672.861400
83+
PE12 -16869.052596 -7368.394690 -23162.873327 1045.497750
84+
PE14 6740.970204 -14990.011144 16776.756543 6543.102360
85+
PE18 -7909.375139 22153.717945 -22394.320012 7271.181720
86+
PE19 -17003.712449 -18815.027631 -15256.192020 7.686854
87+
PE22 10866.359699 25148.089772 11206.557701 4043.239260
88+
PE24 -24489.705165 16412.396854 2509.106828 -168.873064
89+
PE26 2142.702531 -28371.884503 8175.649425 7550.887950
90+
PE30 22447.079859 -1288.654640 -19269.282796 6980.978990
91+
PC06 -13080.576579 21210.171774 34179.077162 156.048012
92+
PC07 -24623.178490 32109.762716 -12364.345866 -117.480156
93+
PC08 -9165.600323 34751.450928 -21817.307480 -916.024353
94+
PC09 4401.525306 27249.857935 32060.634892 -105.193831
95+
PC10 -12082.197048 32919.937208 -23539.191969 -429.984959
96+
PC12 17234.145260 2198.575590 21865.374314 814.513687
97+
PC13 914.485752 41385.428948 -7351.764151 552.746004
98+
PC14 17150.879322 -11715.889597 -18621.754981 238.607351
99+
PJ01 -28726.531572 27690.329963 18771.139987 77.142303
100+
EOF

gnss_lib_py/utils/ephemeris_downloader.py

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
is downloaded (COD0MGXFIN). The CODE final SP3 solutions became
5252
available starting GPS week 1962 or Aug 13, 2017. The CODE final
5353
solution includes: GPS+GLO+GAL+BDS+QZS. More about the CODE solution can
54-
be found in their papers [6]_[7]_.
54+
be found in their papers [6]_ [7]_.
5555
5656
If the SP3 date requested is between GPS week 1690 and 1961 or between
5757
May 25, 2012 and Aug 12, 2017, then the CODE 'com' short name solution
5858
is downloaded. More about the CODE 'com' solution can be found in their
59-
papers [9]_[10]_.
59+
papers [9]_ [10]_.
6060
6161
CLK Older than Two Weeks
6262
------------------------
@@ -65,7 +65,7 @@
6565
is downloaded (COD0MGXFIN). The CODE final CLK solutions became
6666
available starting GPS week 2113 or July 5th, 2020. The CODE final
6767
solution includes: GPS+GLO+GAL+BDS+QZS. More about the CODE solution can
68-
be found in their papers [6]_[7]_.
68+
be found in their papers [6]_ [7]_.
6969
7070
If the CLK date requested is between GPS week 2034 and 2112 or between
7171
Jan 1, 2019 and July 4th, 2020, then the Wuhan University final
@@ -75,7 +75,7 @@
7575
If the CLK date requested is week GPS week 2034 and between Dec 30, 2018
7676
and Dec 31, 2018, then the GFZ short name solution is downloaded (gbm).
7777
More about the GFZ 'gbm' solution can be found in their
78-
documentation [13]_[14]_.
78+
documentation [13]_ [14]_.
7979
8080
If the CLK date requested is between GPS week 1962 and 2033 or between
8181
Aug 13, 2017 and Dec 29th, 2018 then the Wuhan University short name
@@ -85,7 +85,7 @@
8585
If the CLK date requested is between GPS week 1710 and 1961 or between
8686
Oct 14, 2012 and Aug 12, 2017, then the CODE 'com' short name solution
8787
is downloaded. More about the CODE 'com' solution can be found in their
88-
papers [9]_[10]_.
88+
papers [9]_ [10]_.
8989
9090
IGS Resources
9191
-------------
@@ -172,8 +172,29 @@ def load_ephemeris(file_type, gps_millis,
172172
file_paths,
173173
verbose)
174174

175-
downloaded_paths = _download_ephemeris(file_type, needed_files,
176-
download_directory, verbose)
175+
try:
176+
downloaded_paths = _download_ephemeris(file_type,
177+
needed_files,
178+
download_directory, verbose)
179+
except ftplib.error_perm as err:
180+
# try second options for some files
181+
print(err)
182+
print("Retrying download...")
183+
if "Connection timed out" in str(err): #pragma: no cover
184+
pass
185+
elif "WUM0MGXFIN" in str(err):
186+
needed_files = [(x[0],x[1].replace("WUM0MGXFIN","GFZ0MGXRAP"))
187+
for x in needed_files]
188+
elif "wum" in str(err):
189+
needed_files = [(x[0],x[1].replace("wum","gbm"))
190+
for x in needed_files]
191+
elif "BRDM00DLR_R" in str(err):
192+
needed_files = [(x[0],x[1].replace("BRDM00DLR_R","BRDC00IGS_R"))
193+
for x in needed_files]
194+
195+
downloaded_paths = _download_ephemeris(file_type,
196+
needed_files,
197+
download_directory, verbose)
177198

178199
if verbose:
179200
if len(existing_paths) > 0:
@@ -626,11 +647,16 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
626647
if file_paths is None:
627648
return False, recommended_file
628649
# check compatible file types
629-
for path in file_paths:
650+
for path in file_paths: # exact match
630651
if os.path.split(path)[1] + ".Z" == os.path.split(recommended_file[1])[1]:
631652
return True, path
632-
for path in file_paths:
633-
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1]:
653+
for path in file_paths: # other short form files
654+
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1][3:]:
655+
return True, path
656+
for path in file_paths: # other long form files
657+
if os.path.split(path)[1][11:] == str(timetuple.tm_year) \
658+
+ str(timetuple.tm_yday).zfill(3) \
659+
+ "0000_01D_05M_ORB.SP3":
634660
return True, path
635661

636662
# clk from last three days
@@ -743,11 +769,18 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
743769
if file_paths is None:
744770
return False, recommended_file
745771
# check compatible file types
746-
for path in file_paths:
772+
for path in file_paths: # exact file match
747773
if os.path.split(path)[1] + ".Z" == os.path.split(recommended_file[1])[1]:
748774
return True, path
749-
for path in file_paths:
750-
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1]:
775+
print("2. looking for:",os.path.split(recommended_file[1])[1][3:])
776+
for path in file_paths: # other short form files
777+
print("2. found path:",os.path.split(path)[1][3:] + ".Z")
778+
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1][3:]:
779+
return True, path
780+
for path in file_paths: # other long form files
781+
if os.path.split(path)[1][11:] == str(timetuple.tm_year) \
782+
+ str(timetuple.tm_yday).zfill(3) \
783+
+ "0000_01D_30S_CLK.CLK":
751784
return True, path
752785

753786
# clk for Aug 13, 2017 to Dec 29, 2018
@@ -768,7 +801,12 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
768801
if os.path.split(path)[1] + ".Z" == os.path.split(recommended_file[1])[1]:
769802
return True, path
770803
for path in file_paths:
771-
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1]:
804+
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1][3:]:
805+
return True, path
806+
for path in file_paths: # other long form files
807+
if os.path.split(path)[1][11:] == str(timetuple.tm_year) \
808+
+ str(timetuple.tm_yday).zfill(3) \
809+
+ "0000_01D_30S_CLK.CLK":
772810
return True, path
773811

774812
# clk for Oct 14, 2012 to Aug 12, 2017
@@ -789,9 +827,13 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
789827
if os.path.split(path)[1] + ".Z" == os.path.split(recommended_file[1])[1]:
790828
return True, path
791829
for path in file_paths:
792-
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1]:
830+
if os.path.split(path)[1][3:] + ".Z" == os.path.split(recommended_file[1])[1][3:]:
831+
return True, path
832+
for path in file_paths: # other long form files
833+
if os.path.split(path)[1][11:] == str(timetuple.tm_year) \
834+
+ str(timetuple.tm_yday).zfill(3) \
835+
+ "0000_01D_30S_CLK.CLK":
793836
return True, path
794-
795837
else:
796838
raise RuntimeError(possible_type,"invalid possible_type "\
797839
+"for valid ephemeris")
@@ -930,7 +972,7 @@ def _get_rinex_extension(timestamp):
930972
"""Get file extension of rinex file based on timestamp.
931973
932974
GPS and Glonass Rinex files switched from .Z to .gz on
933-
December 1, 2020 [5]_.
975+
December 1, 2020 [15]_.
934976
935977
Parameters
936978
----------
@@ -944,7 +986,7 @@ def _get_rinex_extension(timestamp):
944986
945987
References
946988
----------
947-
.. [5] https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/daily_30second_data.html
989+
.. [15] https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/daily_30second_data.html
948990
949991
"""
950992
# switched from .Z to .gz compression format on December 1st, 2020

0 commit comments

Comments
 (0)