kinextract.fit_losvd_gauss_hermite

kinextract.fit_losvd_gauss_hermite(v: ndarray, y: ndarray, fit_h3h4: bool = True) dict[source]

Fit the classic 4-moment Gauss-Hermite model to a non-parametric LOSVD.

This is the standard, publication-facing GH characterization of the recovered non-parametric LOSVD: a bounded least-squares fit of gauss_hermite_losvd_model() (legacy fortran H3/H4 normalization, matching the original Fortran pipeline pallmc.f) to y(v), giving the mean velocity V, dispersion sigma, and the skewness/kurtosis-like moments h3 and h4. Initial guesses are derived from getfwhm_fortran_like(), and sigma is fit in log-space to enforce positivity. This is the fitter used by kinextract.plotting.plot_losvd() and by kinextract.errors.LOSVDErrorEstimator to characterize both the MAP LOSVD and each bootstrap replicate. For higher-order (h5, h6, …) characterization using the vdM1993 convention instead, see fit_losvd_gauss_hermite_higher().

Parameters:
  • v (ndarray) – Velocity grid (km/s) on which the LOSVD y is sampled.

  • y (ndarray) – Non-parametric LOSVD amplitude at each v (same shape as v).

  • fit_h3h4 (bool, optional) – If True (default), fit h3 and h4 along with amplitude, V, and sigma. If False, h3 and h4 are fixed to zero and only a pure Gaussian (amp, V, sigma) is fit — useful for comparing against a strictly-Gaussian LOSVD assumption.

Returns:

Dictionary with keys:

  • vherm, sherm : fitted mean velocity and dispersion (km/s).

  • h3, h4 : fitted Gauss-Hermite moments (dimensionless, fortran convention — see fh3_fortran_like()); zero if fit_h3h4=False.

  • amp : fitted overall amplitude/normalization.

  • fwhm_sigma : sigma estimate derived from the FWHM initial guess (km/s), useful as a sanity check against sherm.

  • v1, v2 : flux-weighted centroid and RMS width of the raw LOSVD (km/s), model-free moments from getfwhm_fortran_like().

  • fwhm, vmax, ymax, x_left, x_right : raw half-max diagnostics from getfwhm_fortran_like().

  • model : the best-fit GH model evaluated on the full input v grid (NaN where the fit could not be performed).

  • fit_success : bool, whether the least-squares solver converged.

  • fit_message : str, solver status message (or failure reason).

If fewer than 5 finite (v, y) points are available, all numeric keys are NaN and fit_success is False.

Return type:

dict