GUIBRUSHR.core.types.chain_schema module

Frozen ordering contract for the flat MCMC free-parameter sequence.

ChainSchema collapses the parallel list_bestpars, list_bestpars_initial_value and scale_vector_params lists into a single immutable object that owns the name <-> index mapping for the chain vector newpars_chain.

The MCMC inner loop continues to operate on numpy arrays for performance; ChainSchema is the explicit dict<->array boundary. The multi_expansion attribute encodes how multi-valued parameters (e.g. per-night jitter) were expanded into individual chain entries (jitter1, jitter2, …), so create_param_full no longer needs to substring-match base names.

class GUIBRUSHR.core.types.chain_schema.ChainSchema(names: ~typing.Tuple[str, ...], initial_values: ~numpy.ndarray, scale_vector: ~numpy.ndarray, multi_expansion: ~typing.Mapping[str, ~typing.Tuple[str, ...]] = <factory>)[source]

Bases: object

Immutable description of a flat free-parameter sequence.

Variables:
  • names (Tuple[str, ...]) – Ordered tuple of free-parameter names with multi-expansion already applied (e.g. ("T0", "p1", "jitter1", "jitter2", "CO", "H2O")). Aligned 1:1 with newpars_chain and the leading axis of the stored chains array pars[nfit, nsteps, nchains].

  • initial_values (numpy.ndarray) – ndarray(nfit,) of starting values, aligned with names.

  • scale_vector (numpy.ndarray) – ndarray(nfit,) of DE-MCMC perturbation scales, aligned with names. Replaces Retrieval.scale_vector_params.

  • multi_expansion (Mapping[str, Tuple[str, ...]]) – Mapping from a multi-valued base parameter name (e.g. "jitter") to the ordered tuple of expanded chain names that were generated from it (e.g. ("jitter1", "jitter2", "jitter3")). Empty mapping if no multi-parameters are active. Used by create_param_full to attribute consecutive chain values to the right multi slot without substring matching.

names: Tuple[str, ...]
initial_values: ndarray
scale_vector: ndarray
multi_expansion: Mapping[str, Tuple[str, ...]]
property nfit: int
i(name: str) int[source]

Return the chain-index of name.

get(vector: ndarray, name: str) float[source]

Read value of name from a chain vector.

to_dict(vector: ndarray) Dict[str, float][source]
from_dict(mapping: Mapping[str, float]) ndarray[source]
__init__(names: ~typing.Tuple[str, ...], initial_values: ~numpy.ndarray, scale_vector: ~numpy.ndarray, multi_expansion: ~typing.Mapping[str, ~typing.Tuple[str, ...]] = <factory>) None