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 precomputed ip_map/ip_mask tables on st), and applies any continuum corrections. This is the forward model whose mismatch with the observed spectrum forms the chi2 term of objective_map().

Parameters:
  • a (ndarray) – Flat parameter vector, laid out as: nl LOSVD bin values, nt template weights, then (depending on st.icoff) 0, 1, or 2 continuum offset parameters, then an optional global amplitude (if st.fit_global_amp), then an optional polynomial continuum coefficient (if st.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) when st.fit_continuum is 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_amp is False).

Notes

When st.fortran_template_mixture is False, each pixel’s mixture only uses the templates that actually cover it there, via the per-template st.outside_tpl mask (shape (npix, nt)), rather than via the fragile T == 1.0 sentinel value used by the legacy Fortran/ early-Python code.