Skip to content

compare_line_fits

Fit one spectral line with every profile in turn and pick the best one.

Category Line fitting
Backend scipy - implemented here on top of scipy primitives
Version 1.0.0
Reads ctx.spectrum (a Spectrum1D)
Writes line_fits, extras.line_fit_comparison

Useful when you do not know whether a line is pressure-broadened (Lorentzian wings dominate), thermally / instrumentally broadened (Gaussian is enough), or genuinely mixed (Voigt). The wrapper picks no winner itself — it leaves all three fits on the context for you to compare.

Parameters

Parameter Default Required Description
line_center_angstrom None yes Approximate line centre in Å (required).
window_angstrom 20.0 - Half-width of the fit window on each side (Å).
profiles ['fit_gaussian_line', 'fit_lorentzian_line', 'fit_voigt_line'] - Names of fit_*_line algorithms to run.
label_prefix '' - Prefix for the keys written to ctx.line_fits (defaults to '').

Use it

from spectro_kernel import run_algorithm

output = run_algorithm("compare_line_fits", ctx, {
    "line_center_angstrom": "<value>",
    "window_angstrom": 20.0,
    "profiles": [
        "fit_gaussian_line",
        "fit_lorentzian_line",
        "fit_voigt_line"
    ],
    "label_prefix": ""
})
spectro run compare_line_fits --input spectrum.fits \
  --param line_center_angstrom=<value> \
  --param window_angstrom=20.0 \
  --param profiles=["fit_gaussian_line","fit_lorentzian_line","fit_voigt_line"] \
  --param label_prefix=
{
  "tool": "compare_line_fits",
  "arguments": {
    "session_id": "<session_id>",
    "params": {
      "line_center_angstrom": "<value>",
      "window_angstrom": 20.0,
      "profiles": [
        "fit_gaussian_line",
        "fit_lorentzian_line",
        "fit_voigt_line"
      ],
      "label_prefix": ""
    }
  }
}

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

References

  • Catalogue fit_*_line algorithms; this wrapper is composition only.
  • equivalent_width - Measure a line's equivalent width without assuming a profile shape.
  • fit_gaussian_line - Fit a single Gaussian (plus a linear continuum) to one spectral line.
  • fit_lorentzian_line - Fit a single Lorentzian (plus a linear continuum) to one spectral line.
  • fit_voigt_line - Fit a single Voigt profile (plus a linear continuum) to one spectral line.
  • vr_ratio - Violet/Red intensity ratio of a double-peaked emission line.