astrocook.fitting.voigt_model module#
- class astrocook.fitting.voigt_model.VoigtModelConstraintV2(system_list: SystemListV2, constraints: Dict[str, Any] = None)[source]#
Bases:
objectManages parameter constraints and vector mapping for Voigt fitting.
This class acts as a bridge between the high-level, object-oriented representation of absorption systems (
SystemListV2) and the flat parameter arrays required by numerical optimizers.It handles:
Selective Fitting: Identifying which components are “active” (free to vary) and which are “frozen” based on user selection and grouping logic.
Parameter Linking: Evaluating mathematical expressions to link parameters (e.g., tying the redshift of two components together).
Vectorization: Converting component objects to a flat vector
pand back.
- Parameters:
system_list (SystemListV2) – The system list containing the components to model.
constraints (dict, optional) – Initial constraints dictionary (legacy argument, usually handled internally).
- PARAMETER_ORDER = ['z', 'logN', 'b', 'btur']#
- V1_ID_REGEX = re.compile('p\\[(\\d+)\\]')#
- DEFAULT_BOUNDS = {'b': (1.0, 300.0), 'btur': (0.0, 100.0), 'logN': (10.0, 23.0), 'z': (-0.5, 10.0)}#
- __init__(system_list: SystemListV2, constraints: Dict[str, Any] = None)[source]#
- set_active_components(target_uuids: List[str] = None, group_depth: int = 2)[source]#
Define the set of components to be fit (the “Fluid Group”).
When fitting a specific line, the fitter must also include any lines that are: 1. Physically linked (via parameter constraints). 2. Spectrally overlapping (blended).
This method calculates that connected group and marks all other components as “frozen” (fixed parameters) for the upcoming fit.
- Parameters:
target_uuids (list of str, optional) – The UUIDs of the components the user explicitly selected. If
None, ALL components are considered active.group_depth (int, optional) – How many degrees of separation to traverse when finding connected components. -
1: Direct neighbors/links only. -2: Neighbors of neighbors (Friends of Friends). Defaults to2.
- property p_free_vector: ndarray#
The 1D array of currently free (varying) parameters.
This vector serves as the input
xfor the optimizer. It excludes fixed parameters and dependent (linked) parameters.
- map_p_free_to_full(p_free_fitted: ndarray) ndarray[source]#
Reconstruct the full parameter vector from the free parameters.
This method: 1. Places the free parameter values into their correct positions in the full vector. 2. Leaves fixed parameters at their initial values. 3. Evaluates and applies all linked parameter expressions (e.g.,
z2 = p['uuid1'].z).- Parameters:
p_free_fitted (np.ndarray) – The vector of optimized free parameters (output from optimizer).
- Returns:
The full vector containing all parameters (z, logN, b, btur) for all components.
- Return type:
np.ndarray
- get_bounds() Tuple[ndarray, ndarray][source]#
Return lower and upper bounds for the free parameters.
Extracts the physical limits (e.g., b > 0) for every parameter currently in the free vector.
- Returns:
A tuple
(lower_bounds, upper_bounds), each being a numpy array matching the size ofp_free_vector.- Return type:
tuple
- property v2_constraints_for_save: Dict[str, Dict[str, ParameterConstraintV2]]#
- get_active_param_labels() List[str][source]#
Return a list of formatting labels for all active free parameters.
Iterates through the components and parameter constraints to build identifying strings (e.g.,
'z (1)','logN (2)') for every parameter that is currently free to vary during the fit. Used primarily for visualization (e.g., Corner Plots).- Returns:
A list of parameter labels, matching the order of the
p_free_vector.- Return type:
list of str