Skip to content

clip_sigma

Remove outlier samples (cosmic rays, hot pixels) by iterative sigma clipping.

Category Transforms
Backend scipy - implemented here on top of scipy primitives
Version 1.0.1
Reads ctx.spectrum (a Spectrum1D)
Writes spectrum, metrics.n_clipped

Parameters

Parameter Default Required Description
sigma 5.0 - Clipping threshold, in standard deviations of the residual.
window 5 - Median-filter window (samples) used to estimate the local baseline.
iterations 3 - Maximum number of clipping iterations.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("clip_sigma", ctx, {
    "sigma": 5.0,
    "window": 5,
    "iterations": 3
})
spectro run clip_sigma --input spectrum.fits \
  --param sigma=5.0 \
  --param window=5 \
  --param iterations=3
{
  "tool": "clip_sigma",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "sigma": 5.0,
      "window": 5,
      "iterations": 3
    }
  }
}

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

References

  • Bevington & Robinson 2003, Data Reduction and Error Analysis for the Physical Sciences, 3rd ed., McGraw-Hill — Chauvenet's criterion / iterative rejection of samples beyond k·σ of the fit.
  • astropy.stats.sigma_clip — iterative σ-clipping about a robust centre (the same iterate-until-no-new-rejection scheme, applied here to the residual from a running median).
  • scipy.ndimage.median_filter — local baseline.
  • combine_spectra_arithmetic - Add, subtract, multiply or divide ctx.spectrum by a reference.
  • extract_region - Crop a spectrum to the wavelength window [wavelength_min, wavelength_max].
  • mask_range - Flag every sample inside a wavelength window as masked.