Skip to content

Using it from the command line

The spectro command is the no-AI-agent door: everything the catalogue offers, reachable from a terminal - for exploration, scripting and CI. It needs no Python code.

Commands at a glance

Command What it does
spectro info Catalogue summary (counts, version).
spectro list List algorithms, optionally by --category.
spectro categories List the non-empty categories.
spectro describe <name> Full details of one algorithm.
spectro source <name> Print the wrapper's source code (or just the GitHub link with --url-only) - for auditing.
spectro presets List the bundled pipeline presets.
spectro run <algorithm> Run a single algorithm.
spectro pipeline <preset> Run a whole preset pipeline.

Add --json to any command for machine-readable output (handy in scripts and CI).

Discovering the catalogue

spectro info
spectro list --category line_fitting
spectro describe fit_gaussian_line
spectro source fit_gaussian_line --url-only   # GitHub permalink
spectro source fit_gaussian_line               # full wrapper source

describe shows the parameters, the required ones, the context inputs/outputs, the backend and the literature references:

fit_gaussian_line  v1.1.0  [line_fitting]

  Fit a single Gaussian (plus a linear continuum) to one spectral line.

  Backend: scipy
  References:
    - scipy.optimize.curve_fit - Levenberg-Marquardt / Trust Region Reflective

  Parameters:
    line_center_angstrom = None (required)
        Approximate line centre in Å (required).
    window_angstrom = 20.0
        Half-width of the fit window on each side of the line (Å).
    ...

Running one algorithm

# Load a spectrum and run an algorithm on it:
spectro run snr_der --input obs.fits

# Pass parameters with -p key=value (repeatable); values are auto-typed:
spectro run normalize_polynomial -i obs.fits -p order=3 -p sigma_clip=3.0

# Save the resulting spectrum (format chosen by extension):
spectro run normalize_polynomial -i obs.fits -o normalised.fits

The --input file is read into the context before the algorithm runs (FITS, ASCII or VOTable, by extension or URL). The exit code is 0 on success, non-zero on failure - so spectro run composes cleanly in shell scripts.

Running a preset pipeline

spectro presets
spectro pipeline balmer_quick --input obs.fits
spectro pipeline snr_check --input obs.fits --json

You can also point pipeline at a YAML file directly:

spectro pipeline ./my_recipe.yaml --input obs.fits

Scripting example

#!/usr/bin/env bash
# Batch SNR check over a directory of spectra.
for f in data/*.fits; do
  snr=$(spectro run snr_der --input "$f" --json | python -c \
        'import sys,json; print(json.load(sys.stdin)["context"]["metrics"]["snr_der"])')
  printf '%-30s SNR = %.0f\n' "$f" "$snr"
done

Same catalogue, every door

Whatever you do here, an AI agent can do through the MCP server, and your Python code can do through the library. The three are guaranteed to stay in sync because they are all thin layers over the same registry.