kinextract.evaluate_model_gp
- kinextract.evaluate_model_gp(a: ndarray, st: FitState, apply_continuum: bool = True) tuple[source]
Evaluate the forward model spectrum for a trial parameter vector.
Unpacks the flat parameter vector a into its physical components (the LOSVD histogram b, template weights w, continuum offsets, and optional global amplitude / polynomial term), forms the weighted template mixture, convolves it with the LOSVD via the discrete pixel-scatter scheme (
_convolve_losvd_numba(), driven by the precomputedip_map/ip_masktables on st), and applies any continuum corrections. This is the forward model whose mismatch with the observed spectrum forms the chi2 term ofobjective_map().- Parameters:
a (ndarray) – Flat parameter vector, laid out as:
nlLOSVD bin values,nttemplate weights, then (depending onst.icoff) 0, 1, or 2 continuum offset parameters, then an optional global amplitude (ifst.fit_global_amp), then an optional polynomial continuum coefficient (ifst.continuum_poly_mode != "none").st (FitState) – Precomputed fit state holding the data, template matrix, velocity grids, and configuration flags needed to evaluate the model.
apply_continuum (bool, optional) – If True (default), multiply the model by the current continuum (
st.continuum_mult) whenst.fit_continuumis set. Set to False to obtain the continuum-free model, e.g. for diagnostics.
- Returns:
gp (ndarray) – Model spectrum, length
npix.b (ndarray) – LOSVD histogram used to build the model, length
nl(clipped to a small positive floor).w (ndarray) – Template weights used to build the model, length
nt(clipped to a small positive floor).coff (float) – Additive continuum offset parameter.
coff2 (float) – Second continuum offset parameter.
A (float) – Global amplitude scaling applied to the model (1.0 if
st.fit_global_ampis False).
Notes
When
st.fortran_template_mixtureis False, each pixel’s mixture only uses the templates that actually cover it there, via the per-templatest.outside_tplmask (shape(npix, nt)), rather than via the fragileT == 1.0sentinel value used by the legacy Fortran/ early-Python code.