Metadata-Version: 2.4
Name: squitter
Version: 0.1.0
Summary: SQUITTER: ADS-B/C Link Outage, Fading, and Degradation from Ionospheric Irregularities Simulator. A physical forward model of ADS-B, ADS-C and GNSS channels through a controllable ionosphere, from irregularity strength to scintillation (S4) to message success.
Author-email: Shibaji Chakraborty <chakras4@erau.edu>
Maintainer-email: Shibaji Chakraborty <chakras4@erau.edu>
License-Expression: LGPL-3.0-or-later
Project-URL: Homepage, https://github.com/shibaji7/SQUITTER
Project-URL: Documentation, https://squitter.readthedocs.io/
Project-URL: Issues, https://github.com/shibaji7/SQUITTER/issues
Keywords: ADS-B,ADS-C,GNSS,ionosphere,scintillation,space weather,radio propagation,phase screen,link budget
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: COPYING
Requires-Dist: numpy
Requires-Dist: scipy
Provides-Extra: plots
Requires-Dist: matplotlib>=3.5; extra == "plots"
Requires-Dist: cycler; extra == "plots"
Requires-Dist: SciencePlots; extra == "plots"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-cov>=4; extra == "dev"
Requires-Dist: hypothesis>=6.100; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"
Requires-Dist: interrogate; extra == "dev"
Requires-Dist: vulture; extra == "dev"
Requires-Dist: deptry; extra == "dev"
Requires-Dist: pip-audit; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: docs
Requires-Dist: fonttools; extra == "docs"
Requires-Dist: sphinx>=7.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.3; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=1.24; extra == "docs"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Dynamic: license-file

<p align="center"><img src="docs/_static/logo-wordmark.svg" alt="SQUITTER" width="720"></p>

# SQUITTER

**ADS-B/C Link Outage, Fading, and Degradation from Ionospheric Irregularities Simulator.**

SQUITTER follows an ADS-B message (the *squitter*) through an irregular ionosphere and says whether it survives. It is a tested Python forward model of
ADS-B (1090ES; UAT planned), ADS-C and GNSS channels: 3D geometry, a ray-optics background (delay, Faraday rotation, deflection), wave-optics
scintillation (phase screens, Fresnel propagation, S4) and link metrics (Nakagami fading, bit and message errors).

