Skip to content

subtract_continuum

Subtract a sigma-clipped polynomial continuum, leaving the line residual.

Category Continuum
Backend numpy - implemented here on top of numpy primitives
Version 1.0.1
Reads ctx.spectrum (a Spectrum1D)
Writes spectrum, metrics.continuum_median

Parameters

Parameter Default Required Description
order 3 - Polynomial degree of the continuum fit.
sigma_clip 3.0 - Reject samples beyond this many standard deviations per iteration.
iterations 3 - Number of sigma-clipping iterations.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("subtract_continuum", ctx, {
    "order": 3,
    "sigma_clip": 3.0,
    "iterations": 3
})
spectro run subtract_continuum --input spectrum.fits \
  --param order=3 \
  --param sigma_clip=3.0 \
  --param iterations=3
{
  "tool": "subtract_continuum",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "order": 3,
      "sigma_clip": 3.0,
      "iterations": 3
    }
  }
}

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

References

  • Tody 1986, Proc. SPIE 627, 733 — the IRAF data reduction and analysis system ; onedspec.continuum fits an iteratively sigma-clipped function and offers the 'difference' output type implemented here.
  • Gray 2005, The Observation and Analysis of Stellar Photospheres, 3rd ed., Cambridge UP — ch. 12, continuum placement for line measurement.
  • compare_normalisations - Run every continuum-normalisation method on ctx.spectrum and collect them.
  • normalize_edges - Normalise a spectrum using a continuum fitted only on its line-free edges.
  • normalize_max - Normalise a spectrum by dividing the flux by its maximum value.
  • normalize_percentile - Normalise a spectrum by dividing the flux by a high percentile of itself.
  • normalize_polynomial - Normalise the continuum to unity with a sigma-clipped polynomial fit.
  • normalize_to_region - Divide the flux by its NaN-safe mean over [wave_lo, wave_hi].