kinextract.compute_weighted_template_spectrum
- kinextract.compute_weighted_template_spectrum(st: FitState, w: ndarray) ndarray[source]
Compute the weighted mixture of stellar templates for given weights.
Forms the (unconvolved, pre-LOSVD) weighted combination of the template library
st.tusing weights w, i.e. the same template-mixing step performed insideevaluate_model_gp()before LOSVD convolution. Used to reconstruct the best-fit “input” template spectrum for plotting or output, without having to re-run the full forward model.- Parameters:
st (FitState) – Fit state holding the template matrix
st.t(shape(npix, nt)) and theoutside_tplcoverage mask.w (ndarray) – Template weights, length
nt(as fit by the optimizer).
- Returns:
Weighted template spectrum, length
npix. If the weights sum to a non-positive or non-finite value, returns an array of ones (a flat fallback spectrum) rather than dividing by zero.- Return type:
ndarray
Notes
When
st.fortran_template_mixtureis False, pixels outside any template’s coverage are excluded from the weighted sum viast.outside_tpl, matching the corresponding logic inevaluate_model_gp().