The MNIST of Gas Sensing
AI Agent-Ready simulation engine + ML benchmark for optical gas sensing
HITRAN-grade physics. 9 tasks. 14 baselines. Full pipeline via natural language.
Documentation · Interactive Demo · Leaderboard · Dataset · Baselines
You don't need to be a spectroscopist. If you work on regression, denoising, domain generalization, or anomaly detection, SPEKTRAN gives you 9 ready-to-use benchmark tasks backed by real physics — with the same convenience as MNIST, but grounded in a domain where ML has direct industrial impact.
You don't even need to type code. SPEKTRAN is fully AI Agent-ready — tell Claude Code, Cursor, or any coding agent what you want, and it operates the entire pipeline through natural language. See AGENTS.md.
Highlights
Quick Start
Zero-install — load data from Hugging Face in one line:
from datasets import load_dataset
ds = load_dataset("spektran/spektran-ch4-v0")
Full engine — simulate spectra locally:
pip install spektran
from spektran.physics import simulate_absorbance
nu, absorbance = simulate_absorbance(
molecule="CH4", concentration_ppm=100.0,
temperature_K=296.0, pressure_atm=1.0,
path_length_m=10.0,
wavenumber_start_cm1=6046.0, wavenumber_end_cm1=6048.0,
)
More examples — WMS, multi-species, CLI
WMS 2f signal:
from spektran.physics.wms import WMSConfig, simulate_wms
See examples/wms_ch4.py for a complete WMS example.
Multi-species (CH4 + H2O interferent):
from spektran.physics import absorption_coefficient
from spektran.physics.hitran import demo_ch4_2nu3, demo_h2o
alpha_ch4 = absorption_coefficient(nu, demo_ch4_2nu3(), 100e-6, 296.0, 1.0)
alpha_h2o = absorption_coefficient(nu, demo_h2o(), 0.01, 296.0, 1.0)
See examples/multispecies_ch4_h2o.py.
CLI (all commands support --json for AI agents):
spektran info --json # Project discovery (agent bootstrap)
spektran list tasks --json # Available benchmark tasks
spektran train --baseline ridge --json # Train with auto data generation
spektran generate configs/datasets/ch4-t1-train-v0.yaml --out data --json
spektran benchmark --task T1-concentration --truth data/test.h5 --predictions preds.csv
AI Agent Ready
SPEKTRAN is designed from the ground up for the AI agent era. Every CLI command outputs structured JSON, every resource is discoverable, and the full ML pipeline — simulate → generate → train → evaluate — runs with zero manual steps.
Works with: Claude Code, Cursor, GitHub Copilot, Windsurf, Cline, and any agent that can run shell commands.
Agent interface: AGENTS.md — the agent reads this file and immediately
understands how to operate the entire project.
You: "Train the ridge baseline on T1 and show me the scores"
Agent: spektran train --baseline ridge --task T1 --json
→ {"baseline": "ridge", "scores": {"T1": {"mae_ppm": 2.84, "mape_pct": 29.87}}}
Agent workflow examples
Discovery — agent bootstraps itself:
spektran info --json # What is this project? What's available?
spektran list tasks --json # 9 tasks with metrics and available baselines
spektran list baselines --json # 14 baselines with pre-computed scores
spektran status --json # What data exists? What's been trained?
One-command training — agent trains any baseline:
spektran train --baseline ridge --json # Auto-generates data if missing
spektran train --baseline transformer --json # Works for any registered baseline
spektran train --baseline cnn1d --task T1 --json # Target a specific task
Compare all baselines — agent scripts a leaderboard run:
for baseline in ridge cnn1d transformer; do
spektran train --baseline $baseline --task T1 --json
done
Custom model — agent writes code, evaluates with CLI:
# Agent generates training code using spektran.io.read_records
# Agent writes predictions CSV
spektran benchmark --task T1-concentration \
--truth data/ch4-t1-test-v0.h5 \
--predictions my_model_predictions.csv
Benchmark Tasks
| Task | Domain | Primary Metric |
|---|---|---|
| T1 Concentration regression | DA spectrum → ppm | MAE |
| T2 Spectral denoising | Noisy → clean spectrum | RMSE |
| T3 Cross-instrument generalization | Held-out instruments | Degradation vs T1 |
| T4 WMS concentration | 2f signal → ppm | MAE |
| T5 Drift compensation | Time-series scans | Allan variance |
| T6 OOD instrument detection | In-dist vs OOD | AUROC |
| T7 Cross-modality transfer | TDLAS → NDIR | Degradation vs T1 |
| T8 Multi-species regression | CH4 + H2O → both ppm | Aggregate MAE |
| T9 Temperature regression | Spectrum → gas temp (K) | MAE |
Leaderboard
T1 Concentration + T3 Cross-Instrument (v0 splits, CH4 DA):
| Model | T1 MAE ↓ | T1 MAPE ↓ | T3 MAE ↓ | T3 Degradation |
|---|---|---|---|---|
| Ridge regression | 2.84 | 29.9% | 3.72 | 1.31x |
| Patchified Transformer | 7.39 | 22.7% | 10.81 | 1.46x |
| 1D CNN | 15.58 | 42.2% | 28.30 | 1.82x |
Model complexity correlates with instrument overfitting: Ridge 1.31x → Transformer 1.46x → CNN 1.82x. Can you build a model that breaks this pattern?
Results for other tasks
| Task | Best Model | Score |
|---|---|---|
| T2 Denoising | 1D U-Net | RMSE 3.62e-3 |
| T4 WMS | Ridge | MAE 15.15 ppm |
| T5 Drift | Moving average | MAE 0.270 ppm |
| T6 OOD | PCA + Mahalanobis | AUROC 0.672 |
| T7 Cross-modality | Ridge (TDLAS→NDIR) | MAE 130.68 ppm (46x) |
| T8 Multi-species | Ridge (dual) | CH4 0.89 / H2O 3937 ppm |
| T9 Temperature | Ridge | MAE 9.4 K |
Full leaderboard → · Submit results →
Real-World Impact
SPEKTRAN's benchmarks mirror problems that matter in industry and environmental science:
- Methane leak detection — oil & gas facilities, landfills, livestock operations (T1, T3)
- Industrial emissions monitoring — continuous stack gas analysis for SO2, NO, CO (T4, T8)
- Medical breath analysis — trace-gas biomarkers at ppb levels (T1, T9)
- Instrument-agnostic deployment — models that transfer across hardware without recalibration (T3, T7)
- Drift-resilient field sensors — long-term autonomous monitoring in harsh environments (T5)
How It Works
HITRAN line data Instrument configs Benchmark
─────────────── ────────────────── ─────────
Line positions ──► Virtual instruments ──► Official splits
Line strengths (noise, fringes, (train/val/test/
Broadening params drift, chirp) held-out)
│ │ │
▼ ▼ ▼
Forward physics ──► Noisy spectra ──► Evaluate & rank
(Voigt / HTP) with provenance on leaderboard
Physics You Can Trust
- Dual-implementation validation — independent reference implementations cross-checked against HITRAN/hapi
- Literature-anchored noise — instrument noise parameters surveyed from 18 published systems
- Sim-to-real gap report — known gap sources documented in G5 report
- Automated quality gates — G1–G5 checkpoints enforced in CI
Citing
@software{spektran,
title = {SPEKTRAN: Simulation Engine and ML Benchmark for Optical Gas Sensing},
url = {https://github.com/spektran/spektran},
doi = {10.5281/zenodo.21790394},
version = {0.5.1},
license = {Apache-2.0}
}
See CITATION.cff or use the DOI: 10.5281/zenodo.21790394.
Star History
Contributing
See CONTRIBUTING.md. We welcome new baselines, modalities, and line lists.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spektran-0.5.1.tar.gz.
File metadata
- Download URL: spektran-0.5.1.tar.gz
- Upload date:
- Size: 15.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a67702d4cee5bb16a842bd01cce91b39b74bed181feb7bf87e8ebe1b1e3ab741
|
|
| MD5 |
4249253cc03b5207dce59a77e8b2bebb
|
|
| BLAKE2b-256 |
e321995ed0cecdf73d149a7971f05445d5095848d0c559d483652df45d5d3ec3
|
Provenance
The following attestation bundles were made for spektran-0.5.1.tar.gz:
Publisher:
publish.yml on spektran/spektran
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spektran-0.5.1.tar.gz -
Subject digest:
a67702d4cee5bb16a842bd01cce91b39b74bed181feb7bf87e8ebe1b1e3ab741 - Sigstore transparency entry: 2420236631
- Sigstore integration time:
-
Permalink:
spektran/spektran@3efa6f07f6e68f96722751e4531f0c11590bf0c9 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/spektran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3efa6f07f6e68f96722751e4531f0c11590bf0c9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file spektran-0.5.1-py3-none-any.whl.
File metadata
- Download URL: spektran-0.5.1-py3-none-any.whl
- Upload date:
- Size: 83.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36e868f21e9ec1559bb34eb91bc7dfdc798efb1fee517a883ed10805db8a3c28
|
|
| MD5 |
24a1c0d8c864e172ff0031f1112cd3df
|
|
| BLAKE2b-256 |
c9019c9c5762e90cc3ce5660f1e0b2688ba016f8b69c2e2581c8d0b982a68e2f
|
Provenance
The following attestation bundles were made for spektran-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on spektran/spektran
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spektran-0.5.1-py3-none-any.whl -
Subject digest:
36e868f21e9ec1559bb34eb91bc7dfdc798efb1fee517a883ed10805db8a3c28 - Sigstore transparency entry: 2420237409
- Sigstore integration time:
-
Permalink:
spektran/spektran@3efa6f07f6e68f96722751e4531f0c11590bf0c9 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/spektran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3efa6f07f6e68f96722751e4531f0c11590bf0c9 -
Trigger Event:
release
-
Statement type: