GUIBRUSHR.Retrieval.ModelCalculation.Classes.Atmosphere module¶
Atmosphere module for atmospheric modeling and radiative transfer calculations.
This module provides the Atmosphere class for handling atmospheric models, including support for both petitRADTRANS and PyratBay radiative transfer codes.
- GUIBRUSHR.Retrieval.ModelCalculation.Classes.Atmosphere.cloud_opas(lambda0_micron, kappa_cond, kappa_opac, omega, xi, temperatures)[source]¶
Create a cloud opacity function for atmospheric modeling.
This function returns a closure that calculates cloud opacities based on wavelength-dependent scattering and absorption properties.
- Parameters:
lambda0_micron (float) – Central wavelength in microns
kappa_cond (float) – Condensation opacity coefficient
kappa_opac (float or None) – Opacity coefficient (if None, calculated from kappa_cond)
omega (float) – Width parameter for wavelength dependence
xi (float) – Asymmetry parameter
temperatures (array_like) – Temperature profile
- Returns:
Opacity function that takes wavelengths and pressures as input
- Return type:
function
- class GUIBRUSHR.Retrieval.ModelCalculation.Classes.Atmosphere.Atmosphere[source]¶
Bases:
objectAtmospheric model class for radiative transfer calculations.
This class handles atmospheric modeling using either petitRADTRANS or PyratBay radiative transfer codes. It manages pressure profiles, chemical compositions, wavelength grids, and stellar spectra for both high and low resolution calculations.
- update_params(line_species, line_species_isotope, line_species_complete_name_hr, line_species_complete_name_lr, list_condensed_molecules, rayleigh_species, range_min_pressures, range_max_pressures, layers, lbl_high_res, lbl_low_res, resolution=None, instruments_HR=None, instruments_LR=None, continum_opacity=None, mass_vector=None, target=None, chemistry=None, manual_model_obj=None, temp_min=300, temp_max=3000, temp_step=150, initial_params=None, path_default='', rad_mode='Transmission', manual_model_composition=None, retrieval_model='petitRADTRANS', rv_sampling=0.1, additional_opac=False, start_molecs=0)[source]¶
Update atmospheric model parameters.
This method configures the atmospheric model with species, pressure grid, resolution settings, and other parameters needed for radiative transfer calculations.
- Parameters:
line_species (list) – List of line species for opacity calculations
line_species_isotope (list) – List of isotope-specific line species
line_species_complete_name_hr (list) – Complete names of line species HR
line_species_complete_name_lr (list) – Complete names of line species LR
list_condensed_molecules (list) – List of condensed/cloud species
rayleigh_species (list) – List of Rayleigh scattering species
range_min_pressures (float) – Minimum pressure in the atmospheric grid
range_max_pressures (float) – Maximum pressure in the atmospheric grid
layers (int) – Number of atmospheric layers
lbl_high_res (float) – Line-by-line high resolution sampling
lbl_low_res (float) – Line-by-line low resolution sampling
resolution (float, optional) – Spectral resolution
instruments_HR (list, optional) – High resolution instruments
instruments_LR (list, optional) – Low resolution instruments
continum_opacity (list, optional) – Continuum opacity contributors
mass_vector (array_like, optional) – Mass fractions for chemical species
target (object, optional) – Target object containing system parameters
chemistry (str, optional) – Chemistry model type
manual_model_obj (object, optional) – Manual model configuration object
temp_min (float, default=300) – Minimum temperature for calculations
temp_max (float, default=3000) – Maximum temperature for calculations
temp_step (float, default=150) – Temperature step for calculations
initial_params (dict, optional) – Initial parameter values
path_default (str, default="") – Default path for data files
rad_mode (str, default="Transmission") – Radiative transfer mode
manual_model_composition (dict, optional) – Manual composition specification
retrieval_model (str, default="petitRADTRANS") – Radiative transfer code to use
rv_sampling (float, default=0.1) – Radial velocity sampling
additional_opac (bool, default=False) – Whether to include additional opacity sources
start_molecs (int, default=0) – Starting molecule index
- set_wl_range(minwlen_lr=None, maxwlen_lr=None, minwlen_hr=None, maxwlen_hr=None)[source]¶
Set wavelength ranges for high and low resolution calculations.
This method determines the wavelength boundaries for both high and low resolution calculations based on instrument specifications and data ranges. If no explicit ranges are provided, they are automatically determined from the instrument configurations.
- Parameters:
minwlen_lr (float, optional) – Minimum wavelength for low resolution calculations (microns)
maxwlen_lr (float, optional) – Maximum wavelength for low resolution calculations (microns)
minwlen_hr (float, optional) – Minimum wavelength for high resolution calculations (microns)
maxwlen_hr (float, optional) – Maximum wavelength for high resolution calculations (microns)
- init_pyratbay(output_folder, initial_params)[source]¶
Initialize PyratBay radiative transfer module.
This method sets up the PyratBay atmospheric model with the specified configuration and identifies available opacity models for clouds and Rayleigh scattering.
- Parameters:
output_folder (str or Path) – Directory for PyratBay output files
initial_params (dict or None) – Initial parameter values for the model
- read_opacities(table_output_file=None, path_target='', stellar_spectrum_type_lr='Phoenix', stellar_spectrum_type_hr='Phoenix', min_hwhm_hr=1.5, instrument_LR=None, stellar_spectrum_type_lr_mode='Point by Point', use_hr_linelists_for_lr=False)[source]¶
Initialize opacity tables and stellar spectra for radiative transfer.
This method orchestrates the setup of petitRADTRANS Radtrans objects for both high and low resolution calculations. It delegates to specialized methods for LR and HR initialization, loads opacity data, and prepares stellar spectra for emission calculations.
The method handles three resolution scenarios: 1. Low resolution only: Uses correlated-k opacity tables 2. High resolution only: Uses line-by-line opacity mode 3. Mixed mode: HR linelists binned to LR resolution (use_hr_linelists_for_lr)
- Parameters:
table_output_file (str, optional) – Path to output file for error messages
path_target (str, default="") – Path to target-specific data directory
stellar_spectrum_type_lr (str, default="Phoenix") – Type of stellar spectrum for LR (“Planck”, “Phoenix”, or “Integral”)
stellar_spectrum_type_hr (str, default="Phoenix") – Type of stellar spectrum for HR (“Planck” or path to spectrum file)
min_hwhm_hr (float, default=1.5) – Minimum pixel velocity width for high resolution (km/s)
instrument_LR (list, optional) – List of instruments for low resolution calculations
stellar_spectrum_type_lr_mode (str, default="Point by Point") – Type of stellar spectrum for LR (“Point by Point” or “Integral”)
use_hr_linelists_for_lr (bool, default=False) – Use high resolution line lists for low resolution calculations
Warning
If opacity initialization fails, the error is caught internally, a diagnostic message is written to table_output_file (if provided), and the process exits via
exit(). No exception is raised to the caller.Notes
Stellar spectra only loaded for emission mode (not transmission)
Sets attributes: atmosphere_lr, atmosphere_hr, stellar_spectrum (dict with “model_PRT_LR” and “model_PRT_HR” keys), wl_lr_nm, wl_hr_nm
- calc_model(temperature, mass_fraction, vmr, MMW, dict_calc_model, HR=True)[source]¶
Compute the transmission or emission spectrum for given atmospheric model.
This method calculates either transmission or emission spectra using either petitRADTRANS or PyratBay radiative transfer codes, depending on the configuration.
- Parameters:
temperature (array_like) – Temperature profile
mass_fraction (dict) – Mass fractions of atmospheric species
vmr (dict) – Volume mixing ratios of atmospheric species
MMW (array_like) – Mean molecular weight profile
dict_calc_model (dict) – Dictionary containing model parameters
HR (bool, default=True) – Whether to use high resolution calculation
- Returns:
wl_full_resolution (array_like) – Wavelengths (nm)
model (array_like or None) – Raw model output (transit radii or flux). None when using PyratBay.
depth_full_resolution (array_like) – Final spectrum (transmission depth or emission)
- calc_model_contribution(temperature, mass_fraction, MMW, dict_calc_model, HR=True)[source]¶
Calculate transmission contribution function for atmospheric layers.
This method computes the contribution of different atmospheric layers to the total transmission spectrum, useful for understanding which pressure levels dominate the observed signal.
- Parameters:
temperature (array_like) – Temperature profile
mass_fraction (dict) – Mass fractions of atmospheric species
MMW (array_like) – Mean molecular weight profile
dict_calc_model (dict) – Dictionary containing model parameters
HR (bool, default=True) – Whether to use high resolution calculation
- Returns:
wl (array_like) – Wavelengths (nm)
contribution (array_like) – Transmission contribution function
- opacity_contribution(temperatures, mass_fractions, MMW, dict_calc_model, HR=True)[source]¶
Generate opacity contribution plots for atmospheric species.
This method creates plots showing the relative contribution of different opacity sources (molecular species, clouds, hazes) to the total spectrum.
- Parameters:
temperatures (array_like) – Temperature profile
mass_fractions (dict) – Mass fractions of atmospheric species
MMW (array_like) – Mean molecular weight profile
dict_calc_model (dict) – Dictionary containing model parameters
HR (bool, default=True) – Whether to use high resolution calculation
- Returns:
opacity_contributions – Figure object with opacity contribution plots, or None if failed
- Return type:
matplotlib.figure.Figure or None