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 whereyfalls tofrac(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) ofyas 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 atfracof maximum (km/s ifxis velocity).vmax: location of the peak (same units asx).ymax: peak value ofy.x_left,x_right: interpolated crossing points of thefrac-of-max level on the left/right of the peak.v1: flux-weighted first moment (centroid) ofyoverx.v2: flux-weighted second moment (RMS width) ofyaboutv1.
All values are NaN if fewer than 3 points are supplied.
- Return type: