Metadata-Version: 2.5
Name: fathom-acoustics
Version: 1.2.0
Summary: Acoustic Workbench: sonar waveform generation, channel models, signal analysis and streaming.
Project-URL: Source, https://github.com/loganrf/fathom
Project-URL: Changelog, https://github.com/loganrf/fathom/blob/main/CHANGELOG.md
Author: SIGE
License-Expression: MIT
License-File: LICENSE
Keywords: acoustics,dsp,mcp,sigmf,signal processing,sonar,underwater
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: h5netcdf>=1.3
Requires-Dist: h5py>=3.10
Requires-Dist: matplotlib>=3.8
Requires-Dist: nptdms>=1.9
Requires-Dist: numpy>=1.26
Requires-Dist: pyyaml>=6.0
Requires-Dist: scipy>=1.11
Requires-Dist: soundfile>=0.12
Requires-Dist: xarray>=2024.6
Requires-Dist: zarr>=3.0
Provides-Extra: all
Requires-Dist: anywidget>=0.9; extra == 'all'
Requires-Dist: ipython>=8.20; extra == 'all'
Requires-Dist: jupyterlab>=4.2; extra == 'all'
Requires-Dist: mcp<3,>=2.3; extra == 'all'
Requires-Dist: pyqtgraph>=0.13.7; extra == 'all'
Requires-Dist: pyside6-essentials>=6.7; extra == 'all'
Requires-Dist: pyzmq>=26; extra == 'all'
Requires-Dist: sounddevice>=0.4.7; extra == 'all'
Provides-Extra: gui
Requires-Dist: pyqtgraph>=0.13.7; extra == 'gui'
Requires-Dist: pyside6-essentials>=6.7; extra == 'gui'
Provides-Extra: hw
Requires-Dist: pyzmq>=26; extra == 'hw'
Requires-Dist: sounddevice>=0.4.7; extra == 'hw'
Provides-Extra: jupyter
Requires-Dist: anywidget>=0.9; extra == 'jupyter'
Requires-Dist: ipython>=8.20; extra == 'jupyter'
Requires-Dist: jupyterlab>=4.2; extra == 'jupyter'
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2.3; extra == 'mcp'
Description-Content-Type: text/markdown

# fathom

fathom is the SDK of the **Acoustic Workbench**, a Python application and library for sonar signal work. It generates waveforms, analyzes signals in the time and frequency domains, and reads and writes signal files. The first user is a software-defined sonar prototype on a Red Pitaya STEMlab 125-14 (two channels). The data model accepts N channels.

This is **v1.0**: roadmap phases M0 · Core and CLI, M1 · Channel models and Jupyter, M2 · MCP server, M4 · Signal Studio, M5 · Channel Studio and M6 · Release v1.0. Phase M3 (streaming transports and hardware) comes in v1.1 (see [docs/roadmap.md](docs/roadmap.md)). From v1.0, the public API follows semantic versioning.

## Install

The desktop installers for macOS arm64 and Linux x64 are on the GitHub Releases page. Each holds Python, the studios, JupyterLab and all extras, with menu shortcuts and a Jupyter kernel. On Windows, use `pip`. See [docs/install.md](docs/install.md).

```bash
pip install fathom-acoustics            # core and CLI
pip install "fathom-acoustics[jupyter]" # plus the Jupyter extension and widgets
pip install "fathom-acoustics[mcp]"     # plus the MCP server
pip install "fathom-acoustics[gui]"     # plus Signal Studio and Channel Studio
pip install "fathom-acoustics[all]"     # every extra
```

For development:

```bash
uv sync --group dev
uv run pytest
uv run pytest -m gate tests/test_gui_gate.py -s   # the M4 performance gate
```

The GUI tests run headless with the Qt offscreen platform. On Linux, Qt needs some system libraries, for example `sudo apt-get install libegl1 libxkbcommon0 libfontconfig1 libdbus-1-3` on Ubuntu.

Python 3.12 or later is necessary.

## Use

```bash
fathom gen lfm --f0 8k --f1 12k --dur 10ms --fs 500k -o ping.wav
fathom analyze psd ping.wav --nfft 4096 --plot psd.png --json
fathom convert capture.tdms capture.sigmf-meta
fathom gen hfm --f0 8k --f1 12k --dur 20ms --fs 200k -o - | fathom analyze ambiguity - --plot amb.png
fathom model run examples/models/harbor_multipath.yaml --in ping_lfm=ping.wav -o rx.sigmf-meta
fathom model sweep examples/models/harbor_multipath.yaml --in ping.wav --param drive.gain_db=-27:4:-15 --trials 100 -o roc.nc
fathom serve --project ./tank_tests
fathom mcp --project ./tank_tests   # MCP server on stdio, for a language model client
fathom studio --project ./tank_tests  # Signal Studio on the same workspace
fathom model edit examples/models/harbor_multipath.yaml --project ./tank_tests  # Channel Studio
```

