kinextract.build_initial_guess_nonparam
- kinextract.build_initial_guess_nonparam(st: FitState, coff_init: float, coff2_init: float, b_bounds: tuple = (1e-06, 1.0), w_bounds: tuple = (1e-05, 1.0), coff_bounds: tuple | None = None, coff2_bounds: tuple = (-0.7, 0.7), amp_bounds: tuple = (1e-08, 1000000000000.0)) tuple[ndarray, ndarray, ndarray][source]
Build the initial non-parametric-LOSVD parameter vector and its bounds.
Assembles the flat parameter vector used by the optimizer, concatenating (in order): nl non-parametric LOSVD histogram bin weights (each initialized to a flat
1/nl, i.e. a uniform velocity distribution), nt stellar template weights (each initialized to a flat1/nt), then optionally a continuum/wavelength-offset block (depending onst.icoff), a global amplitude parameter (ifst.fit_global_amp), and a continuum-polynomial coefficient (ifst.continuum_poly_modeis not"none"). The corresponding lower- and upper-bound vectors are built in the same order.- Parameters:
st (FitState) – Fit state; supplies
nl(number of LOSVD velocity bins),nt(number of stellar templates),icoff(which continuum-offset parameterization is active),fit_global_amp,continuum_poly_mode,continuum_poly_bound,t(template matrix, for the global-amplitude initial guess), andgerr/g.coff_init (float) – Initial value for the primary continuum/wavelength offset coefficient (used when
st.icoff == 1).coff2_init (float) – Initial value for the secondary continuum/wavelength offset coefficient (used when
st.icoffis 1 or 2).b_bounds (tuple of (float, float), optional) –
(lower, upper)bounds applied to every LOSVD bin weight.w_bounds (tuple of (float, float), optional) –
(lower, upper)bounds applied to every template weight; the effective upper bound is widened tomax(w_bounds[1], 1 + 1e-6)(see Notes).coff_bounds (tuple of (float, float), optional) –
(lower, upper)bounds for the primary offset coefficient (only used whenst.icoff == 1). Defaults to(coff_init - 0.8, coff_init + 4.0)if not given. The lower bound must be greater than -1 (see Raises).coff2_bounds (tuple of (float, float), optional) –
(lower, upper)bounds for the secondary offset coefficient (used whenst.icoffis 1 or 2).amp_bounds (tuple of (float, float), optional) –
(lower, upper)bounds for the global amplitude parameter (only used whenst.fit_global_ampis True).
- Returns:
x0 (ndarray) – Initial flat parameter vector for the optimizer.
lb (ndarray) – Lower bounds, same length and ordering as x0.
ub (ndarray) – Upper bounds, same length and ordering as x0.
- Raises:
ValueError – If the resolved lower bound on the primary continuum offset is
<= -1, since the model evaluation divides by(coff + 1)and such a bound would allow a zero or negative denominator.
Notes
The template-weight upper bound is raised to at least
1.0 + 1e-6so that the initial value (1/nt) coincides with the lower bound only in the degeneratent == 1case, never with the upper bound; starting exactly at an upper bound can cause some optimizers to treat the parameter as already converged.