Skip to main content

A shared catalogue of astronomical spectroscopy algorithms, composable into reproducible pipelines, usable as a Python library, a CLI, or an MCP server.

Project description

spectro-kernel

A shared catalogue of astronomical spectroscopy algorithms — composable into reproducible pipelines, usable as a Python library, a CLI, or an MCP server.

spectro-kernel is the common foundation for every spectroscopy application: FITS reading/writing, continuum normalisation, SNR, line detection and fitting, smoothing, resampling, barycentric correction, periodograms, exports — implemented once, tested once, and reused everywhere instead of being re-coded (subtly differently) in each project.

It is designed to be the substrate of any future spectroscopy app — a stellar reduction pipeline, a visualisation dashboard, a campaign-collection backend — and it works with or without an AI agent:

  • Without an agentimport spectro_kernel in any Python project, or use the spectro command-line tool.
  • With an agent — run the MCP server (spectro_mcp); Claude and other agents see the same catalogue as discoverable tools. Functional parity between the two access paths is an invariant.

Install

pip install spectro-kernel              # core library + CLI
pip install spectro-kernel[catalogs]    # + SIMBAD / VizieR queries
pip install spectro-kernel[mcp]         # + MCP server
pip install spectro-kernel[all]         # everything

From source (recommended for development):

uv venv --python 3.12
uv pip install -e ".[dev,mcp]"

Quickstart — library

from spectro_kernel import WorkContext, run_algorithm
from spectro_kernel.io import read_fits

ctx = WorkContext(spectrum=read_fits("obs.fits"))
run_algorithm("normalize_polynomial", ctx, {"order": 3})
run_algorithm("snr_der", ctx)
print(ctx.metrics["snr_der"])

Or compose a pipeline:

from spectro_kernel import PipelineBuilder

pipeline = (
    PipelineBuilder()
    .add("normalize_polynomial", order=3)
    .add("snr_der")
    .add("fit_gaussian_line", line_center_angstrom=6562.8, window_angstrom=30)
    .build()
)
result = pipeline.execute(ctx)

Quickstart — CLI (no AI agent needed)

spectro list                              # discover the catalogue
spectro describe fit_gaussian_line        # see params, inputs, outputs
spectro run snr_der --input obs.fits      # run one algorithm
spectro pipeline balmer_quick --input obs.fits   # run a preset pipeline

Quickstart — MCP server (for AI agents)

Local-first. After pip install "spectro-kernel[mcp]", point Claude Desktop at the binary — no server to run, no URL, no API key:

// ~/Library/Application Support/Claude/claude_desktop_config.json   (macOS)
{
  "mcpServers": {
    "spectro": { "command": "spectro-mcp" }
  }
}

Restart Claude Desktop — every catalogue algorithm appears as a tool, plus the transverse ones (list_algorithms, describe_algorithm, get_algorithm_source, run_preset, …).

Cloud option. For claude.ai (web), shared access, or non-Python users: deploy the same spectro-mcp in HTTP mode on any container host (DigitalOcean App Platform, Fly.io, etc.). Local-stdio remains the recommended default.

Architecture

spectro_kernel/        importable Python package — the catalogue
  types/               Spectrum1D, WorkContext, ProcessingStep, ...
  registry.py          @register_algorithm + discovery API
  base.py              BaseAlgorithm + AlgorithmOutput
  pipeline.py          Pipeline + PipelineBuilder
  io/                  FITS / ASCII readers and writers
  algorithms/          the catalogue, one file per algorithm
  presets/             YAML pipeline recipes
  cli.py               the `spectro` command

spectro_mcp/           MCP server wrapping the same catalogue

Add an algorithm = one Python file + one test. No change to the core. See CONTRIBUTING.md.

Documentation

The full documentation site (built with MkDocs Material) lives in docs/ and covers: Why spectro-kernel? (what it adds on top of astropy/specutils), the concepts with diagrams, a guide per access path, tutorials, and an algorithm catalogue generated from the registry. Build it locally with:

uv pip install -e ".[docs,all]"
mkdocs serve     # live preview at http://127.0.0.1:8000

Every algorithm declares its provenance — a backend (the library it leans on) and literature references — visible in spectro describe <name> and in the docs.

Repository layout

Two things in this repo are documentation-facing; do not confuse them:

Path What it is Tracked?
src/spectro_kernel/, src/spectro_mcp/ The Python packages — the actual product. yes
tests/ The test suite. yes
docs/ The documentation — MkDocs Material source (Markdown). The technical site: concepts, guides, tutorials, API reference. yes
website/ The public landing page — a standalone React + Vite app, deployable to Netlify. Separate from docs/; see website/README.md. yes
site/, website/dist/, website/node_modules/ Generated build output / dependencies. Build cruft — git-ignored, never edited by hand. no

In short: edit docs/ for documentation, edit website/ for the landing page, ignore site/.

Status

v0.1.0 — alpha. API unstable until v1.0.0. See CHANGELOG.md for release notes.

License

MIT — see LICENSE.

Project details


Download files

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

Source Distribution

spectro_kernel-0.1.4.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

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

spectro_kernel-0.1.4-py3-none-any.whl (227.0 kB view details)

Uploaded Python 3

File details

Details for the file spectro_kernel-0.1.4.tar.gz.

File metadata

  • Download URL: spectro_kernel-0.1.4.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spectro_kernel-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4fabcd33869334ae44cac1a47a46d18b877bf2c8247984c6d0f0c4f4f674eab6
MD5 066a9d141f62e45a4edc76c22eac6be9
BLAKE2b-256 3e6548c79767283e5f7fbbcd15655e5c0ec69ffd8e2c03c11d4f83e469981bc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for spectro_kernel-0.1.4.tar.gz:

Publisher: release.yml on matthieulel/spectro-kernel

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

File details

Details for the file spectro_kernel-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: spectro_kernel-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 227.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spectro_kernel-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ff3e563bcc02218e55814f7b1a204e3d714e1aed4b3c982a11d69a5a64888edb
MD5 f242b3e2a8c1d280eddfc37f9c7f1f15
BLAKE2b-256 4020b349d16c09a9b11ad1b4dd6dd1a64d7594d74f32ddadada8918ee64978a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for spectro_kernel-0.1.4-py3-none-any.whl:

Publisher: release.yml on matthieulel/spectro-kernel

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 Pingdom Monitoring Sentry Error logging StatusPage Status page