Skip to content

compare_snr_methods

Run every SNR estimator on ctx.spectrum and collect their numbers.

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

Each method writes to ctx.metrics; this wrapper aggregates them into ctx.extras['snr_methods'] so a downstream caller (or an MCP agent) can compare at a glance. The wrapper itself does not mutate ctx.spectrum ; each method runs on a slim context holding a copy of the spectrum only.

Parameters

Parameter Default Required Description
methods ['snr_der', 'snr_edge', 'snr_linear_fit'] - Names of SNR algorithms to run (defaults to the 3 native ones).
per_method_params {} - Optional dict {method_name: {param: value}} for overrides.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("compare_snr_methods", ctx, {
    "methods": [
        "snr_der",
        "snr_edge",
        "snr_linear_fit"
    ],
    "per_method_params": {}
})
spectro run compare_snr_methods --input spectrum.fits \
  --param methods=["snr_der","snr_edge","snr_linear_fit"] \
  --param per_method_params={}
{
  "tool": "compare_snr_methods",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "methods": [
        "snr_der",
        "snr_edge",
        "snr_linear_fit"
      ],
      "per_method_params": {}
    }
  }
}

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

References

  • Catalogue snr_* algorithms; this wrapper is composition only.
  • snr_der - Derivative-based SNR estimator (DER_SNR, Stoehr et al. 2008).
  • snr_edge - Estimate SNR from the flat, line-free regions at the spectrum's edges.
  • 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.