Skip to main content

English | 中文

SPEKTRAN

The MNIST of Gas Sensing

AI Agent-Ready simulation engine + ML benchmark for optical gas sensing
HITRAN-grade physics. 9 tasks. 25 baselines. 5 modalities. Full pipeline via natural language.


Open In Colab GitHub Stars CI PyPI Python License License DOI AI Agent Ready

Documentation  ·  Interactive Demo  ·  Leaderboard  ·  Datasets  ·  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

Simulation Engine

  • 10 molecules — CH4, H2O, CO2, CO, NH3, NO, NO2, SO2, HCl, HF
  • 5 modalities — TDLAS (DA + WMS), NDIR, CRDS, FTIR, DOAS
  • Advanced line shapes — Voigt & Hartmann-Tran Profile
  • 14+ virtual instruments with realistic noise chains
  • WMS 1f–4f demodulation + 2f/1f calibration-free ratio

ML Benchmark

  • 9 tasks (T1–T9) — regression, denoising, OOD, transfer, multi-species
  • 25 baselines — Ridge, CNN, Transformer, U-Net, SpektralNet, RF, PINN, ...
  • Official splits — train / val / test / held-out instrument
  • AI Agent-ready CLI--json on every command, discoverable API
  • Public leaderboard on GitHub Pages

Quick Start

Zero-install — load data from Hugging Face in one line:

from datasets import load_dataset
ds = load_dataset("spektran/spektran-ch4-v0")       # CH4 benchmark
ds = load_dataset("spektran/spektran-co2-v0", "da") # CO2 benchmark
ds = load_dataset("spektran/spektran-industrial-v0", "so2")  # Industrial SO2
ds = load_dataset("spektran/spektran-multigas-v0", "ch4_co2_h2o")  # Multi-gas

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 # 25 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
SpektralNet 2.27 22.5% 3.51 1.54x
Ridge regression 2.84 29.9% 3.72 1.31x
Random Forest 5.27 24.1% 10.89 2.07x
PINN 7.29 49.1% 15.62 2.14x
Patchified Transformer 7.39 22.7% 10.81 1.46x
MLP (BPNN) 8.08 44.5% 9.85 1.22x
1D CNN 15.58 42.2% 28.30 1.82x
BiLSTM 29.47 61.7% 51.04 1.73x
CNN-LSTM-Attention 38.39 69.4% 71.03 1.85x

Key insight: linear models dominate on this benchmark because Beer-Lambert absorbance is linear in concentration. SpektralNet achieves SOTA by augmenting Ridge with physics-informed features, not by adding depth.

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
T1-CRDS Concentration Ridge (tau) MAE 36.5 ppm
T1-FTIR Concentration Ridge (spectrum) MAE 83.7 ppm
T1-DOAS Concentration Ridge (diff OD) MAE 1.40 ppm

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)
  • CO2 monitoring — greenhouse gas quantification, indoor air quality, process control (CO2 dataset)
  • Industrial emissions monitoring — SO2, NO, CO stack gas analysis (industrial dataset)
  • Multi-gas mixtures — disentangling overlapping species in combustion exhaust (multi-gas dataset)
  • 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.6.0},
  license   = {Apache-2.0}
}

See CITATION.cff or use the DOI: 10.5281/zenodo.21790394.

Star History

Star History Chart

Contributing

See CONTRIBUTING.md. We welcome new baselines, modalities, and line lists.

Code: Apache-2.0  ·  Data & Schema: CC BY 4.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spektran-0.6.0.tar.gz (15.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spektran-0.6.0-py3-none-any.whl (114.9 kB view details)

Uploaded Python 3

File details

Details for the file spektran-0.6.0.tar.gz.

File metadata

  • Download URL: spektran-0.6.0.tar.gz
  • Upload date:
  • Size: 15.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spektran-0.6.0.tar.gz
Algorithm Hash digest
SHA256 837713cdcfdf605bc67bbd5f322d7defaea69beb768b508d8efa6be3e85d479e
MD5 e4d4fb5ed360d1af2fc8fdf43271f3dc
BLAKE2b-256 bd7fffb177200a4560b2007d4638aed9ce4944af4258a91f9b2cea300e5cf143

See more details on using hashes here.

Provenance

The following attestation bundles were made for spektran-0.6.0.tar.gz:

Publisher: publish.yml on spektran/spektran

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spektran-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: spektran-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 114.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spektran-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b0b8b388cb7425f0d049a1f5193854a9a7af6006bcf24233b1849deb06b3eda
MD5 947676e498a068077a7731aaf32da2c0
BLAKE2b-256 45cc7168a45be3f8067a002b46bf4ffd09fab7b99cf82a5715b29325d9a7dbad

See more details on using hashes here.

Provenance

The following attestation bundles were made for spektran-0.6.0-py3-none-any.whl:

Publisher: publish.yml on spektran/spektran

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page