```python
import fathom.signals as gen
from fathom import analysis, io

ping = gen.lfm(8e3, 12e3, 10e-3, 500e3, taper="tukey", amplitude=100.0, units="Pa")
print(analysis.measure(ping).to_dict())
io.write(ping, "ping.sigmf-meta")
```

```python
from fathom.models import ChannelModel

model = ChannelModel.load("examples/models/harbor_multipath.yaml")
rx = model.run(ping)  # batch
rx2 = model.run(ping, mode="stream", frame_size=1024)  # stream: same output
ds = model.sweep({"drive.gain_db": [-27, -23, -19]}, ping, trials=100)  # xarray.Dataset
```

```python
%load_ext fathom
%fathom attach ./tank_tests     # workspace objects become notebook variables
```

## What M6 adds

| Area | Content |
| --- | --- |
| Installers | Conda-based installers built with constructor: macOS arm64 `.pkg` (Developer ID, notarized) and Linux x64 `.sh` (PKG-006, PKG-007). Python 3.13, fathom, JupyterLab and all extras; shortcuts for both studios and JupyterLab; a `fathom` kernel |
| Conda package | `installer/recipe` (rattler-build) installs the wheel of `uv build` |
| Release | The installers workflow smoke-tests each installer on a clean runner (PKG-008); PyPI waits for it; the GitHub Release holds the installers, checksums, SBOM and the docs site (PKG-009); a final release publishes the docs to GitHub Pages |
| Versioning | The public API follows semantic versioning; `tests/public_api.json` and `tests/test_architecture.py` stop a breaking change (SDK-003) |
| Docs | Install, Channel Studio, Releases and versioning, Changelog, and a generated Requirement verification page; the block catalog and the API reference |

## What M5 adds

| Area | Content |
| --- | --- |
| Channel Studio | `fathom model edit` and `fathom.gui.run_channel_studio`: a node editor for channel models. Add, connect, bypass, rename and delete blocks; probe any edge; undo and redo (CHN-001, CHN-003, CHN-004) |
| Edge validation | Each rate, representation and channel-count error shows on the edge that causes it, and each edge shows its stream (CHN-005) |
| Runs | Batch, stream and sweep runs; outputs and probes go to the workspace and to the views of Signal Studio (CHN-003, CHN-006, CHN-010) |
| Session | Each action and each undo is a public SDK call; the script repeats the session (CORE-002) |
| File | The canvas saves to the YAML model file; the `layout` key holds the positions and the probe marks (CHN-002) |
| SDK | `ChannelModel.inspect`, `ModelReport`, `Connection`, `place`, `rename`, `move`, `mark_probe`, `probe_marks`, `auto_layout`, `set_medium`; `fathom.models.sweep_values`; `fathom.analysis.frame_psd`; `fathom.theme.node_palette` |
| Gate | `tests/test_requirements.py`: every P1 requirement of the spec has a test, except the STR requirements of M3 (98 of 98) |

## What M4 adds

| Area | Content |
| --- | --- |
| Signal Studio | `fathom studio` and `fathom.gui.run_studio`: a PySide6 and pyqtgraph desktop window on the workspace of a project. It connects to the workspace service, or starts one, and shows a `ws.put()` from a notebook in less than 1 s (JUP-005) |
| Generators | Every P1 family from a parameter form that comes from the SDK schemas (SIG-001); SI input; the common options of SIG-002; bits, symbols and a custom constellation for the modulator (SIG-009); a live preview strip |
| Views | Time (waveform, envelope, instantaneous phase and frequency), spectrum (FFT, Welch PSD in dB re 1 µPa²/Hz or dBFS/Hz, SIG-005), spectrogram, correlation (PSL, ISL, matched filter), ambiguity (wideband, narrowband for comparison, SIG-006), constellation and eye, live scroll mode (SIG-011); two or more signals in each view (SIG-008); time and frequency cursors with deltas (SIG-010) |
| Measurements | Every SIG-007 metric for the current signal or the selected time span |
| Session | Each action records its SDK call; *Copy session as Python* gives a script that repeats the session (CORE-002) |
| Gate | SIG-003: previews update in less than 200 ms at 10⁶ samples. SIG-004: a 10⁸-sample record pans and zooms with no visible lag (min/max pyramids). `tests/test_gui_gate.py` runs on three operating systems |
| SDK | `fathom.schema` (function schemas and catalogs, shared by the MCP tools and the forms); `fathom.plotting.MinMaxPyramid`; `fathom.stream.replay` and `RingBuffer`; `fathom.analysis.StreamingSpectrogram`; `spectrogram(max_frames=...)`; faster `multitone`, `schroeder_multisine` and `modulate` |
| Theme | `fathom.theme.qt_stylesheet`, `qt_palette_roles`, `plot_palette`, `colormap_lut` and `series_styles`: the studio styles from the same tokens (UI-002) |
| Docs | [Signal Studio](docs/studio.md) page and API reference |

## What M2 adds

