kinextract.fit_state_map_with_optional_clean
- kinextract.fit_state_map_with_optional_clean(st: FitState, cfg: FitConfig, a0: ndarray, bounds: list)[source]
Run the MAP fit, optionally with sigma-clipping.
This is the shipped (non-joint) fit path: a bound-constrained L-BFGS-B optimisation of
chi2 + wing-tapered smoothness penalty + LOSVD normalisation penalty(kinextract.numerics.objective_map()), the same objective minimised by the original Fortran implementation this package is a port of. Used directly by pre-normalized-mode fits (cfg.fit_continuum=False) and internally bykinextract.errors’s residual-bootstrap error estimation, which needs hundreds to thousands of fast independent refits per fit – a cost only a point-estimate optimisation, not full posterior sampling, can sustain. A full-posterior (NUTS/HMC) alternative is available viakinextract.bayesian.fit_state_bayesian()for users who want a sampled posterior instead of a point estimate; it is not used by default because a comprehensive recovery-accuracy comparison found the MAP point estimate matches or exceeds the posterior mean’s LOSVD-shape recovery across tested instruments and LOSVD shapes, at a small fraction of the runtime.This is the mid-level orchestration function: it optionally runs the automatic
xlamgrid search (_auto_select_xlam()) once up front, then performs a single (optionally sigma-clipped) MAP fit. Continuum-cofit fits (cfg.fit_continuum=True) never reach this function –run_spectral_fit()dispatches those tokinextract.jointinstead.- Parameters:
st (FitState) – Fit state to optimise;
st.xlammay be overwritten by the automatic regularisation search, andst.clean_good_maskis updated as a side effect when cleaning is enabled.cfg (FitConfig) – Run configuration controlling regularisation search (
xlam_autoand related settings) and cleaning (cleanand related settings).a0 (ndarray) – Initial guess for the flat parameter vector.
bounds (list of tuple) – Per-parameter
(lower, upper)bounds.
- Returns:
The optimisation result from the MAP fit (after any cleaning).
- Return type: