Metadata-Version: 2.4
Name: cnrdiff
Version: 2.2.0
Summary: A library used to compare signal-to-noise ratio.
Author-email: Sheng Guoliang <shengguoliang@sinognss.com>, Yang Fawang <yangfawang@sinognss.com>
License: MIT
Keywords: cnr,signal-to-noise,gnss,rinex,bnc
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
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: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pandas>=2.0.0
Requires-Dist: pyrtcm>=1.0.0

# CNRDIFF

A library used to compare signal-to-noise ratio for GNSS observation data.

## Dependencies

- pandas >= 2.0.0
- pyrtcm >= 1.0.0

## Usage

Compute carrier-to-noise ratio differences of stations SN04 and SN02 relative to reference station SN01:

```bash
cnrdiff SN01001a.24O SN02001a.24O SN04001a.24O
```

### Optional arguments

Compute differences by satellite system and save the output to a file:

```bash
cnrdiff --ftype RTCM3_MSM4 a.rtcm b.rtcm --by-sys > result.txt
```

Supported file types and auto-detected suffixes:

| File type       | Suffix examples        |
|-----------------|------------------------|
| BNC_QC_LOG      | `.log`                 |
| RINEX3_OBS      | `.rnx`, `.obs`, `.*O`  |
| RTCM3_MSM4      | `.rtcm`                |

Use `--ftype` to override auto-detection when needed.

## Averaging algorithm

### Assumptions

1. Each station records observation data normally, with no missing epochs or event interruptions.
2. Observation data from all stations is time-synchronized, with start and end times as consistent as possible.
3. The epoch interval of observation data does not exceed 1 second; data is processed as 1-second intervals.

### By satellite PRN (default)

The intermediate CNR binary file generated during execution is an SQLite database that stores the carrier-to-noise ratio for each epoch, each satellite, and each signal type.

1. First, compute the average of each signal type over all epochs for each satellite to obtain a table indexed by satellite PRN and signal type.
2. Then align the tables from all stations and compute differences to obtain a table indexed by satellite PRN + signal type and station (data file name).

### By satellite system

Extract the satellite system from the satellite PRN as a new dimension.

1. First, compute the average of each signal type over all satellites and all epochs for each satellite system (equivalent to a weighted average by epoch count per satellite) to obtain a table indexed by satellite system and signal type.
2. Then align the tables from all stations and compute differences to obtain a table indexed by satellite system + signal type and station (data file name).

## License

MIT

## Authors and contributors

**Lead Programmer:**
Sheng Guoliang <shengguoliang@sinognss.com>

**Contributors:**
- Yang Fawang <yangfawang@sinognss.com>