[![tests](https://github.com/shibaji7/SQUITTER/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/shibaji7/SQUITTER/actions/workflows/tests.yml)
[![build](https://github.com/shibaji7/SQUITTER/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/shibaji7/SQUITTER/actions/workflows/build.yml)
[![docs](https://github.com/shibaji7/SQUITTER/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/shibaji7/SQUITTER/actions/workflows/docs.yml)
[![security](https://github.com/shibaji7/SQUITTER/actions/workflows/security.yml/badge.svg?branch=main)](https://github.com/shibaji7/SQUITTER/actions/workflows/security.yml)
[![License: LGPL v3+](https://img.shields.io/badge/license-LGPL--3.0--or--later-blue.svg)](LICENSE)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![mypy: strict](https://img.shields.io/badge/mypy-strict-blue.svg)](pyproject.toml)
[![docstrings: 100%](https://img.shields.io/badge/docstrings-100%25-brightgreen.svg)](pyproject.toml)
[![units in names](https://img.shields.io/badge/units-in%20names-informational.svg)](tests/test_units_naming.py)
[![parameters: provenance](https://img.shields.io/badge/parameters-with%20provenance-informational.svg)](src/squitter/config/defaults)
[![PyPI](https://img.shields.io/pypi/v/squitter.svg?label=pypi)](https://pypi.org/project/squitter/)
[![Python versions](https://img.shields.io/pypi/pyversions/squitter.svg?label=python)](https://pypi.org/project/squitter/)
[![codecov](https://codecov.io/gh/shibaji7/SQUITTER/branch/main/graph/badge.svg)](https://codecov.io/gh/shibaji7/SQUITTER)
[![Last commit](https://img.shields.io/github/last-commit/shibaji7/SQUITTER)](https://github.com/shibaji7/SQUITTER/commits/main)
[![Issues](https://img.shields.io/github/issues/shibaji7/SQUITTER)](https://github.com/shibaji7/SQUITTER/issues)
<!-- Still switched off (see docs/dev/release.md, section Badges): switch each on when the service behind it exists:
[![release](https://github.com/shibaji7/SQUITTER/actions/workflows/release.yml/badge.svg)](https://github.com/shibaji7/SQUITTER/actions/workflows/release.yml)
[![Stars](https://img.shields.io/github/stars/shibaji7/SQUITTER?style=social)](https://github.com/shibaji7/SQUITTER)
-->
[![Roadmap](https://img.shields.io/badge/roadmap-published-blue)](ROADMAP.md)
[![status](https://img.shields.io/badge/status-alpha%20v0.1-orange.svg)](ROADMAP.md)

**[📖 Documentation](https://squitter.readthedocs.io/) · [🐙 GitHub](https://github.com/shibaji7/SQUITTER) · [🐛 Issues](https://github.com/shibaji7/SQUITTER/issues) · [📜 Changelog](CHANGELOG.md) · [🗺️ Roadmap](ROADMAP.md) · [🤝 Contributing](CONTRIBUTING.md) · [👥 Contributors](#contributors) · [📎 Cite](CITATION.cff) · [🔒 Security](SECURITY.md)**

> Status: **v0.1 in progress (alpha)**. Constants, geometry, medium, irregularity strength, wave optics, the 1090 MHz link layer and the GNSS closed forms are
> implemented and tested, with a public API (`squitter.run_hop`), a CLI and a Sphinx site. ADS-C, UAT, protection levels and strong-scatter saturation are documented placeholders (`squitter.future`) that raise
> `NotImplementedYetError` until their sources are obtained (see the [roadmap](ROADMAP.md)). The irregularity strength, EIRP, gain, margin and reply rate have
> **no source** and ship as `TBD`: no claim about real detection probability is made.

![The model: geometry, irregularities, wave optics, link](docs/figures/chain_overview.png)

## What it does

```
positions -> pierce point, obliquity, Fresnel scale, IPP speed        (G, geometry)
density variance <dN^2>, L, p3, L0 -> phase std sigma_phi             (I, irregularity)
phase screen + Fresnel propagation -> intensity, S4                   (W, waveoptics)
S4 -> Nakagami m = 1/S4^2 -> fade probability, bit and message errors (L, link)
TEC -> group delay, Faraday rotation, deflection                      (A, medium; a side branch that does not change S4)
```

Every equation in the guide is typeset and tied to the function that implements it; every parameter carries a unit, a status (`sourced`, `assumed`, `unknown`, `override`) and a source.
Read the [guide](docs/guide/index.md) for the theory module by module, the [top-down derivation](docs/guide/topdown.md), [how the modules connect](docs/guide/connecting.md), the [limits](docs/guide/limits.md) and the [glossary](docs/guide/glossary.md); the [API reference](https://squitter.readthedocs.io/en/latest/api/index.html) is built from the docstrings.

## Install

```bash
git clone https://github.com/shibaji7/SQUITTER && cd SQUITTER
make env                  # conda env "squitter": python 3.12, numpy, scipy only
conda activate squitter
make dev                  # editable install with pytest, ruff, mypy, matplotlib, ...
make test
```

or `pip install .` in any Python >= 3.11 environment. Optional extras: `plots` (matplotlib, SciencePlots), `docs` (Sphinx), `dev` (all the quality tools).

## Quick start

```python
import numpy as np

from squitter import geometry, hop, irregularity
from squitter.config import load_parameters
from squitter.constants import R_E

params = load_parameters()  # shipped defaults: every value has a unit, a status and a source
shell_m = params.get("scenario", "shell_height_m") + R_E

# aircraft at 11 km, 30 N; satellite on a 780 km shell at 15 degrees elevation
lat = np.radians(30.0)
tx = (R_E + 11e3) * np.array([np.cos(lat), 0.0, np.sin(lat)])
_, north, up = geometry.enu_basis(tx)
look = np.cos(np.radians(15)) * north + np.sin(np.radians(15)) * up
rx, _, _ = geometry.pierce_point(tx, tx + 5e6 * look, R_E + 780e3)

# the irregularity strength has no source: you supply it (here 1e19 m^-6, an illustration)
sec_z = geometry.obliquity(tx, rx, shell_m)
k0 = 2 * np.pi / (params.get("irregularity", "outer_scale_km") * 1e3)
sigma = irregularity.sigma_phi_from_density(
    1e19, 0.275, params.get("irregularity", "thickness_km") * 1e3, sec_z, params.get("irregularity", "spectral_index_p3"), k0
)

settings = hop.HopSettings(
    shell_radius_m=shell_m, f_Hz=params.get("link", "frequency_Hz"), sigma_phi_rad=sigma, p=2.0,
    k0_rad_per_m=k0, eirp_dBW=27.0, rx_gain_dBi=3.0, margin_dB=6.0,   # placeholders: no source for these
)  # fmt: skip
v = np.array([250.0, 0.0, 0.0])
result = hop.space_hop_1090(tx, rx, v, np.zeros(3), settings, np.random.default_rng(0))
print(f"S4 = {result.s4:.3f}, P(fade) = {result.fade_probability:.2e}")
```

From the shell: `squitter params --status unknown` lists what you still have to supply; `squitter run --delta-n2 1e19 --set link.eirp_dBW=27 --set link.rx_gain_dBi=3 --set link.margin_dB=6` runs the same hop;
`squitter doctor` checks the installation. Docs: `make docs` (Sphinx), or read [docs/index.md](docs/index.md).

Unknown parameters raise instead of guessing: `params.get("link", "eirp_dBW")` fails with the reason until you supply a value, in code or in a TOML file
(`load_parameters("my.toml", overrides={"irregularity.thickness_km": 50})`).

## Honest by design

Every parameter is `value, unit, status, source` with status **sourced**, **assumed**, **unknown** or **override**. An `unknown` value (`TBD`) raises
`MissingParameterError` instead of being guessed: the irregularity strength, the ROTI calibration, EIRP, receiver gain, margin, reply rate and the ADS-C timers have no source.
A disagreement between code, derivation and a reference value is never silenced: it is logged in [DISCREPANCIES.md](DISCREPANCIES.md) and kept as a strict expected-failure test until the author decides. See
[docs/guide/limits.md](docs/guide/limits.md) for what the model does not do.

## Layout

| Path | What |
|---|---|
| [`src/squitter/geometry/`](src/squitter/geometry), [`medium/`](src/squitter/medium) | pierce point, obliquity, Fresnel scale, IPP speed; delay, Faraday rotation, deflection, Appleton-Hartree |
| [`irregularity/`](src/squitter/irregularity), [`screen/`](src/squitter/screen) | `<dN^2>` to `sigma_phi`; von Karman phase screens |
| [`waveoptics/`](src/squitter/waveoptics), [`link/`](src/squitter/link), [`gnss/`](src/squitter/gnss) | Fresnel propagation and S4; fading, bit and message errors; GNSS closed forms |
| [`hop/`](src/squitter/hop), [`api.py`](src/squitter/api.py), [`cli.py`](src/squitter/cli.py), [`result.py`](src/squitter/result.py), [`registry.py`](src/squitter/registry.py) | the end-to-end hop, the public API, the command line, results, plug-in spectra |
| [`config/`](src/squitter/config) | TOML parameters with provenance ([defaults](src/squitter/config/defaults)) |
| [`future/`](src/squitter/future) | placeholders that raise `NotImplementedYetError` (ADS-C, UAT, protection levels, saturation) |
| [`plotting/`](src/squitter/plotting) | the shared figure style |
| [`tests/`](tests) | analytic oracles, golden simulations, characterization of every public function |
| [`docs/`](docs) | Sphinx site: [guide](docs/guide/index.md), [figures](docs/figures), [usage](docs/usage.md) |
| [`examples/`](examples), [`functions/`](functions), [`scripts/`](scripts) | scripts that print or plot checkable numbers; demos; tooling |

## Develop

`make help` lists everything. `make qa` runs ruff, format check, mypy (strict), docstring coverage, dead code, dependencies, duplicate code, SPDX headers and the tests.
Tests are grouped by module with markers: `make gate-W` runs one group, `make gates` runs all. Rules: [CONTRIBUTING.md](CONTRIBUTING.md). Disagreements are logged in
[DISCREPANCIES.md](DISCREPANCIES.md); the limits of the model are in [docs/guide/limits.md](docs/guide/limits.md).

## Contributors

SQUITTER is written and maintained by [Shibaji Chakraborty](https://github.com/shibaji7), with [Claude](https://www.anthropic.com/claude) (Anthropic) as AI pair programmer; see [AUTHORS.md](AUTHORS.md). Contributions are welcome:
read [CONTRIBUTING.md](CONTRIBUTING.md) and the [code of conduct](CODE_OF_CONDUCT.md), and open an [issue](https://github.com/shibaji7/SQUITTER/issues) before changing
the public API or the meaning of a parameter.

[![Contributors](https://contrib.rocks/image?repo=shibaji7/SQUITTER)](https://github.com/shibaji7/SQUITTER/graphs/contributors)

## Related projects

Same author: [SCUBAS](https://github.com/shibaji7/SCUBAS) (submarine cables upset by auroral streams),
[GeoPulse](https://github.com/shibaji7/geopulse) (geomagnetically induced currents across grounded infrastructure) and [pynasonde](https://github.com/shibaji7/pynasonde) (ionosonde analysis).

## Cite

See [CITATION.cff](CITATION.cff). License: LGPL-3.0-or-later ([LICENSE](LICENSE), [COPYING](COPYING)).
