Skip to content

snr_edge

Estimate SNR from the flat, line-free regions at the spectrum's edges.

Category Quality / SNR
Backend numpy - implemented here on top of numpy primitives
Version 1.0.1
Reads ctx.spectrum (a Spectrum1D)
Writes metrics.snr_edge

SNR = median(flux) / std(detrended edge flux), where each edge window is detrended with a linear fit. Non-finite samples (NaN/inf) are masked before the fit and excluded from the noise estimate ; the brick fails when fewer than 3 finite samples remain in either edge window. Returns inf when the detrended edges have zero scatter.

Parameters

Parameter Default Required Description
region_fraction 0.1 - Fraction of the spectrum, at each end, used as a noise window.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("snr_edge", ctx, {
    "region_fraction": 0.1
})
spectro run snr_edge --input spectrum.fits \
  --param region_fraction=0.1
{
  "tool": "snr_edge",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "region_fraction": 0.1
    }
  }
}

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

References

  • Stoehr et al. 2008, 'DER_SNR: A Simple & General Spectroscopic Signal-to-Noise Measurement Algorithm', ASP Conf. Ser. 394, 505 — the comparison baseline (snr_der) for continuum-window SNR estimators.
  • Gray 2005, The Observation and Analysis of Stellar Photospheres, 3rd ed., Cambridge UP — ch. 12, continuum placement and noise estimation in line-free windows.
  • compare_snr_methods - Run every SNR estimator on ctx.spectrum and collect their numbers.
  • snr_der - Derivative-based SNR estimator (DER_SNR, Stoehr et al. 2008).
  • snr_linear_fit - Estimate SNR from the scatter around a linear fit of a continuum region.
  • validate_bess_header - Check a FITS header against the BeSS keyword contract.