jwspecfit.constraints
Parameter constraints: tied kinematics and fixed flux ratios.
Constraints are applied as transformations on the free-parameter vector before the model is evaluated. This keeps the optimiser working in an unconstrained space while enforcing physical relationships.
Classes
|
Collection of parameter constraints for a line fit. |
- class jwspecfit.constraints.ConstraintSet(line_names, tie_nii=True, tie_balmer_to_oiii=True, tie_uv_doublets=True, tie_uv_centroids=True, tie_uv_widths=True, blended_doublets=None, niv_doublet_ratio=None, ciii_doublet_ratio=None)[source]
Bases:
objectCollection of parameter constraints for a line fit.
- Parameters:
- tie_balmer_to_oiii
Tie narrow Balmer (and [NII]) widths to [OIII] 5007 in velocity space.
- Type:
- blended_doublets
Secondary line names of kinematic-tied doublets that are unresolved and should have their amplitude fixed to the low-density-limit ratio. Populated by the fitter based on spectral resolution.
- apply(params)[source]
Apply constraints to a parameter vector (in-place copy).
- Parameters:
params (np.ndarray) – Raw parameter vector
[A_0..A_n, mu_0..mu_n, sigma_0..sigma_n].- Returns:
Constrained parameter vector.
- Return type:
np.ndarray
- expand_free_to_full(p_free)[source]
Insert free parameters into a full-length vector.
Constrained slots are filled with placeholder values that will be overwritten by
apply().- Parameters:
p_free (np.ndarray) – Free parameter values.
- Returns:
Full parameter vector (length
3 * n_lines).- Return type:
np.ndarray