gnsskit 0.5.1__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {gnsskit-0.5.1 → gnsskit-0.6.0}/PKG-INFO +33 -69
  2. gnsskit-0.6.0/README.md +121 -0
  3. {gnsskit-0.5.1 → gnsskit-0.6.0}/pyproject.toml +4 -1
  4. {gnsskit-0.5.1 → gnsskit-0.6.0}/pyproject.toml.orig +4 -1
  5. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/__init__.py +5 -0
  6. gnsskit-0.6.0/src/gnsskit/export/__init__.py +5 -0
  7. gnsskit-0.6.0/src/gnsskit/export/move3.py +401 -0
  8. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/refsys.py +25 -0
  9. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/rinex.py +52 -4
  10. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/rtklib/config.py +2 -2
  11. gnsskit-0.5.1/README.md +0 -157
  12. {gnsskit-0.5.1 → gnsskit-0.6.0}/LICENSE +0 -0
  13. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/kinematic/__init__.py +0 -0
  14. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/kinematic/trajectory.py +0 -0
  15. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/plot/__init__.py +0 -0
  16. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/plot/_map.py +0 -0
  17. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/plot/occupations.py +0 -0
  18. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/plot/solutions.py +0 -0
  19. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/plot/visibility.py +0 -0
  20. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/ppp/__init__.py +0 -0
  21. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/py.typed +0 -0
  22. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/rtklib/__init__.py +0 -0
  23. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/rtklib/pos.py +0 -0
  24. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/rtklib/runner.py +0 -0
  25. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/static/__init__.py +0 -0
  26. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/static/baseline.py +0 -0
  27. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/static/closure.py +0 -0
  28. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/static/network.py +0 -0
  29. {gnsskit-0.5.1 → gnsskit-0.6.0}/src/gnsskit/static/solve.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gnsskit
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: RTKLIB-based GNSS post-processing toolkit: RINEX tools, RTKLIB wrappers, static baselines and network adjustment, kinematic trajectories
5
5
  Keywords: gnss,gps,rtklib,ppk,surveying,least-squares
6
6
  Author: Francesco Ioli
