GUIBRUSHR.Retrieval.ModelCalculation.ParameterHandler module

Parameter handling for atmospheric retrieval.

Manages parameter unpacking, indexing, and categorization for the MCMC retrieval system. Extracted from ModelData to isolate parameter logic.

GUIBRUSHR.Retrieval.ModelCalculation.ParameterHandler.get_param_array_initial_value(array, index, single_value=True)[source]

Get initial parameter value from array at specified index.

Parameters:
  • array – Parameter array

  • index – Index to retrieve

  • single_value – If True, return single value, else return array

Returns:

Initial parameter value or None if not found

class GUIBRUSHR.Retrieval.ModelCalculation.ParameterHandler.ParameterHandler(params_list: List[str], list_multiple_param: List[str])[source]

Bases: object

Handles parameter indexing, unpacking, and categorization.

This class manages the parameter array and provides methods to: - Look up parameter indices by name - Extract parameter values from arrays - Process and categorize parameters from CSV or manual model input - Reconstruct full parameter arrays from MCMC chain values

Variables:
  • params_list – Ordered list of all parameter names.

  • list_multiple_param – Names of parameters that can have multiple values.

  • initial_param_array – Array of ParamForModel objects (one per parameter slot).

__init__(params_list: List[str], list_multiple_param: List[str])[source]
get_index(param_name: str) int[source]

Find index of parameter with given name in the parameters list.

Handles both exact parameter names and parameter names with numeric suffixes (e.g., ‘jitter1’, ‘jitter2’ -> ‘jitter’).

Parameters:

param_name – Name of parameter to find

Returns:

Index of parameter in params_list

get_value(params, name: str, single_value: bool = True)[source]

Extract value of named parameter from params array.

Parameters:
  • params – Array of parameter objects

  • name – Parameter name to extract

  • single_value – If True, return single value, else return array

Returns:

Parameter value(s) or None if parameter not found

parameter_management(name_for_retrieval, in_bestpars_param, scale_param, constant_vmr_param, range_min_param, range_max_param, molec_param, molec_formula_param, mass_param, name_for_list_molec, rayleigh_species_param, value_during_retrieval, sigma_prior_param, isotope, opacity_name_lr, scale, rayleigh_species, line_species, line_species_isotope, line_species_complete_name_hr, line_species_complete_name_lr, list_bestpars, list_bestpars_initial_value, list_fixed, list_condensed_molecules)[source]

Manage parameter processing and categorization for the retrieval system.

Handles the logic of processing individual parameters and categorizing them into appropriate lists based on their properties.

Parameters:
  • name_for_retrieval – Parameter name used in retrieval

  • in_bestpars_param – Whether parameter is in best parameters list

  • scale_param – Scale factor for parameter

  • constant_vmr_param – Whether VMR is constant

  • range_min_param – Minimum parameter range

  • range_max_param – Maximum parameter range

  • molec_param – Whether parameter is molecular

  • molec_formula_param – Molecular formula

  • mass_param – Molecular mass

  • name_for_list_molec – Name for molecule list

  • rayleigh_species_param – Whether parameter is Rayleigh species

  • value_during_retrieval – Parameter value during retrieval

  • sigma_prior_param – Sigma prior for parameter

  • isotope – Isotope information

  • opacity_name_lr – Opacity name for low resolution

  • scale – Scale factors list

  • rayleigh_species – Rayleigh species list

  • line_species – Line species list

  • line_species_isotope – Isotope list

  • line_species_complete_name_hr – Complete species names list HR

  • line_species_complete_name_lr – Complete species names list LR

  • list_bestpars – Best parameters list

  • list_bestpars_initial_value – Initial values list

  • list_fixed – Fixed parameters list

  • list_condensed_molecules – Condensed molecules list

Returns:

Tuple of updated parameter lists

add_param_manual_model(name, value_during_retrieval, constant_VMR, mass_elem, molec_formula, name_for_list_molec, scale, rayleigh, rayleigh_species, line_species, line_species_isotope, line_species_complete_name_hr, line_species_complete_name_lr, list_bestpars, list_bestpars_initial_value, isotope, list_fixed, list_condensed_molecules)[source]

Add a parameter from manual model to the parameter management system.

Parameters:
  • name – Parameter name

  • value_during_retrieval – Parameter value for retrieval

  • constant_VMR – Whether VMR is constant

  • mass_elem – Molecular mass

  • molec_formula – Molecular formula

  • name_for_list_molec – Name for molecule list

  • scale – Scale factor list

  • rayleigh – Whether Rayleigh scattering applies

  • rayleigh_species – List of Rayleigh species

  • line_species – List of line species

  • line_species_isotope – List of isotopes

  • line_species_complete_name_hr – List of complete species names HR

  • line_species_complete_name_lr – List of complete species names LR

  • list_bestpars – List of best parameters

  • list_bestpars_initial_value – List of initial values

  • isotope – Isotope information

  • list_fixed – List of fixed parameters

  • list_condensed_molecules – List of condensed molecules

Returns:

Tuple of updated parameter lists

read_df_parameters(path_df_parameters: str)[source]

Read the fitting-parameters table for the retrieval.

The path argument is treated as the folder containing the parameters file (the filename component is ignored). The reader prefers df_parameters.yaml and falls back to legacy df_parameters.csv, lazily writing a YAML sibling on first read for forward migration.

Parameters:

path_df_parameters – Path to the parameters file (only its parent directory is used). For backwards compatibility the signature still accepts the legacy file path.

Returns:

Tuple containing all processed parameter information

build_typed_result(scale, rayleigh_species, line_species, line_species_isotope, line_species_complete_name_hr, line_species_complete_name_lr, list_bestpars, list_bestpars_initial_value, list_fixed, list_condensed_molecules, mass_vector=None) ParameterManagementResult[source]

Wrap legacy lists into a ParameterManagementResult dataclass.

Used during Phase 1 to expose the new typed view without altering the read_df_parameters / parameter_management call signatures. Builds a ParamRegistry from self.initial_param_array and a ChainSchema (with multi_expansion) from list_bestpars.

read_df_parameters_typed(path_df_parameters: str) ParameterManagementResult[source]

Typed wrapper around read_df_parameters.

Returns a ParameterManagementResult containing both the new ParamRegistry / ChainSchema view and the legacy lists for Phase-1 callers. Internally calls read_df_parameters so the canonical build logic is not duplicated.

create_param_full(newpars_chain, bestpars_data)[source]

Create full parameter array from chain parameter values.

Reconstructs initial_param_array (in place) by mapping each entry of newpars_chain to its canonical slot via the explicit chain-name -> base-name routing table built from bestpars_data.list_bestpars and self.list_multiple_param.

The routing table eliminates the substring scan that the legacy implementation used to attribute consecutive chain values to a multi-parameter slot. "f_rot"-style base names that happen to be substrings of other base names can no longer collide.

Parameters:
  • newpars_chain – Array of parameter values from MCMC chain.

  • bestpars_data – Bestpars object exposing list_bestpars and nfit (length of newpars_chain).

Returns:

self.initial_param_array with value_in_retrieval / value_arr_in_retrieval populated for every active slot.