Skip to content

normalize_polynomial

Normalise the continuum to unity with a sigma-clipped polynomial fit.

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

Use a low order (2-4) for a slowly varying continuum; higher orders risk absorbing real spectral features. For absorption-line-rich sources set sigma_low=1.5, sigma_high=3.

Parameters

Parameter Default Required Description
order 3 - Polynomial degree of the continuum fit.
sigma_clip 3.0 - Symmetric clip threshold (default 3.0). Used as a fallback for sigma_low / sigma_high when those are left at None.
sigma_low None - Asymmetric clip threshold on the LOW side (rejects absorption lines). None ⇒ falls back to sigma_clip.
sigma_high None - Asymmetric clip threshold on the HIGH side (rejects emission lines / cosmics). None ⇒ falls back to sigma_clip.
iterations 3 - Number of sigma-clipping iterations.
windows None - Optional list of (λ_lo, λ_hi) wavelength intervals ; when given, the polynomial is fitted only on samples inside at least one window (IRAF 'sample' parameter).

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("normalize_polynomial", ctx, {
    "order": 3,
    "sigma_clip": 3.0,
    "sigma_low": None,
    "sigma_high": None,
    "iterations": 3,
    "windows": None
})
spectro run normalize_polynomial --input spectrum.fits \
  --param order=3 \
  --param sigma_clip=3.0 \
  --param sigma_low=none \
  --param sigma_high=none \
  --param iterations=3 \
  --param windows=none
{
  "tool": "normalize_polynomial",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "order": 3,
      "sigma_clip": 3.0,
      "sigma_low": null,
      "sigma_high": null,
      "iterations": 3,
      "windows": null
    }
  }
}

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 — IRAF continuum task (low_reject / high_reject / sample heritage).
  • 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_to_region - Divide the flux by its NaN-safe mean over [wave_lo, wave_hi].
  • subtract_continuum - Subtract a sigma-clipped polynomial continuum, leaving the line residual.