GUIBRUSHR.Retrieval.ModelCalculation.LikelihoodHR module¶
High-resolution likelihood calculations for atmospheric retrieval.
Manages mass fraction computation, prior determinant calculation, and the full high-resolution spectral likelihood evaluation. Extracted from ModelData to isolate the HR likelihood logic.
- class GUIBRUSHR.Retrieval.ModelCalculation.LikelihoodHR.LikelihoodHR(atmosphere, retrieval_data, param_handler, bestpars_data, beta_list, model_type, clight, start_molec, start_elements, start_condensed)[source]¶
Bases:
objectHigh-resolution likelihood evaluator for atmospheric retrieval.
Handles mass fraction computation, Bayesian prior determinant calculation, and the full high-resolution spectral likelihood (PCA telluric removal, chi-square, diagnostic plots).
- Variables:
atmosphere – Atmosphere object with species, pressure, resolution data.
retrieval_data – Retrieval configuration (paths, methods, masks).
param_handler – ParameterHandler for index/value lookups.
bestpars_data – Bestpars object with list_bestpars and nfit.
beta_list – Array of beta values per night (or 1).
model_type – Model type string (“Retrieval”, “Model”, etc.).
clight – Speed of light constant.
start_molec – Index where molecules start in params_list.
start_elements – Index where elements start in params_list.
start_condensed – Index where condensed molecules start in params_list.
- __init__(atmosphere, retrieval_data, param_handler, bestpars_data, beta_list, model_type, clight, start_molec, start_elements, start_condensed)[source]¶
- property initial_param_array¶
- calculate_mass_fraction(temperature, metallicity, c_o_ratio, si_o_ratio_final, vmr_peak_arr, pressure_peak_arr, width_peak_arr, chain=None, step=None)[source]¶
Compute mass mixing ratios for atmospheric species.
This method calculates mass mixing ratios based on the selected chemistry model (equilibrium, free chemistry, or hybrid). It handles volume mixing ratio calculations, mean molecular weight computation, and species abundance adjustments for dissociation effects.
- Parameters:
temperature – 1D temperature profile array
metallicity – log(metallicity) enhancement factor for equilibrium chemistry
c_o_ratio – Carbon-to-oxygen ratio for equilibrium chemistry
si_o_ratio_final – Si-to-oxygen ratio for equilibrium chemistry
vmr_peak_arr – VMR peak values for variable abundance profiles
pressure_peak_arr – Pressure peak positions for variable profiles
width_peak_arr – Width parameters for variable abundance profiles
chain – MCMC chain index, used only to annotate warning prints with their origin. None outside an MCMC context.
step – MCMC outer step index, used together with
chainto annotate warning prints. None outside an MCMC context.
- Returns:
mass_fraction: Dictionary of mass mixing ratio profiles
MMW: 1D mean molecular weight profile array
vmr: 2D volume mixing ratio array of shape [nlayers, nmol]
mean_VMR_and_MF_string: String containing mean VMR and mass fractions per species
mean_VMR_and_MF_dict: Dictionary mapping species to their mean VMR, MF, and linelist name
err: Boolean, True if negative mass fractions were found
- Return type:
Tuple containing
- calculate_log_prior(params)[source]¶
Calculate the log of the Gaussian prior product for Bayesian parameter estimation.
IDL called this function/value ‘determinant’ (keyword: determinant=det), but it computes π(θ) = Π_i exp[-0.5*((θ_i-μ_i)/σ_i)²] — the product of Gaussian priors. This is not a matrix determinant; the name is a historical misnomer from IDL exofast.
IDL computed the product in linear space:
det = 1.0 det *= exp(-((value - initial_value)**2) / (2*sigma**2))
which underflows to 0.0 for N ≳ 150 parameters with deviations of a few sigma, silently blocking all MCMC steps (acceptance ratio C = 0/0 → nan → never accepted).
This implementation computes the equivalent in log-space (sum instead of product), which is numerically exact for any number of parameters:
log_prior = Σ -0.5 * ((θ_i - μ_i) / σ_i)²
- Parameters:
params – Array of parameter objects
- Returns:
Log of the Gaussian prior product (float, always finite)
- Return type:
log_prior
- high_resolution_lhood(temperature, mass_fraction, vmr, MMW, dict_calc_model, chain=None, step=None)[source]¶
Compute high-resolution likelihood with advanced spectral processing.
This method performs the most complex spectral processing in the atmospheric retrieval system. It handles: 1. Full-resolution atmospheric model calculation 2. Instrumental resolution convolution 3. Stellar rotation broadening (solid body rotation) 4. Orbital dynamics and Doppler shifts 5. Telluric removal via Principal Component Analysis (PCA) 6. Chi-square likelihood evaluation against observations
The method preserves exact mathematical operations critical for high-precision atmospheric spectroscopy and exoplanet detection.
- Parameters:
temperature – Atmospheric temperature profile
mass_fraction – Mass fraction profiles for all species
vmr – Volume mixing ratios for all species
MMW – Mean molecular weight profile
dict_calc_model – Dictionary containing all model parameters
chain – MCMC chain index, used only to annotate diagnostic prints (negative spectrum, TRPCA error). None outside an MCMC context.
step – MCMC outer step index, used together with
chainto annotate diagnostic prints. None outside an MCMC context.
- Returns:
status: True if successful, False if errors occurred
lhood: Log-likelihood value
wl_full_resolution_HR: Full resolution wavelength array
depth_full_resolution_HR: Full resolution spectrum
opacity_contribution_HR: Opacity contributions (for plotting)
lh_high_resolution: Dictionary of per-instrument per-night likelihood details
- Return type:
Tuple containing