Getting started¶
This page takes you from nothing to a working spectral analysis in a few minutes.
1. Install¶
spectro-kernel needs Python 3.11+. The recommended tool is
uv, but plain pip works too.
Optional extras¶
The core install is deliberately light (astropy, numpy, scipy, pyyaml). Add what you need:
| Extra | Brings | Unlocks |
|---|---|---|
catalogs |
astroquery, pyvo | simbad_query |
viz |
plotly | plot_spectrum_plotly, plot_overlay_plotly |
mcp |
fastmcp | the spectro-mcp server |
storage |
boto3 | S3 / DO Spaces object storage |
An algorithm whose extra is missing simply does not register - the rest of the catalogue still loads.
2. Check it works¶
3. Your first analysis - the library¶
import numpy as np
from spectro_kernel import WorkContext, run_algorithm
from spectro_kernel.types import Spectrum1D
# A synthetic spectrum: flat continuum + one emission line + noise.
wave = np.linspace(6400, 6700, 1500)
flux = 100 + 40 * np.exp(-0.5 * ((wave - 6562.8) / 3.4) ** 2)
flux += np.random.default_rng(0).normal(0, 1, wave.size)
ctx = WorkContext(spectrum=Spectrum1D(wave, flux)) # (1)!
run_algorithm("normalize_polynomial", ctx, {"order": 3}) # (2)!
run_algorithm("snr_der", ctx)
run_algorithm("fit_gaussian_line", ctx, {"line_center_angstrom": 6562.8})
print(f"SNR = {ctx.metrics['snr_der']:.0f}")
print(f"H-alpha FWHM = {ctx.line_fits['6562.8'].fwhm_angstrom:.2f} Å")
- A
WorkContextis the bag of data that flows through your analysis. You put a spectrum in; algorithms read from it and write results back into it. run_algorithmlooks the algorithm up in the registry, runs it against the context, and records a step inctx.history.
4. The same thing - the command line¶
No AI agent, no Python script needed:
spectro list --category line_fitting # discover algorithms
spectro describe fit_gaussian_line # see its parameters and references
spectro run snr_der --input obs.fits # run one algorithm
spectro pipeline balmer_quick --input obs.fits # run a whole preset
5. The same thing - for an AI agent¶
Point Claude Desktop at it (~/Library/Application Support/Claude/claude_desktop_config.json):
The agent now sees every algorithm as a tool. See As an MCP server.
Where next¶
- Just captured a spectrum of a star? → Tutorial: your first spectrum - the gentlest possible start.
- Not sure what is available? → Discover the catalogue.
- Understand the moving parts → Concepts: architecture.
- A guided, end-to-end analysis → Tutorial: analyse a spectrum.
- Browse everything available → Algorithm catalogue.