Skip to content

extract_spectrum_sum

Extract a 1D spectrum from ctx.image by summing across the trace.

Category Extraction (2-D to 1-D)
Backend numpy - implemented here on top of numpy primitives
Version 2.0.0
Reads ctx.image (an ImageFrame)
Writes spectrum

This is the simple unweighted sum: useful for bright targets and as a baseline. The resulting wavelength axis is in pixel indices — pass the spectrum through wavelength_calibrate_polynomial to convert to Ångström. Pixel convention: the axis is 0-based (numpy.arange(npix), first column = pixel 0), the same convention as extract_spectrum_boxcar / extract_spectrum_optimal / extract_spectrum_easyspec / extract_sky_lateral_bands and as the pixel positions returned by match_lamp_lines / reidentify_arc_features. v2.0.0: v1 produced a 1-based axis (arange + 1), so chaining it into match_lamp_lines → wavelength_calibrate_polynomial shifted the solution by one pixel (~ +0.9 Å at 0.9 Å/px); the axis is now 0-based like every other extractor.

Parameters

Parameter Default Required Description
dispersion_axis 1 - Axis along which the spectrum disperses (1 = horizontal rows).
half_width 5 - Half-width of the extraction window in spatial pixels.

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("extract_spectrum_sum", ctx, {
    "dispersion_axis": 1,
    "half_width": 5
})

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

{
  "tool": "extract_spectrum_sum",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "dispersion_axis": 1,
      "half_width": 5
    }
  }
}

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

References

  • Horne 1986, PASP 98, 609 — optimal extraction (variance-weighted variant).