From 68be9a5ec1034e6b4be83a67e9853be2165358c8 Mon Sep 17 00:00:00 2001 From: Kevin4562 <37491921+Kevin4562@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:17:57 -0500 Subject: [PATCH 1/5] parse delta-utc header --- src/georinex/nav2.py | 7 +++++++ src/georinex/tests/test_nav2.py | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/georinex/nav2.py b/src/georinex/nav2.py index de985d8..e4f0a06 100644 --- a/src/georinex/nav2.py +++ b/src/georinex/nav2.py @@ -208,6 +208,13 @@ def rinexnav2(fn: T.TextIO | Path, tlim: tuple[datetime, datetime] | None = None beta = [rinex_string_to_float(beta[2 + i * 12 : 2 + (i + 1) * 12]) for i in range(4)] nav.attrs["ionospheric_corr_GPS"] = np.hstack((alpha, beta)) + if "DELTA-UTC: A0,A1,T,W" in header: + delta_utc = header["DELTA-UTC: A0,A1,T,W"] + nav.attrs["A0"] = rinex_string_to_float(delta_utc[2 : 22]) + nav.attrs["A1"] = rinex_string_to_float(delta_utc[22 : 42]) + nav.attrs["Tot"] = rinex_string_to_float(delta_utc[42 : 52]) + nav.attrs["Wnt"] = rinex_string_to_float(delta_utc[52 : 59]) + return nav diff --git a/src/georinex/tests/test_nav2.py b/src/georinex/tests/test_nav2.py index 127b8a2..d71d623 100755 --- a/src/georinex/tests/test_nav2.py +++ b/src/georinex/tests/test_nav2.py @@ -207,3 +207,15 @@ def test_ionospheric_correction(): -0.5243e06, ] ) + + +def test_delta_utc(): + nav = gr.load(R / "14601736.18n") + assert [nav.A0, nav.A1, nav.Tot, nav.Wnt] == approx( + [ + -0.186264514923e-08, + -0.888178419700e-15, + 61440.0, + 2006.0 + ] + ) From 390eea5428c66fee510b7ae3adaa8dad45a4b5e1 Mon Sep 17 00:00:00 2001 From: aldebaran1 Date: Mon, 29 Jan 2024 14:01:46 -0500 Subject: [PATCH 2/5] return leap second --- src/georinex/obs2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/georinex/obs2.py b/src/georinex/obs2.py index 292db34..6fa493c 100644 --- a/src/georinex/obs2.py +++ b/src/georinex/obs2.py @@ -305,10 +305,11 @@ def rinexsystem2( obs.attrs["rxmodel"] = hdr["rxmodel"] if "position" in hdr.keys(): obs.attrs["position"] = hdr["position"] - if "position_geodetic" in hdr.keys(): obs.attrs["position_geodetic"] = hdr["position_geodetic"] - + if "LEAP SECONDS" in hdr.keys(): + obs.attrs["leap_seconds"] = int(hdr["LEAP SECONDS"]) + return obs @@ -454,7 +455,6 @@ def obsheader2( hdr["interval"] = float(hdr["INTERVAL"][:10]) except (KeyError, ValueError): pass - try: s = " " hdr["rxmodel"] = s.join(hdr["REC # / TYPE / VERS"].split()[1:-1]) From f85803ee2ac452dc14b53fdc929a1d0e190a5efa Mon Sep 17 00:00:00 2001 From: aldebaran1 Date: Tue, 9 Jul 2024 09:47:37 -0400 Subject: [PATCH 3/5] Remove sparse in I --- src/georinex/nav3.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/georinex/nav3.py b/src/georinex/nav3.py index aa936f8..c43ec8b 100644 --- a/src/georinex/nav3.py +++ b/src/georinex/nav3.py @@ -230,10 +230,16 @@ def _sparefields(cf: list[str], sys: str, N: int) -> list[str]: elif N == 27: # no middle or trailing spare fields cf = cf[:22] + cf[23:-3] elif sys == "I": - if N == 28: - cf = cf[:28] + print (cf) + print (len(cf)) + if N == 26: + cf = cf[:22] + cf[23:26] + [cf[27]] + print (cf) + print (len(cf)) if N != len(cf): + # print (cf, len(cf), N) + # print (np.where(np.array(cf) == 'spare0')) raise ValueError(f"System {sys} NAV data is not the same length as the number of fields.") return cf From 3427dcc433637b5529f8cd6150f34c6a47b6aecc Mon Sep 17 00:00:00 2001 From: aldebaran1 Date: Tue, 9 Jul 2024 10:10:11 -0400 Subject: [PATCH 4/5] return leap seconds --- src/georinex/nav2.py | 2 ++ src/georinex/nav3.py | 12 ++++-------- src/georinex/obs3.py | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/georinex/nav2.py b/src/georinex/nav2.py index e4f0a06..231e8ed 100644 --- a/src/georinex/nav2.py +++ b/src/georinex/nav2.py @@ -195,6 +195,8 @@ def rinexnav2(fn: T.TextIO | Path, tlim: tuple[datetime, datetime] | None = None nav[name] *= 1e3 # %% other attributes + if "LEAP SECONDS" in header: + nav.attrs["leap_seconds"] = int(header["LEAP SECONDS"]) nav.attrs["version"] = header["version"] nav.attrs["svtype"] = [svtype] # Use list for consistency with NAV3. nav.attrs["rinextype"] = "nav" diff --git a/src/georinex/nav3.py b/src/georinex/nav3.py index c43ec8b..e7d5b2b 100644 --- a/src/georinex/nav3.py +++ b/src/georinex/nav3.py @@ -153,7 +153,8 @@ def rinexnav3( nav.attrs["ionospheric_corr_BDS"] = np.hstack((corr["BDSA"], corr["BDSB"])) if "IRNA" in corr and "IRNB" in corr: nav.attrs["ionospheric_corr_IRN"] = np.hstack((corr["IRNA"], corr["IRNB"])) - + if "LEAP SECONDS" in header: + nav.attrs["leap_seconds"] = int(header["LEAP SECONDS"].split()[0]) nav.attrs["version"] = header["version"] nav.attrs["svtype"] = svtypes nav.attrs["rinextype"] = "nav" @@ -230,16 +231,11 @@ def _sparefields(cf: list[str], sys: str, N: int) -> list[str]: elif N == 27: # no middle or trailing spare fields cf = cf[:22] + cf[23:-3] elif sys == "I": - print (cf) - print (len(cf)) if N == 26: cf = cf[:22] + cf[23:26] + [cf[27]] - print (cf) - print (len(cf)) - + elif N == 28: + cf = cf[:28] if N != len(cf): - # print (cf, len(cf), N) - # print (np.where(np.array(cf) == 'spare0')) raise ValueError(f"System {sys} NAV data is not the same length as the number of fields.") return cf diff --git a/src/georinex/obs3.py b/src/georinex/obs3.py index a68dc21..89ce87a 100644 --- a/src/georinex/obs3.py +++ b/src/georinex/obs3.py @@ -160,7 +160,8 @@ def rinexobs3( data.attrs["receiver_clock_offset_applied"] = int(hdr["RCV CLOCK OFFS APPL"]) except ValueError: pass - + if "LEAP SECONDS" in hdr.keys(): + data.attrs["leap_seconds"] = int(hdr["LEAP SECONDS"]) return data From 76b00d903f4857be824ce03c003df378291112aa Mon Sep 17 00:00:00 2001 From: aldebaran1 Date: Fri, 12 Jul 2024 12:07:10 -0400 Subject: [PATCH 5/5] parse rnx version --- src/georinex/nav3.py | 1 - src/georinex/obs2.py | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/georinex/nav3.py b/src/georinex/nav3.py index e7d5b2b..ed8706f 100644 --- a/src/georinex/nav3.py +++ b/src/georinex/nav3.py @@ -78,7 +78,6 @@ def rinexnav3( raw += ln[STARTCOL3:80] # one line per SV raws.append(raw.replace("D", "E").replace("\n", "")) - # %% parse collected data per SV # NOTE: must be 'ns' or .to_netcdf will fail! t = np.array([np.datetime64(t, "ns") for t in times]) diff --git a/src/georinex/obs2.py b/src/georinex/obs2.py index 6fa493c..f4c1c8e 100644 --- a/src/georinex/obs2.py +++ b/src/georinex/obs2.py @@ -451,10 +451,14 @@ def obsheader2( except (KeyError, ValueError): pass - try: # This key is OPTIONAL + try: hdr["interval"] = float(hdr["INTERVAL"][:10]) except (KeyError, ValueError): pass + try: + hdr["version"] = float(hdr["RINEX VERSION / TYPE"].split()[0]) + except (KeyError, ValueError): + pass try: s = " " hdr["rxmodel"] = s.join(hdr["REC # / TYPE / VERS"].split()[1:-1])