@@ -43,25 +43,12 @@ Shared tools for post-processing GNSS data with [RTKLIB](https://www.rtklib.com/
43
43
  > command-line program `rnx2rtkp` (the CLI of RTKPOST) for the GNSS processing; `pip`/`uv` do
44
44
  > not install it. See [RTKLIB](#rtklib-required-separately) below.
45
45
 
46
- - **RTKLIB wrappers** (`gnsskit.rtklib`): `RtkConfig`, a typed, immutable set of `rnx2rtkp` options
47
- (`from_file`, `updated`, `with_options`, `with_base_llh`, `write`); `run_rnx2rtkp` and `find_rnx2rtkp`;
48
- `read_pos` (llh, xyz and enu `.pos` files).
49
- - **RINEX** (`gnsskit.rinex`): `rinex_span`, `header_llh`, `header_xyz`, `trim_rinex`; inspection with
50
- `obs_summary` (span, sampling, gaps, satellites) and `read_visibility`; survey occupations with
51
- `read_occupations` (point, receiver, session, time span and position of every occupation, from the
52
- file names, a field book or the headers), `sessions_from_overlap` and `flag_stale_headers`.
53
- - **Plots** (`gnsskit.plot`, needs the `plot` extra): `plot_visibility` (RTKPLOT-style satellite
54
- visibility), `plot_occupations` (map of where, when and with which receiver every point was
55
- occupied), `plot_baselines` (baseline network: arrows base -> rover, fixed/float, repeated
56
- baselines side by side, optional error ellipses) and `plot_pos` (RTKPLOT-like view of a static or
57
- kinematic `.pos` solution: ground track and E/N/U, satellites and ratio against time, colored by
58
- solution quality). The maps can be drawn over OpenStreetMap tiles.
59
- - **Static** (`gnsskit.static`): `solve_static` (one solution over a time window), `process_baseline`
60
- (static baselines with covariance), baseline IO and `loop_closures` (misclosure of every triangle of baselines); least-squares adjustment of a redundant baseline
61
- network in `gnsskit.static.network` (needs the `network` extra).
62
- - **Kinematic** (`gnsskit.kinematic`): trajectory interpolation and averaging.
63
- - **Reference systems** (`gnsskit.refsys`): GPST/UTC, ellipsoids, ECEF/geodetic conversions and
64
- `ENUFrame`, a local east-north-up frame at a point (points, vectors and covariances, both ways).
46
+ - **RTKLIB**: typed `RtkConfig`, `run_rnx2rtkp`, `read_pos`.
47
+ - **RINEX**: inspect, trim and decimate observation files; survey occupations.
48
+ - **Static**: baselines with covariance, loop closures, least-squares network adjustment.
49
+ - **Kinematic**: trajectory interpolation and averaging.
50
+ - **Reference systems and plots**: GPST/UTC, ECEF/geodetic/ENU; visibility, occupation, baseline and `.pos` plots.
51
+ - **Export**: MOVE3 projects.
65
52
 
66
53
  ## Install
67
54
 
@@ -106,39 +93,29 @@ reference systems) is pure Python and works without RTKLIB, e.g. on baselines co
106
93
 
107
94
  ## Example
108
95
 
109
- ```python
110
- from gnsskit import RtkConfig, read_pos, run_rnx2rtkp
111
-
112
- config = RtkConfig(posmode="static", navsys="GEC", solformat="llh").with_base_llh(46.2, 9.8, 2300.0)
113
- pos_file = run_rnx2rtkp(rover_obs, base_obs, [nav], config, "out.pos")
114
- pos = read_pos(pos_file)
115
- ```
116
-
117
- Map of the occupations of a survey, from files named e.g. `s1_A1_gs14.26o`:
96
+ Baselines of a static network with RTKLIB, then a least-squares adjustment with one fixed point:
118
97
 
119
98
  ```python
120
- from gnsskit import find_rinex_obs, plot_occupations, read_occupations
121
-
122
- occ = read_occupations(
123
- find_rinex_obs(["rinex"]),
124
- name_pattern=r"(?P<session>s\d+)_(?P<point>[^_]+)_(?P<receiver>[^.]+)",
125
- )
126
- plot_occupations(occ, "occupations.png", stations={"mil": (4421979.92, 718518.37, 4524921.24)},
127
- basemap=True) # OpenStreetMap tiles: needs internet, falls back to a plain map
99
+ from gnsskit import RtkConfig, process_baseline
100
+ from gnsskit.static.network import adjust_network, coordinate_table
101
+
102
+ conf = RtkConfig(posmode="static", navsys="GRE", solformat="xyz", base_postype="rinexhead")
103
+ baselines = [
104
+ process_baseline(rover, base, f"{rover}.26o", f"{base}.26o", ["nav.26n"], conf, f"{base}-{rover}.pos")
105
+ for base, rover in [("MIL3", "A1"), ("MIL3", "A2"), ("A1", "A2")]
106
+ ]
107
+ adj = adjust_network(baselines, fixed={"MIL3": (4421979.9187, 718518.3650, 4524921.2364)})
108
+ print(coordinate_table(adj))
128
109
  ```
129
110
 
130
- Baseline network and RTKLIB solutions:
131
-
132
- ```python
133
- import pandas as pd
134
- from gnsskit import plot_baselines, plot_pos
135
-
136
- baselines = pd.read_csv("baselines.csv", dtype={"base": str, "rover": str}) # baselines_to_df
137
- plot_baselines(baselines, "network.png", fixed={"mil": (4421979.92, 718518.37, 4524921.24)})
138
- plot_pos("rover.pos", "rover.png") # static or kinematic, llh / xyz / enu
139
- ```
111
+ ## Documentation
140
112
 
141
- See [example/](https://github.com/franioli/gnsskit/tree/main/example) for complete static, kinematic and network adjustment examples.
113
+ - [docs/](https://github.com/franioli/gnsskit/tree/main/docs): one short guide per module (RINEX,
114
+ RTKLIB, static baselines and adjustment, kinematic, reference systems, plots, MOVE3 export).
115
+ - [scripts/](https://github.com/franioli/gnsskit/tree/main/scripts): command-line tools for RINEX
116
+ statistics, occupation maps and trimming.
117
+ - [example/](https://github.com/franioli/gnsskit/tree/main/example): complete worked examples
118
+ (static, kinematic, static network with data).
142
119
 
143
120
  ## Contributing
144
121
 
@@ -162,30 +139,17 @@ Issues are welcome on [GitHub](https://github.com/franioli/gnsskit/issues). To c
162
139
 
163
140
  ## Releasing a new version
164
141
 
165
- For the current maintainers only (it needs write access to the repository and to the PyPI
166
- project).
167
-
168
- Publishing a GitHub release runs [`.github/workflows/publish.yml`](.github/workflows/publish.yml),
169
- which checks that the tag matches the version, runs the tests, builds and uploads to PyPI:
142
+ Maintainers only. Publishing a GitHub release runs
143
+ [`publish.yml`](.github/workflows/publish.yml), which checks the tag against the version, builds
144
+ and uploads to PyPI (Trusted Publishing: publisher `franioli/gnsskit`, workflow `publish.yml`,
145
+ environment `pypi`):
170
146
 
171
147
  ```sh
172
- uv version --bump patch # or minor / major: updates pyproject.toml
173
148
  uv run pytest
149
+ uv version --bump patch # or minor / major
174
150
  git commit -am "Release $(uv version --short)" && git push
175
- gh release create "v$(uv version --short)" --generate-notes # tag + release -> PyPI
151
+ gh release create "v$(uv version --short)" --generate-notes
176
152
  ```
177
153
 
178
- `gh release create` creates the tag on the pushed commit; without the GitHub CLI, push a tag
179
- (`git tag -a vX.Y.Z -m "gnsskit X.Y.Z" && git push origin vX.Y.Z`) and create the release from it
180
- on GitHub. PyPI never accepts the same version twice.
181
-
182
- One-time setup of the automatic upload (PyPI Trusted Publishing, no token): on pypi.org, project
183
- gnsskit -> Settings -> Publishing -> add a GitHub publisher with owner `franioli`, repository
184
- `gnsskit`, workflow `publish.yml` and environment `pypi`.
185
-
186
- Manual upload, if needed, with a project-scoped token kept outside the repository:
187
-
188
- ```sh
189
- rm -rf dist && uv build
190
- UV_PUBLISH_TOKEN=$(cat ~/.config/pypi/gnsskit.token) uv publish
191
- ```
154
+ PyPI never accepts the same version twice. Manual upload, if needed:
155
+ `rm -rf dist && uv build && UV_PUBLISH_TOKEN=<project token> uv publish`.
@@ -0,0 +1,121 @@
1
+ # gnsskit
2
+
3
+ Shared tools for post-processing GNSS data with [RTKLIB](https://www.rtklib.com/) `rnx2rtkp`, used by
4
+ [djippk](https://github.com/franioli/djippk) (drone PPK) and [stopgo](https://github.com/franioli/stopgo)
5
+ (stop-and-go surveys).
6
+
7
+ > [!IMPORTANT]
8
+ > **RTKLIB is not included and must be installed separately.** gnsskit runs the RTKLIB
9
+ > command-line program `rnx2rtkp` (the CLI of RTKPOST) for the GNSS processing; `pip`/`uv` do
10
+ > not install it. See [RTKLIB](#rtklib-required-separately) below.
11
+
12
+ - **RTKLIB**: typed `RtkConfig`, `run_rnx2rtkp`, `read_pos`.
13
+ - **RINEX**: inspect, trim and decimate observation files; survey occupations.
14
+ - **Static**: baselines with covariance, loop closures, least-squares network adjustment.
15
+ - **Kinematic**: trajectory interpolation and averaging.
16
+ - **Reference systems and plots**: GPST/UTC, ECEF/geodetic/ENU; visibility, occupation, baseline and `.pos` plots.
17
+ - **Export**: MOVE3 projects.
18
+
19
+ ## Install
20
+
21
+ With [uv](https://docs.astral.sh/uv/) (recommended), in your project:
22
+
23
+ ```sh
24
+ uv add gnsskit # library
25
+ uv add "gnsskit[network]" # + network adjustment (scipy, pyproj)
26
+ uv add "gnsskit[network,plot]" # + visibility plots and occupation maps (matplotlib)
27
+ uv add "gnsskit[all]" # every extra
28
+ uv add git+https://github.com/franioli/gnsskit # development version
29
+ ```
30
+
31
+ or in an existing environment, `uv pip install gnsskit` (same extras).
32
+
33
+ With pip:
34
+
35
+ ```sh
36
+ pip install gnsskit
37
+ pip install "gnsskit[all]" # with every extra
38
+ ```
39
+
40
+ ### RTKLIB (required separately)
41
+
42
+ The processing functions (`run_rnx2rtkp`, `process_baseline`, `solve_static`) call the RTKLIB
43
+ command-line program **`rnx2rtkp`**, which must be installed on your system and found on your
44
+ `PATH` (or passed with `exe=`); `trim_rinex(use_convbin=True)` also needs RTKLIB `convbin`.
45
+ The [demo5 fork](https://github.com/rtklibexplorer/RTKLIB) is
46
+ recommended; gnsskit is developed with `rnx2rtkp ver.EX 2.5.1`.
47
+
48
+ - **Windows**: download a [demo5 release](https://github.com/rtklibexplorer/RTKLIB/releases),
49
+ unzip it and add the folder with `rnx2rtkp.exe` to your `PATH`.
50
+ - **Linux / macOS**: build it from source:
51
+ ```sh
52
+ git clone https://github.com/rtklibexplorer/RTKLIB
53
+ cd RTKLIB/app/consapp/rnx2rtkp/gcc && make && sudo make install
54
+ ```
55
+
56
+ Check it with `rnx2rtkp -?`. If it is missing, `run_rnx2rtkp` raises an error with these
57
+ instructions. The rest of gnsskit (RINEX tools, `read_pos`, loop closures, network adjustment,
58
+ reference systems) is pure Python and works without RTKLIB, e.g. on baselines computed elsewhere.
59
+
60
+ ## Example
61
+
62
+ Baselines of a static network with RTKLIB, then a least-squares adjustment with one fixed point:
63
+
64
+ ```python
65
+ from gnsskit import RtkConfig, process_baseline
66
+ from gnsskit.static.network import adjust_network, coordinate_table
67
+
68
+ conf = RtkConfig(posmode="static", navsys="GRE", solformat="xyz", base_postype="rinexhead")
69
+ baselines = [
70
+ process_baseline(rover, base, f"{rover}.26o", f"{base}.26o", ["nav.26n"], conf, f"{base}-{rover}.pos")
71
+ for base, rover in [("MIL3", "A1"), ("MIL3", "A2"), ("A1", "A2")]
72
+ ]
73
+ adj = adjust_network(baselines, fixed={"MIL3": (4421979.9187, 718518.3650, 4524921.2364)})
74
+ print(coordinate_table(adj))
75
+ ```
76
+
77
+ ## Documentation
78
+
79
+ - [docs/](https://github.com/franioli/gnsskit/tree/main/docs): one short guide per module (RINEX,
80
+ RTKLIB, static baselines and adjustment, kinematic, reference systems, plots, MOVE3 export).
81
+ - [scripts/](https://github.com/franioli/gnsskit/tree/main/scripts): command-line tools for RINEX
82
+ statistics, occupation maps and trimming.
83
+ - [example/](https://github.com/franioli/gnsskit/tree/main/example): complete worked examples
84
+ (static, kinematic, static network with data).
85
+
86
+ ## Contributing
87
+
88
+ Issues are welcome on [GitHub](https://github.com/franioli/gnsskit/issues). To contribute code:
89
+
90
+ 1. Fork the repository on GitHub and clone your fork:
91
+ ```sh
92
+ git clone https://github.com/<your-username>/gnsskit && cd gnsskit
93
+ git checkout -b my-feature
94
+ ```
95
+ 2. Set up the environment, make your changes and check them:
96
+ ```sh
97
+ uv sync # environment with the dev dependencies (incl. ruff)
98
+ uv run pytest # tests
99
+ uv run ruff format . # format the code
100
+ uv run ruff check --fix . # lint, fixing what can be fixed automatically
101
+ ```
102
+
103
+ 3. Push the branch to your fork and open a pull request against `main` of
104
+ `franioli/gnsskit`.
105
+
106
+ ## Releasing a new version
107
+
108
+ Maintainers only. Publishing a GitHub release runs
109
+ [`publish.yml`](.github/workflows/publish.yml), which checks the tag against the version, builds
110
+ and uploads to PyPI (Trusted Publishing: publisher `franioli/gnsskit`, workflow `publish.yml`,
111
+ environment `pypi`):
112
+
113
+ ```sh
114
+ uv run pytest
115
+ uv version --bump patch # or minor / major
116
+ git commit -am "Release $(uv version --short)" && git push
117
+ gh release create "v$(uv version --short)" --generate-notes
118
+ ```
119
+
120
+ PyPI never accepts the same version twice. Manual upload, if needed:
121
+ `rm -rf dist && uv build && UV_PUBLISH_TOKEN=<project token> uv publish`.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gnsskit"
3
- version = "0.5.1"
3
+ version = "0.6.0"
4
4
  description = "RTKLIB-based GNSS post-processing toolkit: RINEX tools, RTKLIB wrappers, static baselines and network adjustment, kinematic trajectories"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -46,6 +46,9 @@ all = [
46
46
  "matplotlib",
47
47
  ]
48
48
 
49
+ [project.scripts]
50
+ gnsskit-move3 = "gnsskit.export.move3:main"
51
+
49
52
  [project.urls]
50
53
  Repository = "https://github.com/franioli/gnsskit"
51
54
  Issues = "https://github.com/franioli/gnsskit/issues"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gnsskit"
3
- version = "0.5.1"
3
+ version = "0.6.0"
4
4
  description = "RTKLIB-based GNSS post-processing toolkit: RINEX tools, RTKLIB wrappers, static baselines and network adjustment, kinematic trajectories"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -26,6 +26,9 @@ network = ["scipy", "pyproj"]
26
26
  plot = ["matplotlib"]
27
27
  all = ["scipy", "pyproj", "matplotlib"] # every extra above
28
28
 
29
+ [project.scripts]
30
+ gnsskit-move3 = "gnsskit.export.move3:main"
31
+
29
32
  [project.urls]
30
33
  Repository = "https://github.com/franioli/gnsskit"
31
34
  Issues = "https://github.com/franioli/gnsskit/issues"
@@ -2,6 +2,7 @@
2
2
 
3
3
  from importlib.metadata import version
4
4
 
5
+ from .export import write_move3, write_starnet
5
6
  from .kinematic import interpolate
6
7
  from .plot import plot_baselines, plot_occupations, plot_pos, plot_visibility
7
8
  from .refsys import (
@@ -13,6 +14,7 @@ from .refsys import (
13
14
  ENUFrame,
14
15
  enu_diff,
15
16
  gpst_to_local,
17
+ to_gpst,
16
18
  utc_to_gpst,
17
19
  )
18
20
  from .rinex import (
@@ -82,6 +84,9 @@ __all__ = [
82
84
  "sessions_from_overlap",
83
85
  "signal_stats",
84
86
  "solve_static",
87
+ "to_gpst",
85
88
  "trim_rinex",
86
89
  "utc_to_gpst",
90
+ "write_move3",
91
+ "write_starnet",
87
92
  ]
@@ -0,0 +1,5 @@
1
+ """Export of gnsskit results to other software (no extra dependencies)."""
2
+
3
+ from .move3 import write_move3, write_starnet
4
+
5
+ __all__ = ["write_move3", "write_starnet"]
@@ -0,0 +1,401 @@
1
+ """Export static baselines to MOVE3 (native project or StarNet .gps file).
2
+
3
+ Pure numpy/stdlib: no extra dependencies. The input is the list of `BaselineResult` from
4
+ `process_baseline` / `read_baselines`, or the path of the CSV written by `write_baselines`.
5
+ Format reference: MOVE3 File Specification, section 1.1.
6
+
7
+ from gnsskit.export import write_move3
8
+ write_move3("baselines.csv", "move3/", "myproject", origin=("MIL3", 4421979.9, 718518.4, 4524921.2),
9
+ rename={"mil": "MIL3"})
10
+
11
+ Command line: `gnsskit-move3 native|starnet baselines.csv ...` (see `-h`).
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ from collections.abc import Mapping, Sequence
18
+ from dataclasses import replace
19
+ from pathlib import Path
20
+
21
+ import numpy as np
22
+
23
+ from ..static.baseline import BaselineResult, read_baselines
24
+
25
+ CRLF = "\r\n" # MOVE3 is a Windows program: use CRLF line endings
26
+ MAX_NAME_LEN = 16 # station names (spec 1.1)
27
+
28
+
29
+ def _prepare(
30
+ baselines: Sequence[BaselineResult] | Path | str, rename: Mapping[str, str] | None
31
+ ) -> list[BaselineResult]:
32
+ """Load baselines from a CSV if needed, rename stations and validate the names."""
33
+ bls = read_baselines(baselines) if isinstance(baselines, (str, Path)) else list(baselines)
34
+ if not bls:
35
+ raise ValueError("no baselines to export")
36
+ rename = rename or {}
37
+ bls = [
38
+ replace(b, base=rename.get(b.base, b.base), rover=rename.get(b.rover, b.rover)) for b in bls
39
+ ]
40
+ for name in {n for b in bls for n in (b.base, b.rover)}:
41
+ if len(name) > MAX_NAME_LEN or " " in name or " " in name.strip():
42
+ raise ValueError(
43
+ f"invalid MOVE3 station name {name!r}: max {MAX_NAME_LEN} characters, no spaces"
44
+ )
45
+ return bls
46
+
47
+
48
+ def approx_coords(
49
+ bls: Sequence[BaselineResult], origin: Mapping[str, np.ndarray]
50
+ ) -> dict[str, np.ndarray]:
51
+ """Propagate approximate coordinates from the origin station along the baselines.
52
+
53
+ Raises:
54
+ ValueError: If a station is not connected to the origin.
55
+ """
56
+ xyz = dict(origin)
57
+ todo = True
58
+ while todo:
59
+ todo = False
60
+ for b in bls:
61
+ if b.base in xyz and b.rover not in xyz:
62
+ xyz[b.rover] = xyz[b.base] + b.dxyz
63
+ todo = True
64
+ elif b.rover in xyz and b.base not in xyz:
65
+ xyz[b.base] = xyz[b.rover] - b.dxyz
66
+ todo = True
67
+ stations = {n for b in bls for n in (b.base, b.rover)}
68
+ if unreachable := sorted(stations - xyz.keys()):
69
+ raise ValueError(f"stations not connected to the origin {list(origin)}: {unreachable}")
70
+ return xyz
71
+
72
+
73
+ def _write_native(
74
+ bls: Sequence[BaselineResult],
75
+ origin: Mapping[str, np.ndarray],
76
+ fix_origin: bool,
77
+ project: str,
78
+ m0: float,
79
+ outdir: Path,
80
+ ) -> list[Path]:
81
+ """MOVE3 GCO + OBS; precision as sd/correlations plus M0 factor (spec 1.1.4)."""
82
+
83
+ def head(kind: str) -> str:
84
+ return f"MOVE3 V4.5.1 {kind} file\n$\n{project}\n$\n"
85
+
86
+ xyz = approx_coords(bls, origin)
87
+ gco = head("GCO") + "COORDINATES XYZ\n$\n"
88
+ for name, p in xyz.items():
89
+ star = "*" if fix_origin and name in origin else " " # '*' = known (fixed) coordinate
90
+ gco += f"{name:<16}" + "".join(f"{v:16.4f}{star}" for v in p) + "\n"
91
+ gco += "$\n"
92
+ obs = head("OBS") + "ANGLEUNIT GON\n$\n\n"
93
+ for b in bls:
94
+ s = np.sqrt(np.diag(b.cov))
95
+ c = b.cov / np.outer(s, s)
96
+ obs += (
97
+ f"DX {b.base:<14}{b.rover:<14}"
98
+ + "".join(f"{v:14.4f}" for v in b.dxyz)
99
+ + " ".join( # fields need at least two spaces between them (spec 1.1)
100
+ [
101
+ "",
102
+ f"{s[0]:.4f}",
103
+ f"{c[0, 1]:.3f}",
104
+ f"{s[1]:.4f}",
105
+ f"{c[0, 2]:.3f}",
106
+ f"{c[1, 2]:.3f}",
107
+ f"{s[2]:.4f}",
108
+ "M0",
109
+ f"{m0}",
110
+ ]
111
+ )
112
+ + "\n"
113
+ )
114
+ obs += "$\n" # files must end with a block separator
115
+ paths = []
116
+ for ext, text in (("gco", gco), ("obs", obs)):
117
+ paths.append(outdir / f"{project}.{ext}")
118
+ paths[-1].write_text(text.replace("\n", CRLF), newline="")
119
+ return paths
120
+
121
+
122
+ # MOVE3 project file; _write_prj sets the name (3rd record) and the PRJ_KEYS below
123
+ PRJ_TEMPLATE = """MOVE3 V4.5.1 PRJ file
124
+ $
125
+ test_reteA_gr2
126
+ $ INCLUDED FILE TYPES
127
+ TerCoord YES
128
+ GPSCoord YES
129
+ TerObserv YES
130
+ GPSObserv YES
131
+ GeoidModel NO
132
+ FeatureCode NONE
133
+ ProjectType DEFAULT
134
+ $ GEOMETRY PARAMETERS
135
+ Dimension 3
136
+ Projection NONE
137
+ ProjName
138
+ LonOriginCM
139
+ LatOrigin
140
+ StandPar1
141
+ StandPar2
142
+ SkewAzimuth
143
+ ProjScaleFac
144
+ FalseEasting
145
+ FalseNorthing
146
+ Ellipsoid BESSEL_1841
147
+ SemiMajAx 6377397.1550
148
+ InvFlatt 299.152812800
149
+ TransProj NONE
150
+ GPSCoordType XYZ
151
+ $ ADJUSTMENT PARAMETERS
152
+ AdjDesign ADJUST
153
+ Phase 1
154
+ InnerConstraint FALSE
155
+ AngleUnit GON
156
+ LinearUnit m 1.0000000000000 meter
157
+ IterMax 3
158
+ Epsilon 0.0001
159
+ Delta 1.0e-006
160
+ CovMatrix NONE
161
+ APostVarFac DONOT
162
+ VarComponent NONE
163
+ VarIterMax 5
164
+ VarEpsilon 0.0100
165
+ FilterFreeStations FALSE
166
+ EstAddTrf FREENET
167
+ $ PRECISION AND TESTING PARAMETERS
168
+ Sigma0 1.0e+000
169
+ Alfa0 0.0010
170
+ Beta 0.80
171
+ ConfidenceLevel1D 0.683
172
+ ConfidenceLevel2D 0.394
173
+ C0 0.000
174
+ C1 1.000
175
+ DataSnooping NO
176
+ DataSnoopingFTestHigh 2.000
177
+ DataSnoopingFTestLow 0.500
178
+ DataSnoopingMaxRemovals 25
179
+ DataSnoopingMinRedundancy 51.00
180
+ $ DEFAULT STANDARD DEVIATIONS
181
+ SigmaAbsR 0.00100
182
+ SigmaRelR 0.00000
183
+ SigmaAbsS 0.0100
184
+ SigmaRelS 0.0
185
+ SigmaAbsZ 0.00100
186
+ SigmaRelZ 0.00000
187
+ SigmaAbsA 0.00100
188
+ SigmaRelA 0.00000
189
+ SigmaDHA 0.00
190
+ SigmaDHB 1.00
191
+ SigmaDHC 0.00
192
+ SigmaShiftVectorEN 0.0100
193
+ SigmaShiftVectorH 0.0100
194
+ SigmaLocalCoordEN 0.0100
195
+ SigmaLocalCoordH 0.0100
196
+ SigmaAbsDX 0.0100
197
+ SigmaRelDX 1.0
198
+ SigmaAbsX 0.0100
199
+ SigmaLatLon 0.0100
200
+ SigmaHgt 0.01000
201
+ SigmaXYZ 0.0100
202
+ SigmaCentr 0.0000
203
+ SigmaInstr 0.00000
204
+ SigmaTape 0.0100
205
+ SigmaOrthogonal 0.0100
206
+ SigmaDistLine 0.0150
207
+ SigmaAngle 0.10000
208
+ SigmaIdealXY 0.0000
209
+ SigmaIdealH 0.0000
210
+ SigmaGeoidAbs 0.0000
211
+ SigmaGeoidRel 0.0000
212
+ $ ADDITIONAL PARAMETERS
213
+ ScaleFac0 FREE 1.0000000
214
+ ScaleFac1 FREE 1.0000000
215
+ ScaleFac2 FREE 1.0000000
216
+ ScaleFac3 FREE 1.0000000
217
+ ScaleFac4 FREE 1.0000000
218
+ ScaleFac5 FREE 1.0000000
219
+ ScaleFac6 FREE 1.0000000
220
+ ScaleFac7 FREE 1.0000000
221
+ ScaleFac8 FREE 1.0000000
222
+ ScaleFac9 FREE 1.0000000
223
+ VertRefr0 FIXED 0.13
224
+ VertRefr1 FIXED 0.13
225
+ VertRefr2 FIXED 0.13
226
+ VertRefr3 FIXED 0.13
227
+ VertRefr4 FIXED 0.13
228
+ VertRefr5 FIXED 0.13
229
+ VertRefr6 FIXED 0.13
230
+ VertRefr7 FIXED 0.13
231
+ VertRefr8 FIXED 0.13
232
+ VertRefr9 FIXED 0.13
233
+ AzimOffs0 FIXED 0.00000
234
+ AzimOffs1 FIXED 0.00000
235
+ AzimOffs2 FIXED 0.00000
236
+ AzimOffs3 FIXED 0.00000
237
+ AzimOffs4 FIXED 0.00000
238
+ AzimOffs5 FIXED 0.00000
239
+ AzimOffs6 FIXED 0.00000
240
+ AzimOffs7 FIXED 0.00000
241
+ AzimOffs8 FIXED 0.00000
242
+ AzimOffs9 FIXED 0.00000
243
+ GPSTrfTX FREE 0.0000 0.0000
244
+ GPSTrfTY FREE 0.0000 0.0000
245
+ GPSTrfTZ FREE 0.0000 0.0000
246
+ GPSTrfRX FREE 0.00000 0.00000
247
+ GPSTrfRY FREE 0.00000 0.00000
248
+ GPSTrfRZ FREE 0.00000 0.00000
249
+ GPSTrfSc FREE 1.0000000000 0.0000000000
250
+ LocalTrfType NONE
251
+ $ PRINT OUTPUT SWITCHES
252
+ PrProjConst YES
253
+ PrInpCoords YES
254
+ PrAddParms YES
255
+ PrInpObsv YES
256
+ PrAdjCoords YES
257
+ PrExtReliab NO
258
+ PrAbsStandEll YES
259
+ PrRelStandEll YES
260
+ PrTestCoords YES
261
+ PrErrCoords YES
262
+ PrAdjParms YES
263
+ PrAdjObsv YES
264
+ PrTestObsv YES
265
+ PrErrObsv YES
266
+ LogFile XML
267
+ $
268
+ """
269
+
270
+ # .prj keys needed for a GPS-only XYZ project (spec 1.1.1); everything else comes from the template
271
+ PRJ_KEYS = {
272
+ "TerCoord": "NO",
273
+ "GPSCoord": "YES",
274
+ "TerObserv": "NO",
275
+ "GPSObserv": "YES",
276
+ "Projection": "NONE",
277
+ "Ellipsoid": "WGS84",
278
+ "SemiMajAx": " 6378137.0000",
279
+ "InvFlatt": " 298.257223563",
280
+ "GPSCoordType": "XYZ",
281
+ "AngleUnit": "GON",
282
+ }
283
+
284
+
285
+ def _write_prj(project: str, outdir: Path) -> Path:
286
+ """Write PROJECT.prj from PRJ_TEMPLATE, setting the project name and PRJ_KEYS."""
287
+ lines = PRJ_TEMPLATE.splitlines()
288
+ lines[2] = project # third record of the header is the project name
289
+ for i, line in enumerate(lines):
290
+ key = line.split(maxsplit=1)[0] if line.strip() else ""
291
+ if key in PRJ_KEYS:
292
+ lines[i] = f"{key:<20}{PRJ_KEYS[key]}"
293
+ path = outdir / f"{project}.prj"
294
+ path.write_text(CRLF.join(lines) + CRLF, newline="")
295
+ return path
296
+
297
+
298
+ def write_move3(
299
+ baselines: Sequence[BaselineResult] | Path | str,
300
+ outdir: Path | str,
301
+ project: str,
302
+ origin: tuple[str, float, float, float],
303
+ *,
304
+ fix_origin: bool = False,
305
+ m0: float = 10.0,
306
+ rename: Mapping[str, str] | None = None,
307
+ ) -> list[Path]:
308
+ """Write a complete native MOVE3 project: PROJECT.gco, PROJECT.obs, PROJECT.prj.
309
+
310
+ Args:
311
+ baselines: Baselines, or the CSV written by `write_baselines`.
312
+ outdir: Output folder, created if missing. Use a fresh one: MOVE3 overwrites the
313
+ files when an empty project is saved.
314
+ project: Project name (max 30 characters), used for the file names and headers.
315
+ origin: (station, X, Y, Z) with known ECEF coordinates [m], e.g. the base from the
316
+ RINEX header. The other stations get approximate coordinates along the baselines.
317
+ fix_origin: Mark the origin as known ('*') in the .gco.
318
+ m0: Multiplication factor of the baseline standard deviations (RTKLIB sigmas are
319
+ optimistic; written as 'M0 f' on each baseline).
320
+ rename: Station renaming {old: new}, applied before `origin` is looked up.
321
+
322
+ Returns:
323
+ The written files [.gco, .obs, .prj].
324
+ """
325
+ bls = _prepare(baselines, rename)
326
+ out = Path(outdir)
327
+ out.mkdir(parents=True, exist_ok=True)
328
+ org = {origin[0]: np.array(origin[1:], dtype=float)}
329
+ return [*_write_native(bls, org, fix_origin, project, m0, out), _write_prj(project, out)]
330
+
331
+
332
+ def write_starnet(
333
+ baselines: Sequence[BaselineResult] | Path | str,
334
+ outdir: Path | str,
335
+ project: str = "project",
336
+ *,
337
+ m0: float = 10.0,
338
+ rename: Mapping[str, str] | None = None,
339
+ ) -> Path:
340
+ """Write a StarNet NAME.gps file, imported into MOVE3 with Import/export > GNSS/GPS.
341
+
342
+ G0 label, G1 from-to dXYZ, G2 variances, G3 covariances. The format has no M0 field, so
343
+ covariances are scaled by `m0`**2. No station coordinates: enter them in MOVE3 afterwards.
344
+
345
+ Returns:
346
+ The written file.
347
+ """
348
+ bls = _prepare(baselines, rename)
349
+ out = Path(outdir)
350
+ out.mkdir(parents=True, exist_ok=True)
351
+ lines = [".GPS WEIGHT COVARIANCE"]
352
+ for b in bls:
353
+ c = b.cov * m0**2
354
+ lines += [
355
+ "G0 '" + f"{project} {b.session} {b.base}-{b.rover}".replace(" ", " "),
356
+ f"G1 {b.base}-{b.rover} " + " ".join(f"{v:.4f}" for v in b.dxyz),
357
+ f"G2 {c[0, 0]:.6E} {c[1, 1]:.6E} {c[2, 2]:.6E}",
358
+ f"G3 {c[0, 1]:.6E} {c[0, 2]:.6E} {c[1, 2]:.6E}",
359
+ ]
360
+ path = out / f"{project}.gps"
361
+ path.write_text(CRLF.join(lines) + CRLF, newline="")
362
+ return path
363
+
364
+
365
+ def main(argv: Sequence[str] | None = None) -> None:
366
+ """Command line: `gnsskit-move3 native|starnet baselines.csv ...`."""
367
+ common = argparse.ArgumentParser(add_help=False)
368
+ common.add_argument("csv", type=Path, help="baselines CSV written by write_baselines")
369
+ common.add_argument("--outdir", type=Path, default=Path("."), help="output folder")
370
+ common.add_argument(
371
+ "--m0", type=float, default=10.0,
372
+ help="multiplication factor of the baseline standard deviations (default: %(default)s)",
373
+ ) # fmt: skip
374
+ common.add_argument(
375
+ "--rename", nargs="*", default=[], metavar="OLD=NEW", help="rename stations, e.g. mil=MIL3"
376
+ )
377
+ ap = argparse.ArgumentParser(
378
+ description="Export RTKLIB baselines (ECEF + covariance) to MOVE3."
379
+ )
380
+ sub = ap.add_subparsers(dest="format", required=True, metavar="{native,starnet}")
381
+ nat = sub.add_parser("native", parents=[common], help="PROJECT.gco + .obs + .prj")
382
+ nat.add_argument("--project", required=True, metavar="NAME", help="project name")
383
+ nat.add_argument(
384
+ "--origin", required=True, nargs=4, metavar=("NAME", "X", "Y", "Z"),
385
+ help="station with known ECEF coordinates [m]",
386
+ ) # fmt: skip
387
+ nat.add_argument("--fix_origin", action="store_true", help="write the origin as fixed")
388
+ sn = sub.add_parser("starnet", parents=[common], help="StarNet NAME.gps file")
389
+ sn.add_argument("--project", default="project", metavar="NAME", help="name of NAME.gps")
390
+ a = ap.parse_args(argv)
391
+
392
+ if any("=" not in r for r in a.rename):
393
+ ap.error("--rename expects OLD=NEW pairs, e.g. --rename mil=MIL3")
394
+ rename = dict(r.split("=", 1) for r in a.rename)
395
+ if a.format == "native":
396
+ o = a.origin
397
+ paths = write_move3(a.csv, a.outdir, a.project, (o[0], *map(float, o[1:])),
398
+ fix_origin=a.fix_origin, m0=a.m0, rename=rename) # fmt: skip
399
+ else:
400
+ paths = [write_starnet(a.csv, a.outdir, a.project, m0=a.m0, rename=rename)]
401
+ print("wrote " + ", ".join(map(str, paths)))
@@ -55,6 +55,31 @@ def gpst_to_local(t: T, tz: str = "Europe/Rome", leap_s: int = GPST_UTC_OFFSET_S
55
55
  return utc.tz_localize("UTC").tz_convert(tz).tz_localize(None)
56
56
 
57
57
 
58
+ def to_gpst(t: str | pd.Timestamp, time: str = "gpst", tz: str = "Europe/Rome") -> pd.Timestamp:
59
+ """Parse a time given in GPST, UTC or local civil time and return it in GPST.
60
+
61
+ Args:
62
+ t: Time as a string or timestamp, naive.
63
+ time: Time system of `t`: "gpst", "utc" or "local".
64
+ tz: IANA time zone of "local" (daylight saving time is applied).
65
+
66
+ Returns:
67
+ The naive GPST timestamp.
68
+
69
+ Raises:
70
+ ValueError: If `time` is not one of the above, or a local time is ambiguous or does
71
+ not exist (daylight saving time change).
72
+ """
73
+ ts = pd.Timestamp(t)
74
+ if time == "gpst":
75
+ return ts
76
+ if time == "local":
77
+ ts = ts.tz_localize(tz).tz_convert("UTC").tz_localize(None)
78
+ elif time != "utc":
79
+ raise ValueError(f"time must be 'gpst', 'utc' or 'local', not {time!r}")
80
+ return utc_to_gpst(ts)
81
+
82
+
58
83
  def gps_seconds(t: pd.Timestamp | pd.Series) -> float | pd.Series:
59
84
  """Seconds since the GPS epoch (1980-01-06), which avoids week roll-over problems.
60
85
 
@@ -134,12 +134,29 @@ def header_llh(obs: Path | str, ellipsoid: Ellipsoid = GRS80) -> tuple[float, fl
134
134
  # =============================================================================
135
135
 
136
136
 
137
+ def _filter_header(header: list[str], systems: str | None) -> list[str]:
138
+ """Drop the stale satellite statistics and the `SYS / ...` records of removed systems."""
139
+ out = []
140
+ system = "" # system of the last `SYS /` record: continuation lines start with a blank
141
+ for line in header:
142
+ label = line[60:].strip()
143
+ if label in ("# OF SATELLITES", "PRN / # OF OBS"):
144
+ continue
145
+ if systems is not None and label.startswith("SYS /"):
146
+ system = line[0] if line[0] != " " else system
147
+ if system not in systems:
148
+ continue
149
+ out.append(line)
150
+ return out
151
+
152
+
137
153
  def _convbin_trim(
138
154
  src: Path,
139
155
  dst: Path,
140
156
  start: pd.Timestamp | None,
141
157
  end: pd.Timestamp | None,
142
158
  interval: float | None,
159
+ systems: str | None = None,
143
160
  ) -> bool:
144
161
  """Trim with RTKLIB `convbin`; False if it is not installed or fails."""
145
162
  exe = shutil.which("convbin")
@@ -148,6 +165,9 @@ def _convbin_trim(
148
165
  with src.open() as f:
149
166
  version = f.readline()[:9].strip()
150
167
  cmd = [exe, "-r", "rinex", "-v", version, "-od", "-os"] # keep Doppler and SNR
168
+ for s in SYSTEMS if systems is not None else "":
169
+ if s not in systems:
170
+ cmd += ["-y", s] # exclude system
151
171
  if end is not None:
152
172
  # convbin excludes the epoch at -te, and truncates it
153
173
  end += pd.Timedelta(seconds=1)
@@ -175,12 +195,14 @@ def trim_rinex(
175
195
  interval: float | None = None,
176
196
  use_convbin: bool = False,
177
197
  marker: str | None = None,
198
+ systems: str | None = None,
178
199
  ) -> Path:
179
- """Write a RINEX 3 observation file trimmed to [start, end] and decimated.
200
+ """Write a RINEX 3 observation file trimmed to [start, end], decimated and filtered.
180
201
 
181
202
  The pure-Python path drops event records without a timestamp, updates the `INTERVAL`,
182
- `TIME OF FIRST OBS` and `TIME OF LAST OBS` header lines and copies the rest of the
183
- header unchanged. RTKLIB `convbin` writes its own header instead, drops QZSS, and
203
+ `TIME OF FIRST OBS` and `TIME OF LAST OBS` header lines, drops the optional
204
+ `# OF SATELLITES` and `PRN / # OF OBS` records (no longer valid) and copies the rest of
205
+ the header unchanged. RTKLIB `convbin` writes its own header instead, drops QZSS, and
184
206
  excludes the epoch at `end`; it is run with `end` + 1 s, so with data above 1 Hz and no
185
207
  `interval` it may keep epochs up to 1 s after `end`.
186
208
 
@@ -195,6 +217,9 @@ def trim_rinex(
195
217
  Python implementation if it is missing or fails.
196
218
  marker: New `MARKER NAME` for the header. None keeps the original. Ignored by
197
219
  `convbin`, which writes its own header.
220
+ systems: Satellite systems to keep, e.g. "GRE" (letters of `SYSTEMS`). None keeps
221
+ all. The other systems are removed from the observations and from the
222
+ `SYS / ...` header records, and the satellite count of each epoch is updated.
198
223
 
199
224
  Returns:
200
225
  The output path.
@@ -202,13 +227,22 @@ def trim_rinex(
202
227
  Raises:
203
228
  ValueError: If no epoch is kept.
204
229
  """
205
- if use_convbin and _convbin_trim(Path(src), Path(dst), start, end, interval):
230
+ if use_convbin and _convbin_trim(Path(src), Path(dst), start, end, interval, systems):
206
231
  return Path(dst)
207
232
  step_ms = None if interval is None else round(interval * 1000)
208
233
  header: list[str] = []
209
234
  body: list[str] = []
210
235
  epochs: list[pd.Timestamp] = []
211
236
  keep = False
237
+ epoch_line = -1 # index in body of the current observation epoch record, -1 if none
238
+ nsat = 0
239
+
240
+ def close_epoch() -> None:
241
+ # RINEX 3 epoch record: number of satellites in columns 33-35
242
+ if epoch_line >= 0:
243
+ rec = body[epoch_line]
244
+ body[epoch_line] = f"{rec[:32]}{nsat:3d}{rec[35:]}"
245
+
212
246
  with Path(src).open() as f:
213
247
  in_header = True
214
248
  for line in f:
@@ -217,6 +251,9 @@ def trim_rinex(
217
251
  in_header = "END OF HEADER" not in line
218
252
  continue
219
253
  if line.startswith(">"):
254
+ if systems is not None:
255
+ close_epoch()
256
+ epoch_line = -1
220
257
  try:
221
258
  t = _epoch_time(line[1:])
222
259
  except ValueError: # event record: dropped together with its lines
@@ -230,10 +267,21 @@ def trim_rinex(
230
267
  )
231
268
  if keep:
232
269
  epochs.append(t)
270
+ if line[31] in "01": # observations follow (not special records)
271
+ epoch_line, nsat = len(body), 0
272
+ body.append(line)
273
+ continue
233
274
  if keep:
275
+ if epoch_line >= 0 and systems is not None:
276
+ if line[0] not in systems:
277
+ continue
278
+ nsat += 1
234
279
  body.append(line)
280
+ if systems is not None:
281
+ close_epoch()
235
282
  if not epochs:
236
283
  raise ValueError(f"{src}: no epochs kept")
284
+ header = _filter_header(header, systems)
237
285
 
238
286
  def field(value: str, label: str) -> str:
239
287
  return f"{value:<60}{label}\n"
@@ -140,8 +140,8 @@ class RtkConfig:
140
140
  # Marker -> ARP offset (E, N, U) in m; "*" antenna types read it from the RINEX header
141
141
  rover_antdel: Triple | None = _opt(_ROVER_ANTDEL)
142
142
  base_antdel: Triple | None = _opt(_BASE_ANTDEL)
143
- satantfile: str | None = _opt("file-satantfile") # ANTEX files
144
- rcvantfile: str | None = _opt("file-rcvantfile")
143
+ satantfile: str | Path | None = _opt("file-satantfile") # ANTEX files
144
+ rcvantfile: str | Path | None = _opt("file-rcvantfile")
145
145
 
146
146
  # --- output ---
147
147
  solformat: SolFormat | None = _opt("out-solformat", "xyz")
gnsskit-0.5.1/README.md DELETED
@@ -1,157 +0,0 @@
1
- # gnsskit
2
-
3
- Shared tools for post-processing GNSS data with [RTKLIB](https://www.rtklib.com/) `rnx2rtkp`, used by
4
- [djippk](https://github.com/franioli/djippk) (drone PPK) and [stopgo](https://github.com/franioli/stopgo)
5
- (stop-and-go surveys).
6
-
7
- > [!IMPORTANT]
8
- > **RTKLIB is not included and must be installed separately.** gnsskit runs the RTKLIB
9
- > command-line program `rnx2rtkp` (the CLI of RTKPOST) for the GNSS processing; `pip`/`uv` do
10
- > not install it. See [RTKLIB](#rtklib-required-separately) below.
11
-
12
- - **RTKLIB wrappers** (`gnsskit.rtklib`): `RtkConfig`, a typed, immutable set of `rnx2rtkp` options
13
- (`from_file`, `updated`, `with_options`, `with_base_llh`, `write`); `run_rnx2rtkp` and `find_rnx2rtkp`;
14
- `read_pos` (llh, xyz and enu `.pos` files).
15
- - **RINEX** (`gnsskit.rinex`): `rinex_span`, `header_llh`, `header_xyz`, `trim_rinex`; inspection with
16
- `obs_summary` (span, sampling, gaps, satellites) and `read_visibility`; survey occupations with
17
- `read_occupations` (point, receiver, session, time span and position of every occupation, from the
18
- file names, a field book or the headers), `sessions_from_overlap` and `flag_stale_headers`.
19
- - **Plots** (`gnsskit.plot`, needs the `plot` extra): `plot_visibility` (RTKPLOT-style satellite
20
- visibility), `plot_occupations` (map of where, when and with which receiver every point was
21
- occupied), `plot_baselines` (baseline network: arrows base -> rover, fixed/float, repeated
22
- baselines side by side, optional error ellipses) and `plot_pos` (RTKPLOT-like view of a static or
23
- kinematic `.pos` solution: ground track and E/N/U, satellites and ratio against time, colored by
24
- solution quality). The maps can be drawn over OpenStreetMap tiles.
25
- - **Static** (`gnsskit.static`): `solve_static` (one solution over a time window), `process_baseline`
26
- (static baselines with covariance), baseline IO and `loop_closures` (misclosure of every triangle of baselines); least-squares adjustment of a redundant baseline
27
- network in `gnsskit.static.network` (needs the `network` extra).
28
- - **Kinematic** (`gnsskit.kinematic`): trajectory interpolation and averaging.
29
- - **Reference systems** (`gnsskit.refsys`): GPST/UTC, ellipsoids, ECEF/geodetic conversions and
30
- `ENUFrame`, a local east-north-up frame at a point (points, vectors and covariances, both ways).
31
-
32
- ## Install
33
-
34
- With [uv](https://docs.astral.sh/uv/) (recommended), in your project:
35
-
36
- ```sh
37
- uv add gnsskit # library
38
- uv add "gnsskit[network]" # + network adjustment (scipy, pyproj)
39
- uv add "gnsskit[network,plot]" # + visibility plots and occupation maps (matplotlib)
40
- uv add "gnsskit[all]" # every extra
41
- uv add git+https://github.com/franioli/gnsskit # development version
42
- ```
43
-
44
- or in an existing environment, `uv pip install gnsskit` (same extras).
45
-
46
- With pip:
47
-
48
- ```sh
49
- pip install gnsskit
50
- pip install "gnsskit[all]" # with every extra
51
- ```
52
-
53
- ### RTKLIB (required separately)
54
-
55
- The processing functions (`run_rnx2rtkp`, `process_baseline`, `solve_static`) call the RTKLIB
56
- command-line program **`rnx2rtkp`**, which must be installed on your system and found on your
57
- `PATH` (or passed with `exe=`); `trim_rinex(use_convbin=True)` also needs RTKLIB `convbin`.
58
- The [demo5 fork](https://github.com/rtklibexplorer/RTKLIB) is
59
- recommended; gnsskit is developed with `rnx2rtkp ver.EX 2.5.1`.
60
-
61
- - **Windows**: download a [demo5 release](https://github.com/rtklibexplorer/RTKLIB/releases),
62
- unzip it and add the folder with `rnx2rtkp.exe` to your `PATH`.
63
- - **Linux / macOS**: build it from source:
64
- ```sh
65
- git clone https://github.com/rtklibexplorer/RTKLIB
66
- cd RTKLIB/app/consapp/rnx2rtkp/gcc && make && sudo make install
67
- ```
68
-
69
- Check it with `rnx2rtkp -?`. If it is missing, `run_rnx2rtkp` raises an error with these
70
- instructions. The rest of gnsskit (RINEX tools, `read_pos`, loop closures, network adjustment,
71
- reference systems) is pure Python and works without RTKLIB, e.g. on baselines computed elsewhere.
72
-
73
- ## Example
74
-
75
- ```python
76
- from gnsskit import RtkConfig, read_pos, run_rnx2rtkp
77
-
78
- config = RtkConfig(posmode="static", navsys="GEC", solformat="llh").with_base_llh(46.2, 9.8, 2300.0)
79
- pos_file = run_rnx2rtkp(rover_obs, base_obs, [nav], config, "out.pos")
80
- pos = read_pos(pos_file)
81
- ```
82
-
83
- Map of the occupations of a survey, from files named e.g. `s1_A1_gs14.26o`:
84
-
85
- ```python
86
- from gnsskit import find_rinex_obs, plot_occupations, read_occupations
87
-
88
- occ = read_occupations(
89
- find_rinex_obs(["rinex"]),
90
- name_pattern=r"(?P<session>s\d+)_(?P<point>[^_]+)_(?P<receiver>[^.]+)",
91
- )
92
- plot_occupations(occ, "occupations.png", stations={"mil": (4421979.92, 718518.37, 4524921.24)},
93
- basemap=True) # OpenStreetMap tiles: needs internet, falls back to a plain map
94
- ```
95
-
96
- Baseline network and RTKLIB solutions:
97
-
98
- ```python
99
- import pandas as pd
100
- from gnsskit import plot_baselines, plot_pos
101
-
102
- baselines = pd.read_csv("baselines.csv", dtype={"base": str, "rover": str}) # baselines_to_df
103
- plot_baselines(baselines, "network.png", fixed={"mil": (4421979.92, 718518.37, 4524921.24)})
104
- plot_pos("rover.pos", "rover.png") # static or kinematic, llh / xyz / enu
105
- ```
106
-
107
- See [example/](https://github.com/franioli/gnsskit/tree/main/example) for complete static, kinematic and network adjustment examples.
108
-
109
- ## Contributing
110
-
111
- Issues are welcome on [GitHub](https://github.com/franioli/gnsskit/issues). To contribute code:
112
-
113
- 1. Fork the repository on GitHub and clone your fork:
114
- ```sh
115
- git clone https://github.com/<your-username>/gnsskit && cd gnsskit
116
- git checkout -b my-feature
117
- ```
118
- 2. Set up the environment, make your changes and check them:
119
- ```sh
120
- uv sync # environment with the dev dependencies (incl. ruff)
121
- uv run pytest # tests
122
- uv run ruff format . # format the code
123
- uv run ruff check --fix . # lint, fixing what can be fixed automatically
124
- ```
125
-
126
- 3. Push the branch to your fork and open a pull request against `main` of
127
- `franioli/gnsskit`.
128
-
129
- ## Releasing a new version
130
-
131
- For the current maintainers only (it needs write access to the repository and to the PyPI
132
- project).
133
-
134
- Publishing a GitHub release runs [`.github/workflows/publish.yml`](.github/workflows/publish.yml),
135
- which checks that the tag matches the version, runs the tests, builds and uploads to PyPI:
136
-
137
- ```sh
138
- uv version --bump patch # or minor / major: updates pyproject.toml
139
- uv run pytest
140
- git commit -am "Release $(uv version --short)" && git push
141
- gh release create "v$(uv version --short)" --generate-notes # tag + release -> PyPI
142
- ```
143
-
144
- `gh release create` creates the tag on the pushed commit; without the GitHub CLI, push a tag
145
- (`git tag -a vX.Y.Z -m "gnsskit X.Y.Z" && git push origin vX.Y.Z`) and create the release from it
146
- on GitHub. PyPI never accepts the same version twice.
147
-
148
- One-time setup of the automatic upload (PyPI Trusted Publishing, no token): on pypi.org, project
149
- gnsskit -> Settings -> Publishing -> add a GitHub publisher with owner `franioli`, repository
150
- `gnsskit`, workflow `publish.yml` and environment `pypi`.
151
-
152
- Manual upload, if needed, with a project-scoped token kept outside the repository:
153
-
154
- ```sh
155
- rm -rf dist && uv build
156
- UV_PUBLISH_TOKEN=$(cat ~/.config/pypi/gnsskit.token) uv publish
157
- ```
File without changes
File without changes