Metadata-Version: 2.4
Name: gnsskit
Version: 0.6.0
Summary: RTKLIB-based GNSS post-processing toolkit: RINEX tools, RTKLIB wrappers, static baselines and network adjustment, kinematic trajectories
Keywords: gnss,gps,rtklib,ppk,surveying,least-squares
Author: Francesco Ioli
Author-email: Francesco Ioli <francesco.ioli@polimi.it>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Dist: numpy
Requires-Dist: pandas>=2
Requires-Dist: scipy ; extra == 'all'
Requires-Dist: pyproj ; extra == 'all'
Requires-Dist: matplotlib ; extra == 'all'
Requires-Dist: scipy ; extra == 'network'
Requires-Dist: pyproj ; extra == 'network'
Requires-Dist: matplotlib ; extra == 'plot'
Requires-Python: >=3.10
Project-URL: Repository, https://github.com/franioli/gnsskit
Project-URL: Issues, https://github.com/franioli/gnsskit/issues
Provides-Extra: all
Provides-Extra: network
Provides-Extra: plot
Description-Content-Type: text/markdown

# gnsskit

Shared tools for post-processing GNSS data with [RTKLIB](https://www.rtklib.com/) `rnx2rtkp`, used by
[djippk](https://github.com/franioli/djippk) (drone PPK) and [stopgo](https://github.com/franioli/stopgo)
(stop-and-go surveys).

> [!IMPORTANT]
> **RTKLIB is not included and must be installed separately.** gnsskit runs the RTKLIB
> command-line program `rnx2rtkp` (the CLI of RTKPOST) for the GNSS processing; `pip`/`uv` do
> not install it. See [RTKLIB](#rtklib-required-separately) below.

- **RTKLIB**: typed `RtkConfig`, `run_rnx2rtkp`, `read_pos`.
- **RINEX**: inspect, trim and decimate observation files; survey occupations.
- **Static**: baselines with covariance, loop closures, least-squares network adjustment.
- **Kinematic**: trajectory interpolation and averaging.
- **Reference systems and plots**: GPST/UTC, ECEF/geodetic/ENU; visibility, occupation, baseline and `.pos` plots.
- **Export**: MOVE3 projects.

## Install

With [uv](https://docs.astral.sh/uv/) (recommended), in your project:

```sh
uv add gnsskit                  # library
uv add "gnsskit[network]"       # + network adjustment (scipy, pyproj)
uv add "gnsskit[network,plot]"  # + visibility plots and occupation maps (matplotlib)
uv add "gnsskit[all]"           # every extra
uv add git+https://github.com/franioli/gnsskit   # development version
```

or in an existing environment, `uv pip install gnsskit` (same extras).

With pip:

```sh
pip install gnsskit
pip install "gnsskit[all]"   # with every extra
```

### RTKLIB (required separately)

The processing functions (`run_rnx2rtkp`, `process_baseline`, `solve_static`) call the RTKLIB
command-line program **`rnx2rtkp`**, which must be installed on your system and found on your
`PATH` (or passed with `exe=`); `trim_rinex(use_convbin=True)` also needs RTKLIB `convbin`.
The [demo5 fork](https://github.com/rtklibexplorer/RTKLIB) is
recommended; gnsskit is developed with `rnx2rtkp ver.EX 2.5.1`.

- **Windows**: download a [demo5 release](https://github.com/rtklibexplorer/RTKLIB/releases),
  unzip it and add the folder with `rnx2rtkp.exe` to your `PATH`.
- **Linux / macOS**: build it from source:
  ```sh
  git clone https://github.com/rtklibexplorer/RTKLIB
  cd RTKLIB/app/consapp/rnx2rtkp/gcc && make && sudo make install
  ```

Check it with `rnx2rtkp -?`. If it is missing, `run_rnx2rtkp` raises an error with these
instructions. The rest of gnsskit (RINEX tools, `read_pos`, loop closures, network adjustment,
reference systems) is pure Python and works without RTKLIB, e.g. on baselines computed elsewhere.

## Example

Baselines of a static network with RTKLIB, then a least-squares adjustment with one fixed point:

```python
from gnsskit import RtkConfig, process_baseline
from gnsskit.static.network import adjust_network, coordinate_table

conf = RtkConfig(posmode="static", navsys="GRE", solformat="xyz", base_postype="rinexhead")
baselines = [
    process_baseline(rover, base, f"{rover}.26o", f"{base}.26o", ["nav.26n"], conf, f"{base}-{rover}.pos")
    for base, rover in [("MIL3", "A1"), ("MIL3", "A2"), ("A1", "A2")]
]
adj = adjust_network(baselines, fixed={"MIL3": (4421979.9187, 718518.3650, 4524921.2364)})
print(coordinate_table(adj))
```

## Documentation

- [docs/](https://github.com/franioli/gnsskit/tree/main/docs): one short guide per module (RINEX,
  RTKLIB, static baselines and adjustment, kinematic, reference systems, plots, MOVE3 export).
- [scripts/](https://github.com/franioli/gnsskit/tree/main/scripts): command-line tools for RINEX
  statistics, occupation maps and trimming.
- [example/](https://github.com/franioli/gnsskit/tree/main/example): complete worked examples
  (static, kinematic, static network with data).

## Contributing

Issues are welcome on [GitHub](https://github.com/franioli/gnsskit/issues). To contribute code:

1. Fork the repository on GitHub and clone your fork:
   ```sh
   git clone https://github.com/<your-username>/gnsskit && cd gnsskit
   git checkout -b my-feature
   ```
2. Set up the environment, make your changes and check them:
   ```sh
   uv sync                      # environment with the dev dependencies (incl. ruff)
   uv run pytest                # tests
   uv run ruff format .         # format the code
   uv run ruff check --fix .    # lint, fixing what can be fixed automatically
   ```

3. Push the branch to your fork and open a pull request against `main` of
   `franioli/gnsskit`.

## Releasing a new version

Maintainers only. Publishing a GitHub release runs
[`publish.yml`](.github/workflows/publish.yml), which checks the tag against the version, builds
and uploads to PyPI (Trusted Publishing: publisher `franioli/gnsskit`, workflow `publish.yml`,
environment `pypi`):

```sh
uv run pytest
uv version --bump patch            # or minor / major
git commit -am "Release $(uv version --short)" && git push
gh release create "v$(uv version --short)" --generate-notes
```

PyPI never accepts the same version twice. Manual upload, if needed:
`rm -rf dist && uv build && UV_PUBLISH_TOKEN=<project token> uv publish`.
