Metadata-Version: 2.4
Name: hamsci-dsp
Version: 0.11.0
Summary: Shared DSP / timing utilities for the HamSCI sigmond suite
Author-email: Michael Hauan <mjh@hauan.org>
License-Expression: MIT
Project-URL: Homepage, https://github.com/HamSCI/hamsci-dsp
Project-URL: Bug Tracker, https://github.com/HamSCI/hamsci-dsp/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24.0
Requires-Dist: geographiclib>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: scipy>=1.10; extra == "dev"
Provides-Extra: tomography
Requires-Dist: scipy>=1.10; extra == "tomography"
Provides-Extra: iono
Requires-Dist: iri2020>=1.7; extra == "iono"
Dynamic: license-file

# hamsci-dsp

Signal-processing, geometry and timing code for HF radio science, shared by
the programs of the [HamSCI](https://hamsci.org/) **sigmond** station suite.
Each function here once lived as a copy inside several of those programs; this
library keeps one tested version of each.

It provides a library only: no command line, no service, no daemon.

## Install

```bash
pip install hamsci-dsp
```

The core needs only numpy and geographiclib. Heavier engines wait behind
extras:

| Extra | Adds | For |
|-------|------|-----|
| `iono` | `iri2020` (builds with gfortran) | the IRI ionosphere model in `hamsci_dsp.ionosphere` |
| `tomography` | `scipy` | E/F-layer tomography in `hamsci_dsp.ionosphere.tomography` |

```bash
pip install 'hamsci-dsp[iono,tomography]'
```

Ray tracing has no extra. `hamsci_dsp.raytrace` uses HamSCI's PyLAP and the
PHaRLAP ray tracer when you have installed them yourself (PHaRLAP carries its
own licence and download), and does nothing otherwise.

## A first example

```python
from hamsci_dsp.geometry import grid_to_latlon, great_circle_km, latlon_to_grid

tx = grid_to_latlon("EN50")        # (40.5, -89.0), the centre of the square
rx = grid_to_latlon("FN42hn")      # (42.5625, -71.375)
print(round(great_circle_km(*tx, *rx), 1))   # 1485.8
print(latlon_to_grid(*rx))                   # FN42hn
```

## What it holds

**Geometry, signals and propagation**

| Module | Provides | Needs |
|--------|----------|-------|
| `hamsci_dsp.constants` | `C_M_S`, `K_TEC = 40.3`, `R_EARTH_KM`, `TECU` | stdlib |
| `hamsci_dsp.geometry` | great-circle distance, bearing, midpoint and destination (geographiclib); reflection geometry (elevation, hops, height from path); Maidenhead grid to and from latitude and longitude | geographiclib |
| `hamsci_dsp.dsp` | peak SNR (Rayleigh and signed), robust noise floor, `CoherentStack` for slow-time range-Doppler, carrier to Doppler, FFT correlation | numpy |
| `hamsci_dsp.propagation` | path observables: `carrier` (phase to dTEC and its rate), `oblique` (virtual height, equivalent vertical frequency, MUF, obliquity), `scintillation` (S4 and σφ after ITU-R P.531) | numpy |
| `hamsci_dsp.chirp` | chirp-sounder waveform, screening and cleaning, shared by chirp-recorder and its tools | numpy |
| `hamsci_dsp.stability` | Allan deviation and related stability measures | numpy |

**The ionosphere**

| Module | Provides | Needs |
|--------|----------|-------|
| `hamsci_dsp.ionosphere` | solar position and zenith angle (no dependencies); `ionosphere_state`, which uses IRI when installed and a parametric model otherwise | numpy; `iono` for IRI |
| `hamsci_dsp.ionosphere.ionex` | a reader for IGS Global Ionosphere Map (IONEX) files | numpy |
| `hamsci_dsp.ionosphere.space_weather` | near-real-time solar and geomagnetic indices; the caller supplies the download | stdlib |
| `hamsci_dsp.ionosphere.data_service` | WAM-IPE and GIRO ionosonde data, with a bundled GIRO station table | numpy; `requests`, `xarray` if present |
| `hamsci_dsp.ionosphere.tomography` | E- and F-layer TEC separated from many HF ray paths | `tomography` |
| `hamsci_dsp.raytrace` | `RaytraceEngine`, a wrapper for PyLAP and PHaRLAP that does nothing when they are absent | PyLAP, PHaRLAP (yours) |

**Timing and the sigmond suite's shared formats**

| Module | Provides | Needs |
|--------|----------|-------|
| `hamsci_dsp.timing` | `AuthorityReader` and `AuthoritySnapshot` for hf-timestd's `authority.json`; `acquire_anchor_utc`, the one RTP-to-UTC anchor every recorder shares; the timing-authority report clients publish | stdlib |
| `hamsci_dsp.timing_map` | `TimeMap`, the runtime form of the suite's measurement model (schema v2) | stdlib |
| `hamsci_dsp.counter_map` | `CounterMap`, which maps one channel's RTP counter to the radio's input-sample index | stdlib |
| `hamsci_dsp.t6_anchor` | reads hf-timestd's T6 anchor file and projects input-sample indices to UTC nanoseconds, with the tie's measured error | stdlib |
| `hamsci_dsp.stations` | a fixed catalogue of HF time-signal stations | stdlib |
| `hamsci_dsp.io` | the schema-driven SQLite writer and reader behind hf-timestd's data store | numpy |
| `hamsci_dsp.sigmondb_rows` | the sigmondb chirp row (`arrival` and `capture`) that codar-sounder writes | stdlib |
| `hamsci_dsp.data_product_registry` | the suite's data-product schemas (L1 to L3), bundled with the package | stdlib |

## Versions

Versions follow `MAJOR.MINOR.PATCH`. While the major number stays 0, a minor
release may change an interface; each sigmond release pins the exact version it
tested. The [commit history](https://github.com/HamSCI/hamsci-dsp/commits/main)
lists every change.

## Developing

```bash
git clone https://github.com/HamSCI/hamsci-dsp
cd hamsci-dsp
uv sync --extra dev
uv run pytest
```

A version tag (`vX.Y.Z`) publishes to PyPI through GitHub Actions, after the
tests pass against the built wheel. Notes for the suite's own programs, which
develop against a sibling checkout, sit in [docs/CONSUMERS.md](https://github.com/HamSCI/hamsci-dsp/blob/main/docs/CONSUMERS.md).

## Licence and authors

MIT. Michael Hauan (AC0G), for [HamSCI](https://hamsci.org/).
Source: https://github.com/HamSCI/hamsci-dsp
