11"""Functions to download Rinex, SP3, and CLK ephemeris files.
22
3+ Rinex Navigation
4+ ----------------
5+
36Rinex navigation files are pulled from one of five sources. More about
47rinex files can be found in the CDDIS documentation [1]_.
58
2326GPS+GLO+GAL+BDS+QZSS+IRNSS+SBAS. For more information on multi-gnss
2427combined rinex navigation files, see MGEX documentation [2]_.
2528
26- IGS network station information can be found at [3]_.
27-
29+ SP3 and CLK within Two Weeks
30+ ----------------------------
2831SP3 and CLK files are obtained from CDDIS and produced by either the
29- Center for Orbit Determination in Europe (CODE) or GeoForschungsZentrum
30- Potsdam (GFZ). Products are available through the MGEX data program [4]_.
32+ Center for Orbit Determination in Europe (CODE), GeoForschungsZentrum
33+ Potsdam (GFZ) or Wuhan University. Products are available through the
34+ MGEX data program [4]_. Details on the MGEX precise orbit and clock
35+ products can be found on the IGS website [4]_.
3136
3237If the SP3 or CLK date requested is within the three days, then the
3338rapid solution from CODE is downloaded (COD0OPSRAP). The CODE rapid
34- solution includes: GPS+GLO+GAL
39+ solution includes: GPS+GLO+GAL.
3540
3641If the SP3 or CLK date requested is within the last two weeks, then the
3742rapid solution from GFZ is downloaded (GFZ0MGXRAP). The GFZ rapid
3843solution became available starting GPS week 2038 or Jan 27, 2019. The
39- GFZ rapid solution includes: GPS+GLO+GAL+BDS+QZS
40- More about the GFZ solution can be found on their MGEX website [8]_.
41-
42- If the SP3 or CLK date requested is more than two weeks previous to the
43- current date, then the CODE final solution is downloaded (COD0MGXFIN).
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
64-
65- Details on the MGEX precise orbit and clock products can be found on the
66- IGS website [4]_.
67-
68- IGS files can be viewed online using their file browser [5]_.
44+ GFZ rapid solution includes: GPS+GLO+GAL+BDS+QZS. More about the GFZ
45+ solution can be found on their MGEX website [8]_.
46+
47+ SP3 Older than Two Weeks
48+ ------------------------
49+ If the SP3 date requested is more than two weeks previous to the
50+ current date and GPS week 1962 or later, then the CODE final solution
51+ is downloaded (COD0MGXFIN). The CODE final SP3 solutions became
52+ available starting GPS week 1962 or Aug 13, 2017. The CODE final
53+ solution includes: GPS+GLO+GAL+BDS+QZS. More about the CODE solution can
54+ be found in their papers [6]_[7]_.
55+
56+ If the SP3 date requested is between GPS week 1690 and 1961 or between
57+ May 25, 2012 and Aug 12, 2017, then the CODE 'com' short name solution
58+ is downloaded. More about the CODE 'com' solution can be found in their
59+ papers [9]_[10]_.
60+
61+ CLK Older than Two Weeks
62+ ------------------------
63+ If the CLK date requested is more than two weeks previous to the
64+ current date and GPS week 2113 or later, then the CODE final solution
65+ is downloaded (COD0MGXFIN). The CODE final CLK solutions became
66+ available starting GPS week 2113 or July 5th, 2020. The CODE final
67+ solution includes: GPS+GLO+GAL+BDS+QZS. More about the CODE solution can
68+ be found in their papers [6]_[7]_.
69+
70+ If the CLK date requested is between GPS week 2034 and 2112 or between
71+ Jan 1, 2019 and July 4th, 2020, then the Wuhan University final
72+ solution is downloaded (WUM0MGXFIN). More about the WUM0MGXFIN solution
73+ can be found in their documention [11]_.
74+
75+ If the CLK date requested is week GPS week 2034 and between Dec 30, 2018
76+ and Dec 31, 2018, then the GFZ short name solution is downloaded (gbm).
77+ More about the GFZ 'gbm' solution can be found in their
78+ documentation [13]_[14]_.
79+
80+ If the CLK date requested is between GPS week 1962 and 2033 or between
81+ Aug 13, 2017 and Dec 29th, 2018 then the Wuhan University short name
82+ solution is downloaded (wum). More about the "wum" solution can be found
83+ in their paper [12]_.
84+
85+ If the CLK date requested is between GPS week 1710 and 1961 or between
86+ Oct 14, 2012 and Aug 12, 2017, then the CODE 'com' short name solution
87+ is downloaded. More about the CODE 'com' solution can be found in their
88+ papers [9]_[10]_.
89+
90+ IGS Resources
91+ -------------
92+
93+ IGS network station information can be found at [3]_. IGS files can be
94+ viewed online using their file browser [5]_.
6995
7096References
7197----------
79105.. [8] https://www.gfz-potsdam.de/en/section/space-geodetic-techniques/projects/mgex
80106.. [9] http://doi.org/10.1007/1345_2015_161
81107.. [10] http://doi.org/10.1007/s00190-016-0968-8
108+ .. [11] https://files.igs.org/pub/center/analysis/WUM0MGXFIN.acn
109+ .. [12] http://dx.doi.org/10.1007/s00190-015-0862-9
110+ .. [13] https://files.igs.org/pub/resource/pubs/workshop/2014/Workshop%202014%20-%20PS11%20-%20Deng%20-%202226%20-%20Precise%20orbit%20determination%20of%20Beidou%20Satellites%20at%20GFZ.pdf
111+ .. [14] http://doi.org/10.1007/1345_2015_120
112+
82113"""
83114
84115# CLK: 2020, 7, 2
@@ -193,7 +224,7 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
193224 possible_types = []
194225
195226 if file_type == "rinex_nav" :
196- if date < datetime (2013 ,1 ,1 ):
227+ if date < datetime (2013 ,1 ,1 ). date () :
197228 raise RuntimeError ("gnss_lib_py cannot automatically " \
198229 + "download rinex nav files for " \
199230 + "times before Jan 1, 2013" )
@@ -217,32 +248,38 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
217248 possible_types += ["rinex_nav_multi_s" ]
218249
219250 if file_type == "sp3" :
220- if date < datetime (2017 , 8 , 13 ):
251+ if date < datetime (2012 , 5 , 25 ). date ( ):
221252 raise RuntimeError ("gnss_lib_py cannot automatically " \
222253 + "download sp3 files for " \
223- + "times before Aug 13, 2017 " )
254+ + "times before May 25, 2012 " )
224255 if datetime .utcnow ().date () - timedelta (days = 3 ) < date :
225256 possible_types += ["sp3_rapid_CODE" ]
226257 elif datetime .utcnow ().date () - timedelta (days = 14 ) < date :
227258 possible_types += ["sp3_rapid_GFZ" ]
228259 elif date >= datetime (2017 , 8 , 13 ).date ():
229260 possible_types += ["sp3_final_CODE" ]
230261 else :
231- possible_types += ["sp3_final_GFZ " ]
262+ possible_types += ["sp3_short_CODE " ]
232263
233264 if file_type == "clk" :
234- if date < datetime (2017 , 8 , 13 ):
265+ if date < datetime (2012 , 10 , 14 ). date ( ):
235266 raise RuntimeError ("gnss_lib_py cannot automatically " \
236267 + "download clk files for " \
237- + "times before Aug 13, 2017 " )
268+ + "times before Oct 14, 2012 " )
238269 if datetime .utcnow ().date () - timedelta (days = 3 ) < date :
239270 possible_types += ["clk_rapid_CODE" ]
240271 elif datetime .utcnow ().date () - timedelta (days = 14 ) < date :
241272 possible_types += ["clk_rapid_GFZ" ]
242- elif date >= datetime (2017 , 8 , 13 ).date ():
273+ elif date >= datetime (2020 , 7 , 5 ).date ():
243274 possible_types += ["clk_final_CODE" ]
275+ elif date >= datetime (2019 , 1 , 1 ).date ():
276+ possible_types += ["clk_final_WUM" ]
277+ elif date >= datetime (2018 , 12 , 30 ).date ():
278+ possible_types += ["clk_short_GFZ" ]
279+ elif date >= datetime (2017 , 8 , 13 ).date ():
280+ possible_types += ["clk_short_WUM" ]
244281 else :
245- possible_types += ["clk_final_GFZ " ]
282+ possible_types += ["clk_short_CODE " ]
246283
247284 already_exists , filepath = _valid_ephemeris_in_paths (date ,
248285 possible_types , file_paths )
@@ -575,14 +612,14 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
575612 if os .path .split (path )[1 ][3 :] == str (gps_week ).zfill (4 ) + str ((timetuple .tm_wday + 1 )% 7 ) + ".sp3" :
576613 return True , path
577614
578- # sp3 before Aug 13, 2017
579- elif possible_type == "sp3_final_GFZ " :
615+ # sp3 before Aug 13, 2017 and May 25, 2012 or later
616+ elif possible_type == "sp3_short_CODE " :
580617 gps_week , _ = tc .datetime_to_tow (datetime .combine (date ,
581618 time (tzinfo = timezone .utc )))
582619 recommended_file = ("gdc.cddis.eosdis.nasa.gov" ,
583620 "/gnss/products/" \
584621 + str (gps_week ).zfill (4 ) + "/" \
585- + "gbm " + str (gps_week ).zfill (4 ) \
622+ + "com " + str (gps_week ).zfill (4 ) \
586623 + str ((timetuple .tm_wday + 1 )% 7 ) \
587624 + ".sp3.Z" )
588625 recommended_files .append (recommended_file )
@@ -644,7 +681,7 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
644681 if os .path .split (path )[1 ][3 :] == str (gps_week ).zfill (4 ) + str ((timetuple .tm_wday + 1 )% 7 ) + ".clk" :
645682 return True , path
646683
647- # clk if longer than two weeks ago and more recent than Aug 13, 2017
684+ # clk if longer than two weeks ago and more recent than Jul 5, 2020
648685 elif possible_type == "clk_final_CODE" :
649686 gps_week , _ = tc .datetime_to_tow (datetime .combine (date ,
650687 time (tzinfo = timezone .utc )))
@@ -668,8 +705,32 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
668705 if os .path .split (path )[1 ][3 :] == str (gps_week ).zfill (4 ) + str ((timetuple .tm_wday + 1 )% 7 ) + ".clk" :
669706 return True , path
670707
671- # clk before Aug 13, 2017
672- elif possible_type == "clk_final_GFZ" :
708+ # clk for Jan 1, 2019 to Jul 4, 2020
709+ elif possible_type == "clk_final_WUM" :
710+ gps_week , _ = tc .datetime_to_tow (datetime .combine (date ,
711+ time (tzinfo = timezone .utc )))
712+ recommended_file = ("gdc.cddis.eosdis.nasa.gov" ,
713+ "/gnss/products/" \
714+ + str (gps_week ).zfill (4 ) + "/" \
715+ + "WUM0MGXFIN_" + str (timetuple .tm_year ) \
716+ + str (timetuple .tm_yday ).zfill (3 ) \
717+ + "0000_01D_30S_CLK.CLK.gz" )
718+ recommended_files .append (recommended_file )
719+ if file_paths is None :
720+ return False , recommended_file
721+ # check compatible file types
722+ for path in file_paths :
723+ if os .path .split (path )[1 ] + ".gz" == os .path .split (recommended_file [1 ])[1 ]:
724+ return True , path
725+ for path in file_paths :
726+ if os .path .split (path )[1 ][10 :] == os .path .split (recommended_file [1 ])[1 ][10 :- 3 ]:
727+ return True , path
728+ for path in file_paths :
729+ if os .path .split (path )[1 ][3 :] == str (gps_week ).zfill (4 ) + str ((timetuple .tm_wday + 1 )% 7 ) + ".clk" :
730+ return True , path
731+
732+ # clk for Dec 30, 2018 to Dec 31, 2018
733+ elif possible_type == "clk_short_GFZ" :
673734 gps_week , _ = tc .datetime_to_tow (datetime .combine (date ,
674735 time (tzinfo = timezone .utc )))
675736 recommended_file = ("gdc.cddis.eosdis.nasa.gov" ,
@@ -689,6 +750,48 @@ def _valid_ephemeris_in_paths(date, possible_types, file_paths=None):
689750 if os .path .split (path )[1 ][3 :] + ".Z" == os .path .split (recommended_file [1 ])[1 ]:
690751 return True , path
691752
753+ # clk for Aug 13, 2017 to Dec 29, 2018
754+ elif possible_type == "clk_short_WUM" :
755+ gps_week , _ = tc .datetime_to_tow (datetime .combine (date ,
756+ time (tzinfo = timezone .utc )))
757+ recommended_file = ("gdc.cddis.eosdis.nasa.gov" ,
758+ "/gnss/products/" \
759+ + str (gps_week ).zfill (4 ) + "/" \
760+ + "wum" + str (gps_week ).zfill (4 ) \
761+ + str ((timetuple .tm_wday + 1 )% 7 ) \
762+ + ".clk.Z" )
763+ recommended_files .append (recommended_file )
764+ if file_paths is None :
765+ return False , recommended_file
766+ # check compatible file types
767+ for path in file_paths :
768+ if os .path .split (path )[1 ] + ".Z" == os .path .split (recommended_file [1 ])[1 ]:
769+ return True , path
770+ for path in file_paths :
771+ if os .path .split (path )[1 ][3 :] + ".Z" == os .path .split (recommended_file [1 ])[1 ]:
772+ return True , path
773+
774+ # clk for Oct 14, 2012 to Aug 12, 2017
775+ elif possible_type == "clk_short_CODE" :
776+ gps_week , _ = tc .datetime_to_tow (datetime .combine (date ,
777+ time (tzinfo = timezone .utc )))
778+ recommended_file = ("gdc.cddis.eosdis.nasa.gov" ,
779+ "/gnss/products/" \
780+ + str (gps_week ).zfill (4 ) + "/" \
781+ + "com" + str (gps_week ).zfill (4 ) \
782+ + str ((timetuple .tm_wday + 1 )% 7 ) \
783+ + ".clk.Z" )
784+ recommended_files .append (recommended_file )
785+ if file_paths is None :
786+ return False , recommended_file
787+ # check compatible file types
788+ for path in file_paths :
789+ if os .path .split (path )[1 ] + ".Z" == os .path .split (recommended_file [1 ])[1 ]:
790+ return True , path
791+ for path in file_paths :
792+ if os .path .split (path )[1 ][3 :] + ".Z" == os .path .split (recommended_file [1 ])[1 ]:
793+ return True , path
794+
692795 else :
693796 raise RuntimeError (possible_type ,"invalid possible_type " \
694797 + "for valid ephemeris" )
0 commit comments