kinextract.getfwhm_fortran_like

kinextract.getfwhm_fortran_like(x: ndarray, y: ndarray, frac: float = 0.5) dict[source]

Estimate the full-width-at-fraction-of-max and flux moments of a curve.

Locates the peak of y(x) and linearly interpolates the crossing points where y falls to frac (default: half) of its peak value on either side, giving a robust width estimate that does not require a parametric fit. Also returns the simple flux-weighted first and second moments (v1, v2) of y as a model-free estimate of the centroid and width. Used to construct good initial guesses (amplitude, center, sigma) for the Gauss-Hermite least-squares fits (fit_losvd_gauss_hermite(), fit_losvd_gauss_hermite_higher()), matching the legacy Fortran pipeline’s FWHM-based initialization scheme.

Parameters:
  • x (ndarray) – Independent variable, typically the LOSVD velocity grid (km/s).

  • y (ndarray) – Dependent variable (e.g. LOSVD amplitude) sampled at each x. Assumed single-peaked; only the interval on either side of the global maximum is searched for the half-max crossings.

  • frac (float, optional) – Fraction of the peak value at which to measure the width (0.5 for standard FWHM). Default is 0.5.

Returns:

Dictionary with keys:

  • fwhm : full width at frac of maximum (km/s if x is velocity).

  • vmax : location of the peak (same units as x).

  • ymax : peak value of y.

  • x_left, x_right : interpolated crossing points of the frac-of-max level on the left/right of the peak.

  • v1 : flux-weighted first moment (centroid) of y over x.

  • v2 : flux-weighted second moment (RMS width) of y about v1.

All values are NaN if fewer than 3 points are supplied.

Return type:

dict