| Area | Content |
| --- | --- |
| MCP server | `fathom mcp` on stdio (MCP-001) and streamable HTTP with a bearer token (MCP-009); `fathom.mcp.FathomMCP` in Python |
| Tools | `list_workspace`, `describe_signal`, `generate_waveform`, `import_file`, `export_file`, `edit_channel_model`, `run_channel_model`, `run_sweep`, `analyze`, `compare_signals`, `job_status`; `start_stream` and `stop_stream` only with `--allow-hardware` (MCP-006) |
| Schemas | Generated from the SDK type hints and docstrings (MCP-008): every generator, analysis function and file reader and writer |
| Resources | Block catalog with parameter schemas (MCP-004), generator, analysis and format schemas, the model format, and each workspace object |
| Data rule | Names, metadata, numeric summaries and PNG plots, never sample arrays (MCP-002, MCP-003) |
| Safety | Paths stay in the project (MCP-005); no code-running blocks; calls longer than 10 s become background jobs (MCP-007) |
| SDK | `fathom.analysis.compare`, `fathom.plotting.plot_sweep`, `progress` callbacks for model runs, `fathom.models.named_metric`; sweeps no longer write a sink revision per run |
| Docs | [MCP server](docs/mcp.md) page and a generated tool reference |

## What M1 adds

| Area | Content |
| --- | --- |
| Channel models | `ChannelModel`: a DAG of blocks with typed ports; YAML files with a schema version and migrations; checks of rate, representation and channel count on each edge; bypass and probes; model hash in each output's provenance |
| Engine | Batch and stream modes through one block interface (outputs agree to 10⁻⁹); latency compensation and tails; counter-based random numbers, so random output does not change with the frame size; sweeps with seeded trials to an `xarray.Dataset` |
| Block library | All P1 blocks: sources and sinks, probe; gain and loss curves; spreading; Thorp, Francois-Garrison and Ainslie-McColm absorption; integer, fractional and time-varying delay; Doppler time scale; tapped delay line and image method; surface and Rayleigh bottom reflection; measured impulse response; AWGN, colored and Wenz noise; TVR and OCV transducers; clipping and polynomial distortion; amplifier, ADC, DAC, clock offset, jitter; sum, split, mux, demux, resample, filter, custom Python blocks |
| Workspace | Project directory (YAML plus Zarr arrays, read memory-mapped); workspace service on localhost with a token; clients with change events; `fathom serve` |
| Jupyter | `%load_ext fathom`, `%fathom attach/push/pull`; workspace objects as variables; HTML summaries; interactive time, PSD and spectrogram views for JupyterLab and VS Code; `fathom lab` |
| CLI | `fathom model run`, `sweep`, `check`, `blocks`; `fathom serve`; `fathom lab` |
| Examples | Five notebooks that run in CI from recorded data, on three operating systems |

## What M0 contains

| Area | Content |
| --- | --- |
| Data model | `Signal`: channel-major samples, fs, timeline, passband/baseband, units, per-channel calibration (counts → V → Pa), geometry, medium (water or air), annotations, provenance; lossless xarray conversion; memory-mapped large records |
| Generators | All P1 families: CW and gated CW, pulse trains with stagger, multi-tone, Schroeder multisine; LFM, HFM, exponential sweep; Barker, MLS; impulse, Gaussian pulse, Ricker, sinc; white, pink, red, band-limited and PSD-shaped noise; OOK, BPSK, QPSK, M-PSK, FSK, MFSK with RRC shaping; AM, FM, PM; NumPy expressions; file import |
| Analysis | Spectrum, Welch PSD, spectrogram; envelope, instantaneous phase and frequency; matched filter, autocorrelation, PSL and ISL; wideband and narrowband ambiguity; CFAR; GCC-PHAT; delay-and-sum beamforming; H1, H2, coherence; the full measurement set |
| File I/O | SigMF (with a `fathom:` extension namespace), WAV/RF64, FLAC, AIFF, TDMS, HDF5, NetCDF4, Zarr, MAT v5 and v7.3, npy/npz, raw binary, CSV; PNG/SVG/PDF plots |
| Streams | Framed stream protocol (FSP) v1: Python reference parser and C header |
| CLI | `gen`, `analyze`, `convert`, `info`, `plot`, `formats`; `--json`; SI suffixes; `-` for stdin and stdout; exit codes 0/1/2 |
| Visual design | SIGE dark theme tokens in one module; matplotlib style; perceptually uniform colormap; Paper print variant |
| CI and release | Ruff, mypy strict, tests on 3 OSes × 3 Python versions, coverage ≥ 85 %, docs build, benchmarks against the last release; tag-driven release with trusted publishing |

## Documentation

Build the docs with `uv run mkdocs serve`. The pages are in [docs/](docs/). The software spec, with the requirement IDs that the code and tests cite, is in [docs/spec.md](docs/spec.md).

## License

MIT. See [LICENSE](LICENSE).
