Skip to content

normalize_to_region

Divide the flux by its NaN-safe mean over [wave_lo, wave_hi].

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

out = flux / nanmean(flux[wave_lo:wave_hi]). The window is closed at both ends and clamped to the spectrum's wavelength range. Uncertainty (if present) is scaled by |region_mean|. If the region mean is zero or non-finite the algorithm fails with a clear message rather than emitting NaN.

Parameters

Parameter Default Required Description
wave_lo 0.0 yes Lower bound of the reference window (same unit as the wavelength axis).
wave_hi 0.0 yes Upper bound of the reference window.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("normalize_to_region", ctx, {
    "wave_lo": 0.0,
    "wave_hi": 0.0
})
spectro run normalize_to_region --input spectrum.fits \
  --param wave_lo=0.0 \
  --param wave_hi=0.0
{
  "tool": "normalize_to_region",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "wave_lo": 0.0,
      "wave_hi": 0.0
    }
  }
}

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 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_polynomial - Normalise the continuum to unity with a sigma-clipped polynomial fit.
  • subtract_continuum - Subtract a sigma-clipped polynomial continuum, leaving the line residual.