Skip to content

merge_echelle_orders

Merge every Spectrum1D in ctx.spectra into a single ctx.spectrum.

Category Stacking
Backend numpy - implemented here on top of numpy primitives
Version 1.0.1
Reads ctx.spectra (a list of Spectrum1D)
Writes spectrum, metrics.n_orders_merged

Use after read_echelle_fits. The output is a 1D spectrum with a log-uniformly-sampled wavelength axis ready for analysis algorithms (snr_der, detect_lines, …) — most of which expect a single Spectrum1D, not a list of orders.

Parameters

Parameter Default Required Description
n_grid_per_order 4000 - Number of log-λ samples to allocate per order on the merged grid. Higher = finer output but slower.
weighting 'uncertainty' - How to combine overlapping pixels: 'uncertainty' (1/σ², requires Spectrum1D.uncertainty), 'mean' (plain average), or 'first' (keep the first order in declared sequence).

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("merge_echelle_orders", ctx, {
    "n_grid_per_order": 4000,
    "weighting": "uncertainty"
})

The CLI loads a single 1-D spectrum with --input; this algorithm needs ctx.spectra (a list of Spectrum1D). Run it from Python or as a step of a pipeline preset.

{
  "tool": "merge_echelle_orders",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "n_grid_per_order": 4000,
      "weighting": "uncertainty"
    }
  }
}

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

References

  • Tody 1993, ASP Conf. Ser. 52, 173 — IRAF scombine (echelle package): orders interpolated to a common dispersion and combined by (weighted) average in the overlap regions.
  • Horne 1986, PASP 98, 609 — inverse-variance (1/σ²) weighting of independent estimates of the same flux.
  • stack_spectra - Combine every spectrum in ctx.spectra into one stacked spectrum.