kinextract.objective_map

kinextract.objective_map(a: ndarray, st: FitState) float[source]

Scalar objective function minimised by the MAP LOSVD/template fit.

Evaluates the forward model via evaluate_model_gp() and combines the chi2 goodness-of-fit with the LOSVD smoothness penalty, an optional wing-shrinkage penalty, and a soft normalization constraint:

objective = chi2 + smoothness_penalty + wing_shrinkage_penalty
  • 0.1 * |sum(b) - 1|

where chi2 is computed by _compute_chi2() over the good (unmasked, finite, non-clipped) pixels, smoothness_penalty is the wing-tapered second-derivative roughness penalty on the LOSVD b computed by _compute_smoothness() with regularization strength st.xlam, and wing_shrinkage_penalty (_compute_wing_shrinkage(), strength st.xlam_wing_shrink, off by default) is an L2 amplitude penalty active only in the wings – see that function’s docstring for why the roughness penalty alone can leave a non-zero pedestal there. The normalization term softly enforces that the LOSVD histogram integrates to 1 (i.e. represents a normalized probability distribution) without a hard constraint, so the optimizer remains a simple bound- constrained problem solvable by L-BFGS-B. This is the function (or, when use_jax_objective=True, its JAX-autodiff counterpart built by _build_jax_objective_value_and_grad()) minimised in kinextract.fitting.

Parameters:
  • a (ndarray) – Flat trial parameter vector; see evaluate_model_gp() for its layout.

  • st (FitState) – Fit state providing the data, errors, velocity grid, and regularization settings. Its ntot counter (total objective evaluations) and time_eval_model (cumulative model-evaluation wall time) are incremented as a side effect, for diagnostics.

Returns:

The scalar objective value to be minimised.

Return type:

float