Skip to content

detect_lines

Detect emission/absorption peaks, optionally matched to a named catalogue.

Category Line detection
Backend scipy - implemented here on top of scipy primitives
Version 1.2.1
Reads ctx.spectrum (a Spectrum1D)
Writes extras.detected_lines, metrics.n_lines_detected, metrics.n_lines_matched, metrics.n_emission, metrics.n_absorption, metrics.noise_level, metrics.continuum_window, metrics.wavelength_range_lo, metrics.wavelength_range_hi

Blind mode (catalog=None) returns continuum, signed amplitude, SNR (|amp| / noise), FWHM (from scipy.signal.peak_widths at half-maximum), and the MAD-robust noise level used for the threshold. Catalogue mode preserves the v1.1.0 behaviour: each detection is labelled with the nearest catalogue line within tolerance_angstrom.

Parameters

Parameter Default Required Description
catalog 'balmer' - Reference catalogue: 'balmer', 'telluric', 'nebular', 'aurorae', or None for blind mode (no identification).
kind 'both' - Which features to look for: emission, absorption or both.
prominence_sigma 5.0 - Peak prominence threshold, in units of the noise level.
tolerance_angstrom 5.0 - Maximum detection-to-catalogue separation for a match (Å).
continuum_window 101 - Median-filter window (samples, odd ≥ 3) used to estimate the continuum before MAD noise computation in blind mode.
min_separation_angstrom 2.0 - Minimum spacing between detections (Å). Forwarded to find_peaks(distance=…) in blind mode.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("detect_lines", ctx, {
    "catalog": "balmer",
    "kind": "both",
    "prominence_sigma": 5.0,
    "tolerance_angstrom": 5.0,
    "continuum_window": 101,
    "min_separation_angstrom": 2.0
})
spectro run detect_lines --input spectrum.fits \
  --param catalog=balmer \
  --param kind=both \
  --param prominence_sigma=5.0 \
  --param tolerance_angstrom=5.0 \
  --param continuum_window=101 \
  --param min_separation_angstrom=2.0
{
  "tool": "detect_lines",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "catalog": "balmer",
      "kind": "both",
      "prominence_sigma": 5.0,
      "tolerance_angstrom": 5.0,
      "continuum_window": 101,
      "min_separation_angstrom": 2.0
    }
  }
}

Every algorithm is an MCP tool of the same name; describe_algorithm returns this page's metadata as JSON.

References

  • scipy.signal.find_peaks — prominence-thresholded peak detection.
  • Press, Teukolsky, Vetterling & Flannery 2007, Numerical Recipes, 3rd ed., Cambridge UP — §10.2, parabolic interpolation through three points (vertex refinement of the peak position).
  • Hampel 1974, J. Am. Stat. Assoc. 69, 383 — Median Absolute Deviation (blind-mode noise level: 1.4826 · MAD).