Skip to content

smooth_savgol

Smooth a spectrum with a Savitzky-Golay filter.

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

Non-finite samples (NaN/inf) are bridged by linear interpolation over the finite neighbours before filtering, so a bad pixel neither raises nor smears ; the original non-finite positions are restored to NaN in the output (finite inputs are processed bit-identically to v1.0.0). The uncertainty array is copied unchanged, i.e. it is an overestimate after smoothing (the filter reduces the noise) ; propagating it is a contract change left for a future major release.

Parameters

Parameter Default Required Description
window 11 - Sliding-window length in samples (odd; coerced up to the next odd).
polyorder 3 - Polynomial order fitted within each window (< window).

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("smooth_savgol", ctx, {
    "window": 11,
    "polyorder": 3
})
spectro run smooth_savgol --input spectrum.fits \
  --param window=11 \
  --param polyorder=3
{
  "tool": "smooth_savgol",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "window": 11,
      "polyorder": 3
    }
  }
}

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

References

  • Savitzky & Golay 1964, Analytical Chemistry 36, 1627
  • scipy.signal.savgol_filter
  • compare_smoothings - Run every smoothing kernel on ctx.spectrum and collect the results.
  • smooth_gaussian - Smooth a spectrum by convolution with a Gaussian kernel.