Skip to content

compare_normalisations

Run every continuum-normalisation method on ctx.spectrum and collect them.

Category Continuum
Backend numpy - implemented here on top of numpy primitives
Version 1.0.1
Reads ctx.spectrum (a Spectrum1D)
Writes extras.normalisations, metrics.normalisations_rms

The Spectrum1D ctx.spectrum you pass in is not modified — only ctx.extras['normalisations'] is populated. To then apply one of the results, copy it back into ctx.spectrum yourself.

Parameters

Parameter Default Required Description
methods ['normalize_polynomial', 'normalize_percentile', 'normalize_max', 'normalize_edges'] - Names of normalisation algorithms to run (defaults to the 4 native ones).
per_method_params {} - Optional dict {method_name: {param: value}} for non-default params.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("compare_normalisations", ctx, {
    "methods": [
        "normalize_polynomial",
        "normalize_percentile",
        "normalize_max",
        "normalize_edges"
    ],
    "per_method_params": {}
})
spectro run compare_normalisations --input spectrum.fits \
  --param methods=["normalize_polynomial","normalize_percentile","normalize_max","normalize_edges"] \
  --param per_method_params={}
{
  "tool": "compare_normalisations",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "methods": [
        "normalize_polynomial",
        "normalize_percentile",
        "normalize_max",
        "normalize_edges"
      ],
      "per_method_params": {}
    }
  }
}

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

References

  • Catalogue normalise_* algorithms; this wrapper is composition only.
  • 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.
  • normalize_to_region - Divide the flux by its NaN-safe mean over [wave_lo, wave_hi].
  • subtract_continuum - Subtract a sigma-clipped polynomial continuum, leaving the line residual.