petitRADTRANS.radtrans

Contents

petitRADTRANS.radtrans#

Stores the Radtrans object.

Attributes#

Classes#

Radtrans

Calculate spectra using a given set of opacities.

Functions#

_noop_opacity_fn(wavelengths, pressures)

Return zero opacity matrix with shape (n_wavelengths, n_pressures).

_interpolate_linear_sorted(x_grid, y_grid, x_query)

Linearly interpolate y(x) on a sorted 1D grid for a scalar query.

Module Contents#

petitRADTRANS.radtrans._MISSING_FLOAT#
petitRADTRANS.radtrans._MISSING_NEG_INF#
petitRADTRANS.radtrans._noop_opacity_fn(wavelengths, pressures)#

Return zero opacity matrix with shape (n_wavelengths, n_pressures).

petitRADTRANS.radtrans._interpolate_linear_sorted(x_grid, y_grid, x_query)#

Linearly interpolate y(x) on a sorted 1D grid for a scalar query.

class petitRADTRANS.radtrans.Radtrans(pressures: jax.typing.ArrayLike = None, wavelength_boundaries: jax.typing.ArrayLike = None, line_species: list[str] | tuple[str] = None, gas_continuum_contributors: list[str] | tuple[str] = None, rayleigh_species: list[str] | tuple[str] = None, cloud_species: list[str] | tuple[str] = None, line_opacity_mode: str = 'c-k', line_by_line_opacity_sampling: int = 1, scattering_in_emission: bool = True, emission_angle_grid: jax.typing.ArrayLike = None, anisotropic_cloud_scattering: bool = 'auto', retain_line_opacities_for_plotting: bool = False, path_input_data: str = None)#

Calculate spectra using a given set of opacities.

Args:
pressures (Optional):

(bar) Array defining the pressure grid to be used for the spectral calculations.

wavelength_boundaries (Optional):

List containing left and right border of wavelength region to be considered, in micron. If nothing else is specified, it will be equal to [0.05, 300], hence using the full petitRADTRANS wavelength range (0.11 to 250 microns for 'c-k' mode, 0.3 to 30 microns for the 'lbl' mode). The larger the range the longer the computation time.

line_species (Optional):

List of strings, denoting which line absorber species to include.

gas_continuum_contributors (Optional):

List of strings, denoting which continuum absorber species to include.

rayleigh_species (Optional):

List of strings, denoting which Rayleigh scattering species to include.

cloud_species (Optional):

List of strings, denoting which cloud opacity species to include.

line_opacity_mode (Optional[string]):

If equal to 'c-k': use low-resolution mode, at \(\\lambda/\\Delta \\lambda = 1000\), with the correlated-k assumption. if equal to 'lbl': use high-resolution mode, at \(\\lambda/\\Delta \\lambda = 10^6\), with a line-by-line treatment.

line_by_line_opacity_sampling (Optional[int]):

If mode = 'lbl', then this will only load every line_by_line_opacity_sampling-nth point of the high-resolution opacities. This can be used to save time and RAM. The user should verify whether this leads to solutions which are identical to the results of the non down-sampled \(10^6\) resolution.

scattering_in_emission (Optional[bool]):

Will be False by default. If True scattering will be included in the emission spectral calculations. Note that this increases the runtime of pRT!

emission_angle_grid (Optional):

Array defining the cosines of the angle grid to be used for the emission spectrum calculations, and their weights. The array is of shape (2, n_angles), with emission_angle_grid[0] being the cosines of the angles, and emission_angle_grid[1] being the weights. A dictionary of array with keys ‘cos_angles’ and ‘weights’ can also be used. If None, a default set of values and weights are used.

anisotropic_cloud_scattering (Optional[bool, str]):

If True, anisotropic cloud scattering opacities are used for the spectral calculations. If False, isotropic cloud scattering opacities are used for the spectral calculations. If ‘auto’ (recommended), anisotropic_cloud_scattering is set to True for emission spectrum calculations, and to False for transmission spectrum calculations.

retain_line_opacities_for_plotting (Optional[bool]):

If True, keep per-species unstacked line opacity tables after the stacked runtime layout has been built. This is intended for plotting and debugging only and increases memory usage.

path_input_data (Optional[str]):

Path to the input_data folder, containing the files to be loaded by petitRADTRANS.

__dat_opacity_files_warning_message = Multiline-String#
Show Value
"""loading opacities from .dat files is discouraged, the HDF5 format offer better performances at for a lower memory usage

Converting petitRADTRANS .dat opacity files into HDF5 can be done by executing:
>>> from petitRADTRANS.opacities.file_conversion import convert_all
>>> convert_all()

Alternatively, the petitRADTRANS HDF5 files can be downloaded (see https://petitradtrans.readthedocs.io/en/latest/content/available_opacities.html)"""
__line_opacity_property_setting_warning_message = Multiline-String#
Show Value
"""setting a Radtrans line opacity property should be avoided
These properties are loaded from the opacity data in the input_data directory and are inter-dependent (they need to be updated for consistency)
It is recommended to create a new Radtrans instance instead"""
__property_setting_warning_message = Multiline-String#
Show Value
"""setting a Radtrans property directly is not recommended
Create a new Radtrans instance (recommended) or re-do all the setup steps necessary for the modification to be taken into account"""
_frequency_grid_misalignment_tolerance: float = 0.002#
_pressures#
_line_species = ()#
_gas_continuum_contributors = ()#
_rayleigh_species = ()#
_cloud_species = ()#
_line_opacity_mode = 'c-k'#
_line_by_line_opacity_sampling = 1#
_scattering_in_emission = True#
_retain_line_opacities_for_plotting = False#
_anisotropic_cloud_scattering = 'auto'#
_sum_opacities_emission: bool = False#
_anisotropic_cloud_scattering_emission: bool#
_path_input_data = None#
__scattering_in_transmission = False#
__sum_opacities = False#
__absorber_present#
_lines_loaded_opacities#
_cias_loaded_opacities#
_clouds_loaded_opacities#
_emission_angle_grid#
__getattr__(name)#

Override of the object base __getattr__ method, in order to hint towards pRT3 names when pRT2 names are used.

property anisotropic_cloud_scattering#
property cias_loaded_opacities#
property clouds_loaded_opacities#
property cloud_species#
property emission_angle_grid#
property frequencies#
property frequency_bins_edges#
property gas_continuum_contributors#
property line_by_line_opacity_sampling#
property lines_loaded_opacities#
property line_opacity_mode#
property line_species#
property path_input_data#
property pressures: jax.typing.ArrayLike#
property rayleigh_species#
property scattering_in_emission#
property wavelength_boundaries#
_clouds_have_effect(mass_fractions, cloud_fraction)#

Check if the clouds have any effect, i.e. if the cloud species MMR is greater than 0.

Args:

mass_fractions: atmospheric mass mixing ratios cloud_fraction: cloud coverage fraction

static _has_partial_coverage_background_cloud(opaque_cloud_top_pressure=None, power_law_opacity_350nm=None, power_law_opacity_coefficient=None)#

Check whether runtime-only cloud opacities should participate in cloud_fraction mixing.

_normalize_patchy_clouds(patchy_clouds=None, complete_coverage_clouds=None)#
_get_complete_coverage_cloud_species(patchy_clouds)#
_get_partial_coverage_cloud_species(patchy_clouds)#
static _compute_additional_continuum_opacities(frequencies, pressures, additional_absorption_opacities_function, additional_scattering_opacities_function, cloud_photosphere_median_optical_depth)#
_init_spectral_function(is_emission, reference_gravity, return_clear_spectrum, mass_fractions, cloud_fraction, opaque_cloud_top_pressure, has_partial_coverage_background_cloud=False, patchy_clouds=None, complete_coverage_clouds=None)#

Initializations and checks common to calculate_flux and calculate_transit_radii.

_stack_loaded_line_opacities(temperature_pressure_grids=None, temperature_grid_sizes_map=None, pressure_grid_sizes_map=None, opacity_grids=None)#
_set_unstacked_line_opacity_debug_data(temperature_pressure_grids, temperature_grid_sizes, pressure_grid_sizes, opacity_grids)#
static _set_sum_opacities(emission, line_opacity_mode, scattering_in_emission)#
_resolve_solver_pressures(pressures=None)#
_calculate_flux(pressures, temperatures, reference_gravity, opacities, continuum_opacities_scattering, irradiation_geometry, star_irradiation_cos_angle, stellar_intensity, reflectances, emissivities, cloud_f_sed, photospheric_cloud_optical_depths, cloud_photosphere_wavelength_boundaries, cloud_anisotropic_scattering_opacities, cloud_absorption_opacities, adaptive_feautrier_iterations, return_contribution=False, return_angle_dependent_intensities=False, sum_opacities=True, chunk_feautrier=True, feautrier_chunk_size=1536)#

Compute the emission flux for the already-prepared opacity state.

This helper converts opacities into optical depths, chooses the appropriate radiative-transfer solver, and optionally evaluates the emission contribution function.

Args:
reference_gravity:

Reference gravity in cgs units used in the optical-depth calculation.

opacities:

Total absorption opacity array prepared by _calculate_opacities.

continuum_opacities_scattering:

Continuum scattering opacity array with frequency and layer dimensions.

irradiation_geometry:

Irradiation geometry passed to the emission solver.

star_irradiation_cos_angle:

Cosine of the stellar irradiation angle.

stellar_intensity:

Incident stellar intensity spectrum on the model frequency grid.

reflectances:

Surface reflectance spectrum.

emissivities:

Surface emissivity spectrum.

cloud_f_sed:

Cloud settling parameter forwarded to the optical-depth helper when photospheric cloud scaling is requested.

photospheric_cloud_optical_depths:

Optional target cloud optical depth used by the photospheric cloud parametrization.

cloud_photosphere_wavelength_boundaries:

Optional wavelength interval used when evaluating the photospheric cloud optical depth.

cloud_anisotropic_scattering_opacities:

Cloud anisotropic scattering opacities used when scattering in emission is enabled.

cloud_absorption_opacities:

Cloud absorption opacity contribution used by the optical-depth calculation.

adaptive_feautrier_iterations:

Whether to adapt the number of scattering iterations in the Feautrier solver.

return_contribution:

If True, also return the emission contribution function.

return_angle_dependent_intensities:

If True, return angle-dependent intensities. Non-scattering emission returns a zero placeholder with the correct shape.

chunk_feautrier:

If True, evaluate the Feautrier solver in frequency chunks.

feautrier_chunk_size:

Number of frequency bins per chunk when chunk_feautrier is enabled.

Returns:

Tuple (flux, emission_contribution, optical_depths, relative_cloud_scaling_factor) on the internal frequency grid.

_maybe_calculate_photosphere_radius(planet_radius, return_photosphere_radius, temperatures, mean_molar_masses, reference_gravity, opacities, continuum_opacities_scattering, cloud_f_sed, cloud_photosphere_median_optical_depth, cloud_photosphere_wavelength_boundaries, cloud_anisotropic_scattering_opacities, cloud_absorption_opacities, optical_depths)#
_calculate_radius_hydrostatic_equilibrium(pressures, temperatures, mean_molar_masses, reference_gravity, planet_radius)#
_get_photosphere_optical_depths(pressures, optical_depths, reference_gravity, opacities, continuum_opacities_scattering, cloud_f_sed, cloud_photosphere_median_optical_depth, cloud_photosphere_wavelength_boundaries, cloud_anisotropic_scattering_opacities, cloud_absorption_opacities, sum_opacities)#
_interpolate_photosphere_radius_profile(pressures, optical_depths, radius_hydrostatic_equilibrium)#
_calculate_opacities(pressures, temperatures, mass_fractions, mean_molar_masses, reference_gravity, opaque_cloud_top_pressure=None, cloud_particle_mean_radii=None, cloud_particle_radius_distribution_std=None, cloud_particle_radius_distribution='lognormal', cloud_particle_number_density_grid=None, cloud_hansen_a=None, cloud_hansen_b=None, clouds_particle_porosity_factor=None, cloud_f_sed=None, eddy_diffusion_coefficients=None, haze_factor=1.0, power_law_opacity_350nm=None, power_law_opacity_coefficient=None, gray_opacity=None, cloud_photosphere_median_optical_depth=None, cloud_fraction=1.0, patchy_clouds=None, return_cloud_contribution=False, return_opacities=False, additional_absorption_opacities_function=None, additional_scattering_opacities_function=None, compute_clear_opacities=False, sum_opacities=False, anisotropic_cloud_scattering=None, target_particle_radii=None, target_pressure=None)#

Build line, continuum, and cloud opacity products for a spectrum calculation.

The method interpolates line opacities to the current atmospheric structure, computes gas and cloud continuum contributions, combines them according to the active line-opacity mode, and optionally builds a

Args:
temperatures:

Atmospheric temperature profile in K.

mass_fractions:

Mapping from species name to mass-fraction profile.

mean_molar_masses:

Mean molecular mass profile in amu.

reference_gravity:

Reference gravity in cgs units.

opaque_cloud_top_pressure:

Optional pressure in bar where an opaque cloud deck is imposed.

cloud_particle_mean_radii:

Optional cloud particle mean radii keyed by cloud species.

cloud_particle_radius_distribution_std:

Width of the log-normal particle size distribution.

cloud_particle_radius_distribution:

Cloud particle size distribution model, typically "lognormal" or "hansen".

cloud_particle_number_density_grid:

Optional per-species particle number density grid.

cloud_hansen_a:

Optional Hansen a parameter profiles keyed by cloud species.

cloud_hansen_b:

Optional Hansen b parameter profiles keyed by cloud species.

clouds_particle_porosity_factor:

Optional porosity factors keyed by cloud species.

cloud_f_sed:

Cloud settling parameter, either scalar or per-species mapping.

eddy_diffusion_coefficients:

Optional eddy diffusion coefficient profile or mapping.

haze_factor:

Scalar multiplier for Rayleigh scattering.

power_law_opacity_350nm:

Optional reference scattering opacity at 0.35 micron.

power_law_opacity_coefficient:

Wavelength exponent for the parametrized scattering opacity.

gray_opacity:

Optional gray absorption opacity added everywhere.

cloud_photosphere_median_optical_depth:

Optional target median cloud optical depth near the photosphere.

cloud_fraction:

Cloud coverage fraction for mixed cloudy and clear columns.

patchy_clouds:

Cloud species affected by cloud_fraction and therefore excluded from the always-cloudy branch.

return_cloud_contribution:

If True, propagate cloud contribution products required by downstream diagnostics.

additional_absorption_opacities_function:

Optional user-supplied absorption opacity callback.

additional_scattering_opacities_function:

Optional user-supplied scattering opacity callback.

compute_clear_opacities:

If True, also construct clear-column opacities.

target_particle_radii:

Particle radius to target for selective bin disabling. Radius bin closest the input value will be disabled.

target_pressure:

Pressure to target for selective bin disabling. Pressure bin closest to the input value will be disabled.

Returns:

Tuple containing cloudy opacities, cloudy scattering opacities, cloud-only opacity diagnostics, particle radii products, a flag for scattering in transmission, and optional clear-column opacity products.

_calculate_transit_radii(pressures, temperatures, mean_molar_masses, reference_gravity, reference_pressure, planet_radius, variable_gravity, opacities, continuum_opacities_scattering, sum_opacities, return_contributions)#

Compute transmission-spectrum radii for the prepared opacity state.

Args:
temperatures:

Atmospheric temperature profile in K.

mean_molar_masses:

Mean molecular mass profile in amu.

reference_gravity:

Reference gravity in cgs units at reference_pressure.

reference_pressure:

Pressure in bar where planet_radius is defined.

planet_radius:

Planet radius in cm at reference_pressure.

variable_gravity:

If True, use a $1/r^2$ gravity profile in the transmission calculation.

opacities:

Total opacity array produced by _calculate_opacities.

continuum_opacities_scattering:

Continuum scattering opacity array.

sum_opacities:

Whether the main transmission spectrum should use the summed opacity contract.

return_contributions:

Whether to evaluate the transmission contribution function on the same opacity contract as the main transmission spectrum.

Returns:

Tuple (transit_radii, radius_hydrostatic_equilibrium, transmission_contribution).

_init_frequency_grid()#
static _init_frequency_grid_from_frequency_grid(frequency_grid, wavelength_boundaries, sampling=1)#
_init_frequency_grid_from_lines()#
_tree_flatten()#
classmethod _tree_unflatten(aux_data, children)#
calculate_contribution_spectra(mode, opaque_cloud_top_pressure=None, power_law_opacity_350nm=None, power_law_opacity_coefficient=None, gray_opacity=None, cloud_photosphere_median_optical_depth=None, additional_absorption_opacities_function=None, additional_scattering_opacities_function=None, stellar_intensities=None, **kwargs)#

Calculate total and per-opacity-source spectra for attribution studies.

The method evaluates the requested spectral mode once with all active opacity sources and then repeats the calculation for each individual initialization-time or runtime opacity source, returning a dictionary of spectra keyed by contribution name.

Args:
mode:

Either "emission" or "transmission".

opaque_cloud_top_pressure:

Optional opaque cloud deck pressure in bar.

power_law_opacity_350nm:

Optional reference scattering opacity for the parametrized power law cloud model.

power_law_opacity_coefficient:

Wavelength exponent for the parametrized scattering opacity.

gray_opacity:

Optional gray absorption opacity.

cloud_photosphere_median_optical_depth:

Optional target cloud optical depth near the photosphere.

additional_absorption_opacities_function:

Optional user-provided absorption opacity callback.

additional_scattering_opacities_function:

Optional user-provided scattering opacity callback.

stellar_intensities:

Optional stellar intensity spectrum used in emission mode.

**kwargs:

Additional keyword arguments forwarded to calculate_flux or calculate_transit_radii.

Returns:

Nested dictionary containing the total spectrum under "Total" and contribution spectra grouped by opacity source.

calculate_flux(temperatures: jax.typing.ArrayLike, mass_fractions: dict[str, jax.typing.ArrayLike], mean_molar_masses: jax.typing.ArrayLike, reference_gravity: float, planet_radius: float = None, opaque_cloud_top_pressure: float = None, cloud_particle_mean_radii: dict[str, jax.typing.ArrayLike] = None, cloud_particle_radius_distribution_std: float | dict[str, jax.typing.ArrayLike] = None, cloud_particle_radius_distribution: str = 'lognormal', cloud_hansen_a: dict[str, jax.typing.ArrayLike] = None, cloud_hansen_b: dict[str, jax.typing.ArrayLike] = None, cloud_particle_number_density_grid: dict[str, jax.typing.ArrayLike] = None, clouds_particle_porosity_factor: dict[str, float] = None, cloud_f_sed: float = None, eddy_diffusion_coefficients: jax.typing.ArrayLike = None, haze_factor: float = 1.0, power_law_opacity_350nm: float = None, power_law_opacity_coefficient: float = None, gray_opacity: float = None, cloud_photosphere_wavelength_boundaries: jax.typing.ArrayLike = None, cloud_photosphere_median_optical_depth: float = None, cloud_fraction: float = 1.0, patchy_clouds: list[str] | tuple[str] = None, complete_coverage_clouds: list[str] = None, irradiation_geometry: str = 'dayside_ave', stellar_intensities: jax.typing.ArrayLike = None, star_effective_temperature: float = None, star_radius: float = None, orbit_semi_major_axis: float = None, star_irradiation_angle: float = 0.0, reflectances: jax.typing.ArrayLike = None, emissivities: jax.typing.ArrayLike = None, additional_absorption_opacities_function: Callable = None, additional_scattering_opacities_function: Callable = None, adaptive_feautrier_iterations: bool = False, chunk_feautrier: bool = True, feautrier_chunk_size: int = 1536, frequencies_to_wavelengths: bool = True, return_contribution: bool = False, return_clear_spectrum: bool = False, return_photosphere_radius: bool = False, return_rosseland_optical_depths: bool = False, return_cloud_contribution: bool = False, return_opacities: bool = False, return_abundances: bool = False, return_stellar_intensities: bool = False, return_angle_dependent_intensities: bool = False, return_particle_radii_bins: bool = False, return_particle_radii: bool = False, target_particle_radii: jax.typing.ArrayLike = None, pressures: jax.typing.ArrayLike = None, target_pressure: jax.typing.ArrayLike = None) tuple[jax.typing.ArrayLike, jax.typing.ArrayLike, dict[str, Any]]#

Method to calculate the atmosphere’s emitted flux (emission spectrum).

Args:
temperatures:

The atmospheric temperature in K, at each atmospheric layer (1-d numpy array, same length as pressure array).

mass_fractions:

Dictionary of mass fractions for all atmospheric absorbers. Dictionary keys are the species names. Every mass fraction array has same length as pressure array.

mean_molar_masses:

The atmospheric mean molecular weight in amu, at each atmospheric layer (1-d numpy array, same length as pressure array).

reference_gravity (float):

Surface gravity in cgs. Vertically constant for emission spectra.

planet_radius: planet radius at maximum pressure in cm. Only used to calculate the planet’s changing

Photospheric radius as function of wavelength, if return_photosphere_radius is True.

opaque_cloud_top_pressure (Optional[float]):

Pressure, in bar, where opaque cloud deck is added to the absorption opacity.

cloud_particle_mean_radii (Optional):

Dictionary of mean particle radii for all cloud species. Dictionary keys are the cloud species names. Every radius array has same length as pressure array.

cloud_particle_radius_distribution_std:

Width of the log-normal cloud particle size distribution. May be a shared scalar or a per-species dictionary whose values are scalars or layer profiles.

cloud_particle_radius_distribution (Optional[string]):

The cloud particle size distribution to use. Can be either ‘lognormal’ (default) or ‘hansen’. If hansen, the cloud_hansen_b parameters must be used.

cloud_hansen_a (Optional[dict]):

A dictionary of the ‘a’ parameter values for each included cloud species and for each atmospheric layer, formatted as the kzz argument. Equivalent to cloud_particle_mean_radii. If cloud_hansen_a is not included and dist is “hansen”, then it will be computed using Kzz and fsed (recommended).

cloud_hansen_b (Optional[dict]):

A dictionary of the ‘b’ parameter values for each included cloud species and for each atmospheric layer, formatted as the kzz argument. This is the width of the hansen distribution normalized by the particle area (1/cloud_hansen_a^2)

cloud_particle_number_density_grid (Optional[dict]):

EXPERIMENTAL

clouds_particle_porosity_factor (Optional[dict]):

A dictionary of porosity factors depending on the cloud species. This can be useful when opacities are calculated using the Distribution of Hollow Spheres (DHS) method.

cloud_f_sed (Optional[float]):

Cloud settling parameter.

eddy_diffusion_coefficients (Optional[float]):

The atmospheric eddy diffusion coefficient in cgs (i.e. \(\rm cm^2/s\)), at each atmospheric layer (1-d numpy array, same length as pressure array).

haze_factor (Optional[float]):

Scalar factor, increasing the gas Rayleigh scattering cross-section.

power_law_opacity_350nm (Optional[float]):

Scattering opacity at 0.35 micron, in cgs units (cm^2/g).

power_law_opacity_coefficient (Optional[float]):

Has to be given if kappa_zero is defined, this is the wavelength powerlaw index of the parametrized scattering opacity.

gray_opacity (Optional[float]):

Gray opacity value, to be added to the opacity at all pressures and wavelengths (units \(\rm cm^2/g\))

cloud_photosphere_median_optical_depth (Optional[float]):

Median optical depth (across wavelength_boundaries) of the clouds from the top of the atmosphere down to the gas-only photosphere. This parameter can be used for enforcing the presence of clouds in the photospheric region.

cloud_photosphere_wavelength_boundaries (Optional[NDArray]):

Min and max wavelength boundaries when calculating the median of the photospheric cloud optical depth. By default, the whole spectral range is used.

cloud_fraction:

Mix a column without cloud with a column with cloud to the requested fraction (0 = clear, 1 = full cloud cover). Cloud sources such as power-law clouds and opaque cloud decks follow the same mixing. By default, assume a full cloud cover.

patchy_clouds:

List of cloud species affected by cloud_fraction. Runtime-only cloud sources such as power-law clouds and opaque cloud decks are always mixed by cloud_fraction.

complete_coverage_clouds:

Deprecated alias for the complement of patchy_clouds.

irradiation_geometry (Optional[string]):

if equal to 'dayside_ave': use the dayside average geometry. If equal to 'planetary_ave': use the planetary average geometry. If equal to 'non-isotropic': use the non-isotropic geometry.

stellar_intensities (Optional[array]):

The stellar intensity to use. If None, it will be calculated using a PHOENIX model.

star_effective_temperature (Optional[float]):

The temperature of the host star in K, used only if the scattering is considered. If not specified, the direct light contribution is not calculated.

star_radius (Optional[float]):

The radius of the star in cm. If specified, used to scale the to scale the stellar flux, otherwise it uses PHOENIX radius.

orbit_semi_major_axis (Optional[float]):

The distance of the planet from the star. Used to scale the stellar flux when the scattering of the direct light is considered.

star_irradiation_angle (Optional[float]):

Inclination angle of the direct light with respect to the normal to the atmosphere. Used only in the non-isotropic geometry scenario.

reflectances (Optional):

Reflectances of the surface (layer with the highest pressure).

emissivities (Optional):

Emissivities of the surface (layer with the highest pressure).

additional_absorption_opacities_function (Optional[function]):

A python function that takes wavelength arrays in microns and pressure arrays in bars as input, and returns an absorption opacity matrix in units of cm^2/g, in the shape of number of wavelength points x number of pressure points. This opacity will then be added to the atmospheric absorption opacity. This must not be used to add atomic / molecular line opacities in low-resolution mode (c-k), because line opacities require a proper correlated-k treatment. It may be used to add simple cloud absorption laws, for example, which have opacities that vary only slowly with wavelength, such that the current model resolution is sufficient to resolve any variations.

additional_scattering_opacities_function (Optional[function]):

A python function that takes wavelength arrays in microns and pressure arrays in bars as input, and returns an isotropic scattering opacity matrix in units of cm^2/g, in the shape of number of wavelength points x number of pressure points. This opacity will then be added to the atmospheric absorption opacity. It may be used to add simple cloud absorption laws, for example, which have opacities that vary only slowly with wavelength, such that the current model resolution is sufficient to resolve any variations.

adaptive_feautrier_iterations (Optional[bool]):

If True, adapt the number of iterations of the Feautrier scattering-method (scattering_in_emission=True) based on the photon destruction probability.

frequencies_to_wavelengths (Optional[bool]):

if True, convert the frequencies (Hz) output to wavelengths (cm), and the flux per frequency output (erg.s-1.cm-2/Hz) to flux per wavelength (erg.s-1.cm-2/cm)

return_contribution (Optional[bool]):

If True, calculate the emission contribution function.

return_clear_spectrum (Optional[bool]):

If True, return the clear spectrum in addition to a cloudy spectrum.

return_photosphere_radius (Optional[bool]):

If True, calculate and return the photosphere radius.

return_rosseland_optical_depths (Optional[bool]):

If True, calculate and return the Rosseland opacities and optical depths.

return_cloud_contribution (Optional[bool]):

If True, calculate the cloud contribution.

return_opacities (Optional[bool]):

If True, return the absorption opacities and scattering opacities for species and clouds, as well as optical depths

return_abundances (Optional[bool]):

If True, return the mass fractions.

return_stellar_intensities (Optional[bool]):

If True, include the stellar intensities used by the emission solver in the auxiliary output mapping.

return_angle_dependent_intensities (Optional[bool]):

If True, include the angle-dependent intensities in the auxiliary output mapping.

return_particle_radii_bins (Optional[bool]):

If True, return the particle radii bins.

return_particle_radii (Optional[bool]):

If True, return the particle radii.

target_particle_radii (Optional[ArrayLike]:

Particle radius to target for selective bin disabling. Radius bin closest the input value will be disabled.

target_pressure (Optional[ArrayLike]:

Pressure to target for selective bin disabling. Pressure bin closest to the input value will be disabled.

_calculate_flux_kernel(temperatures, mass_fractions, mean_molar_masses, reference_gravity, pressures=None, planet_radius=None, opaque_cloud_top_pressure=None, cloud_particle_mean_radii=None, cloud_particle_radius_distribution_std=None, cloud_particle_radius_distribution='lognormal', cloud_hansen_a=None, cloud_hansen_b=None, cloud_particle_number_density_grid=None, clouds_particle_porosity_factor=None, cloud_f_sed=None, eddy_diffusion_coefficients=None, haze_factor=1.0, power_law_opacity_350nm=None, power_law_opacity_coefficient=None, gray_opacity=None, cloud_photosphere_wavelength_boundaries=None, cloud_photosphere_median_optical_depth=None, cloud_fraction=1.0, patchy_clouds=None, irradiation_geometry='dayside_ave', stellar_intensities=None, star_effective_temperature=None, star_radius=None, orbit_semi_major_axis=None, star_irradiation_angle=0.0, reflectances=None, emissivities=None, additional_absorption_opacities_function=None, additional_scattering_opacities_function=None, adaptive_feautrier_iterations=False, chunk_feautrier=True, feautrier_chunk_size=1536, frequencies_to_wavelengths=True, return_contribution=False, return_clear_spectrum=False, return_photosphere_radius=False, return_cloud_contribution=False, return_opacities=False, return_abundances=False, return_stellar_intensities=False, return_angle_dependent_intensities=False, return_particle_radii_bins=False, return_particle_radii=False, target_particle_radii=None, target_pressure=None, sum_opacities=True, anisotropic_cloud_scattering=None)#

JIT-compiled kernel for calculate_flux. See calculate_flux for parameter docs.

calculate_flux_autodiff(temperatures: jax.typing.ArrayLike, mass_fractions: dict[str, jax.typing.ArrayLike], mean_molar_masses: jax.typing.ArrayLike, reference_gravity: float, *, pressures: jax.typing.ArrayLike = None, cloud_parameters: dict[str, Any] | None = None, irradiation_geometry: str = 'dayside_ave', stellar_intensities: jax.typing.ArrayLike = None, star_irradiation_angle: float = 0.0, reflectances: jax.typing.ArrayLike = None, emissivities: jax.typing.ArrayLike = None, additional_absorption_opacities_function: Callable = None, additional_scattering_opacities_function: Callable = None, chunk_feautrier: bool = True, feautrier_chunk_size: int = 1536, frequencies_to_wavelengths: bool = True) tuple[jax.typing.ArrayLike, jax.typing.ArrayLike, dict[str, any]]#

Autodiff-oriented emission-spectrum API with grouped cloud controls.

The method uses the same pure JAX kernel as calculate_flux, but collapses the cloud-configuration surface into a single keyword argument and only accepts direct stellar intensities on the irradiation side.

Example:
>>> cloud_parameters = {
...     'cloud_f_sed': cloud_f_sed,
...     'eddy_diffusion_coefficients': eddy_diffusion_coefficients,
...     'cloud_particle_radius_distribution_std': 1.05,
... }
>>> _, flux, _ = atmosphere.calculate_flux_autodiff(
...     temperatures=temperatures,
...     mass_fractions=mass_fractions,
...     mean_molar_masses=mean_molar_masses,
...     reference_gravity=reference_gravity,
...     cloud_parameters=cloud_parameters,
...     frequencies_to_wavelengths=False,
... )
>>> temperature_gradient = jax.grad(
...     lambda t: jnp.sum(
...         atmosphere.calculate_flux_autodiff(
...             temperatures=t,
...             mass_fractions=mass_fractions,
...             mean_molar_masses=mean_molar_masses,
...             reference_gravity=reference_gravity,
...             cloud_parameters=cloud_parameters,
...             frequencies_to_wavelengths=False,
...         )[1]
...     )
... )(temperatures)
calculate_photosphere_radius(temperatures: jax.typing.ArrayLike, mean_molar_masses: jax.typing.ArrayLike, reference_gravity: float, planet_radius: float, opacities: jax.typing.ArrayLike, continuum_opacities_scattering: jax.typing.ArrayLike, cloud_f_sed: float, cloud_photosphere_median_optical_depth: float, cloud_anisotropic_scattering_opacities: jax.typing.ArrayLike, cloud_absorption_opacities: jax.typing.ArrayLike, optical_depths: jax.typing.ArrayLike = None, cloud_photosphere_wavelength_boundaries: jax.typing.ArrayLike = None, pressures: jax.typing.ArrayLike = None) jax.typing.ArrayLike#

Estimate the wavelength-dependent photosphere radius.

The photosphere radius is obtained by computing or reusing optical depths, locating the layer where the angle-averaged optical depth reaches $2/3$, and interpolating the hydrostatic radius profile to that pressure.

Args:
temperatures:

Atmospheric temperature profile in K.

mean_molar_masses:

Mean molecular mass profile in amu.

reference_gravity:

Reference gravity in cgs units.

planet_radius:

Radius in cm at the deepest atmospheric layer.

opacities:

Total opacity array used for the emission calculation.

continuum_opacities_scattering:

Continuum scattering opacity array.

cloud_f_sed:

Cloud settling parameter used when photospheric cloud scaling is active.

cloud_photosphere_median_optical_depth:

Optional target cloud optical depth near the photosphere.

cloud_anisotropic_scattering_opacities:

Cloud anisotropic scattering opacities.

cloud_absorption_opacities:

Cloud absorption opacities.

optical_depths:

Precomputed optical depths. If omitted, they are recomputed.

cloud_photosphere_wavelength_boundaries:

Optional wavelength bounds used for the photospheric cloud model.

Returns:

Photosphere radius on the internal frequency grid, in cm.

calculate_rosseland_planck_opacities(temperatures: numpy.typing.NDArray[float], mass_fractions: dict[str, numpy.typing.NDArray[float]], mean_molar_masses: numpy.typing.NDArray[float], reference_gravity: float, opaque_cloud_top_pressure: float = None, cloud_particle_mean_radii: dict[str, jax.typing.ArrayLike] = None, cloud_particle_radius_distribution_std: float | dict[str, jax.typing.ArrayLike] = None, cloud_particle_radius_distribution: str = 'lognormal', cloud_hansen_a: dict[str, jax.typing.ArrayLike] = None, cloud_hansen_b: dict[str, jax.typing.ArrayLike] = None, clouds_particle_porosity_factor: dict[str, float] = None, cloud_f_sed: float = None, eddy_diffusion_coefficients: float = None, haze_factor: float = 1.0, power_law_opacity_350nm: float = None, power_law_opacity_coefficient: float = None, gray_opacity: float = None) tuple[numpy.typing.NDArray[float], numpy.typing.NDArray[float], dict[str, any]]#

Method to calculate the atmosphere’s Rosseland and Planck mean opacities.

Args:
temperatures:

the atmospheric temperature in K, at each atmospheric layer (1-d numpy array, same length as pressure array).

mass_fractions:

dictionary of mass fractions for all atmospheric absorbers. Dictionary keys are the species names. Every mass fraction array has same length as pressure array.

mean_molar_masses:

the atmospheric mean molecular weight in amu, at each atmospheric layer (1-d numpy array, same length as pressure array).

reference_gravity (float):

Surface gravity in cgs. Vertically constant for emission spectra.

opaque_cloud_top_pressure (Optional[float]):

Pressure, in bar, where opaque cloud deck is added to the absorption opacity.

cloud_particle_mean_radii (Optional):

dictionary of mean particle radii for all cloud species. Dictionary keys are the cloud species names. Every radius array has same length as pressure array.

cloud_particle_radius_distribution_std:

Width of the log-normal cloud particle size distribution. May be a shared scalar or a per-species dictionary whose values are scalars or layer profiles.

cloud_particle_radius_distribution (Optional[string]):

The cloud particle size distribution to use. Can be either ‘lognormal’ (default) or ‘hansen’. If hansen, the cloud_hansen_b parameters must be used.

cloud_hansen_a (Optional[dict]):

A dictionary of the ‘a’ parameter values for each included cloud species and for each atmospheric layer, formatted as the kzz argument. Equivalent to radius arg. If cloud_hansen_a is not included and dist is “hansen”, then it will be computed using Kzz and fsed (recommended).

cloud_hansen_b (Optional[dict]):

A dictionary of the ‘b’ parameter values for each included cloud species and for each atmospheric layer, formatted as the kzz argument. This is the width of the hansen distribution normalized by the particle area (1/cloud_hansen_a^2)

clouds_particle_porosity_factor (Optional[dict]):

A dictionary containing the particle porosity factor for each cloud species.

cloud_f_sed (Optional[float]):

cloud settling parameter

eddy_diffusion_coefficients (Optional):

the atmospheric eddy diffusion coefficient in cgs (i.e. \(\rm cm^2/s\)), at each atmospheric layer (1-d numpy array, same length as pressure array).

haze_factor (Optional[float]):

Scalar factor, increasing the gas Rayleigh scattering cross-section.

power_law_opacity_350nm (Optional[float]):

Scattering opacity at 0.35 micron, in cgs units (cm^2/g).

power_law_opacity_coefficient (Optional[float]):

Has to be given if kappa_zero is defined, this is the wavelength powerlaw index of the parametrized scattering opacity.

gray_opacity (Optional[float]):

Gray opacity value, to be added to the opacity at all pressures and wavelengths (units \(\rm cm^2/g\))

calculate_transit_radii(temperatures: jax.typing.ArrayLike, mass_fractions: dict[str, jax.typing.ArrayLike], mean_molar_masses: jax.typing.ArrayLike, reference_gravity: float, reference_pressure: float, planet_radius: float, variable_gravity: bool = True, opaque_cloud_top_pressure: float = None, cloud_particle_mean_radii: dict[str, jax.typing.ArrayLike] = None, cloud_particle_radius_distribution_std: float | dict[str, jax.typing.ArrayLike] = None, cloud_particle_radius_distribution: str = 'lognormal', cloud_hansen_a: dict[str, jax.typing.ArrayLike] = None, cloud_hansen_b: dict[str, jax.typing.ArrayLike] = None, cloud_particle_number_density_grid: dict[str, jax.typing.ArrayLike] = None, clouds_particle_porosity_factor: dict[str, float] = None, cloud_f_sed: float = None, eddy_diffusion_coefficients: float = None, haze_factor: float = 1.0, power_law_opacity_350nm: float = None, power_law_opacity_coefficient: float = None, gray_opacity: float = None, cloud_fraction: float = 1.0, patchy_clouds: list[str] | tuple[str] = None, complete_coverage_clouds: list[str] = None, additional_absorption_opacities_function: Callable = None, additional_scattering_opacities_function: Callable = None, frequencies_to_wavelengths: bool = True, return_contribution: bool = False, return_clear_spectrum: bool = False, return_cloud_contribution: bool = False, return_radius_hydrostatic_equilibrium: bool = False, return_opacities: bool = False, return_abundances: bool = False, return_particle_radii_bins: bool = False, return_particle_radii: bool = False, return_particle_densities: bool = False, target_particle_radii: jax.typing.ArrayLike = None, pressures: jax.typing.ArrayLike = None, target_pressure: jax.typing.ArrayLike = None) tuple[jax.typing.ArrayLike, jax.typing.ArrayLike, dict[str, Any]]#

Method to calculate the atmosphere’s transmission radius (for the transmission spectrum).

Args:
temperatures:

the atmospheric temperature in K, at each atmospheric layer (1-d numpy array, same length as pressure array).

mass_fractions:

dictionary of mass fractions for all atmospheric absorbers. Dictionary keys are the species names. Every mass fraction array has same length as pressure array.

mean_molar_masses:

the atmospheric mean molecular weight in amu, at each atmospheric layer (1-d numpy array, same length as pressure array).

reference_gravity (float):

Surface gravity in cgs at reference radius and pressure.

reference_pressure (float):

Reference pressure P0 in bar where R(P=P0) = R_pl, where R_pl is the reference radius (parameter of this method), and g(P=P0) = gravity, where gravity is the reference gravity (parameter of this method)

planet_radius (float):

Reference radius R_pl, in cm.

variable_gravity (Optional[bool]):

Standard is True. If False the gravity will be constant as a function of pressure, during the transmission radius calculation.

opaque_cloud_top_pressure (Optional[float]):

Pressure, in bar, where opaque cloud deck is added to the absorption opacity.

cloud_particle_mean_radii (Optional):

dictionary of mean particle radii for all cloud species. Dictionary keys are the cloud species names. Every radius array has same length as pressure array.

cloud_particle_radius_distribution_std:

Width of the log-normal cloud particle size distribution. May be a shared scalar or a per-species dictionary whose values are scalars or layer profiles.

cloud_particle_radius_distribution (Optional[string]):

The cloud particle size distribution to use. Can be either ‘lognormal’ (default) or ‘hansen’. If hansen, the cloud_hansen_b parameters must be used.

cloud_hansen_a (Optional[dict]):

A dictionary of the ‘a’ parameter values for each included cloud species and for each atmospheric layer, formatted as the kzz argument. Equivalent to radius arg. If cloud_hansen_a is not included and dist is “hansen”, then it will be computed using Kzz and fsed (recommended).

cloud_hansen_b (Optional[dict]):

A dictionary of the ‘b’ parameter values for each included cloud species and for each atmospheric layer, formatted as the kzz argument. This is the width of the hansen distribution normalized by the particle area (1/cloud_hansen_a^2)

cloud_particle_number_density_grid (Optional[dict]):

EXPERIMENTAL

clouds_particle_porosity_factor (Optional[dict]):

A dictionary of porosity factors depending on the cloud species. This can be useful when opacities are calculated using the Distribution of Hollow Spheres (DHS) method.

cloud_f_sed (Optional[float]):

cloud settling parameter

eddy_diffusion_coefficients (Optional):

the atmospheric eddy diffusion coefficient in cgs (i.e. \(\rm cm^2/s\)), at each atmospheric layer (1-d numpy array, same length as pressure array).

haze_factor (Optional[float]):

Scalar factor, increasing the gas Rayleigh scattering cross-section.

power_law_opacity_350nm (Optional[float]):

Scattering opacity at 0.35 micron, in cgs units (cm^2/g).

power_law_opacity_coefficient (Optional[float]):

Has to be given if kappa_zero is defined, this is the wavelength powerlaw index of the parametrized scattering opacity.

gray_opacity (Optional[float]):

Gray opacity value, to be added to the opacity at all pressures and wavelengths (units \(\rm cm^2/g\))

cloud_fraction:

Mix a column without cloud with a column with cloud to the requested fraction (0 = clear, 1 = full cloud cover). Runtime-only cloud sources such as power-law clouds and opaque cloud decks follow the same mixing. By default, assume a full cloud cover.

patchy_clouds:

List of cloud species affected by cloud_fraction. Runtime-only cloud sources such as power-law clouds and opaque cloud decks are always mixed by cloud_fraction.

complete_coverage_clouds:

Deprecated alias for the complement of patchy_clouds.

additional_absorption_opacities_function (Optional[function]):

A python function that takes wavelength arrays in microns and pressure arrays in bars as input, and returns an absorption opacity matrix in units of cm^2/g, in the shape of number of wavelength points x number of pressure points. This opacity will then be added to the atmospheric absorption opacity. This must not be used to add atomic / molecular line opacities in low-resolution mode (c-k), because line opacities require a proper correlated-k treatment. It may be used to add simple cloud absorption laws, for example, which have opacities that vary only slowly with wavelength, such that the current model resolution is sufficient to resolve any variations.

additional_scattering_opacities_function (Optional[function]):

A python function that takes wavelength arrays in microns and pressure arrays in bars as input, and returns an isotropic scattering opacity matrix in units of cm^2/g, in the shape of number of wavelength points x number of pressure points. This opacity will then be added to the atmospheric absorption opacity. It may be used to add simple cloud absorption laws, for example, which have opacities that vary only slowly with wavelength, such that the current model resolution is sufficient to resolve any variations.

frequencies_to_wavelengths (Optional[bool]):

If True, convert the frequencies (Hz) output to wavelengths (cm).

return_contribution (Optional[bool]):

If True the transmission and emission contribution function is calculated.

return_clear_spectrum (Optional[bool]):

If True, return the clear spectrum in addition to a cloudy spectrum.

return_cloud_contribution (Optional[bool]):

If True, calculate and return the cloud contribution.

return_radius_hydrostatic_equilibrium (Optional[bool]):

If True, return the radius at hydrostatic equilibrium of the planet.

return_opacities (Optional[bool]):

If True, return the absorption opacities and scattering opacities.

return_abundances (Optional[bool]):

If True, return the mass fractions.

return_particle_radii_bins (Optional[bool]):

If True, return the particles radii bins.

return_particle_radii (Optional[bool]):

If True, return the particles radii.

return_particle_densities (Optional[bool]):

If True, return the particles densities.

target_particle_radii (Optional[ArrayLike]:

Particle radius to target for selective bin disabling. Radius bin closest the input value will be disabled.

target_pressure (Optional[ArrayLike]:

Pressure to target for selective bin disabling. Pressure bin closest to the input value will be disabled.

_calculate_transit_radii_full_kernel(temperatures, mass_fractions, mean_molar_masses, reference_gravity, reference_pressure, planet_radius, pressures=None, variable_gravity=True, opaque_cloud_top_pressure=None, cloud_particle_mean_radii=None, cloud_particle_radius_distribution_std=None, cloud_particle_radius_distribution='lognormal', cloud_hansen_a=None, cloud_hansen_b=None, cloud_particle_number_density_grid=None, clouds_particle_porosity_factor=None, cloud_f_sed=None, eddy_diffusion_coefficients=None, haze_factor=1.0, power_law_opacity_350nm=None, power_law_opacity_coefficient=None, gray_opacity=None, cloud_photosphere_median_optical_depth=None, cloud_fraction=1.0, patchy_clouds=None, additional_absorption_opacities_function=None, additional_scattering_opacities_function=None, frequencies_to_wavelengths=True, return_contribution=False, return_clear_spectrum=False, return_radius_hydrostatic_equilibrium=False, return_cloud_contribution=False, return_opacities=False, return_abundances=False, return_particle_radii_bins=False, return_particle_radii=False, return_particle_densities=False, target_particle_radii=None, target_pressure=None, sum_opacities=False, anisotropic_cloud_scattering=None)#

JIT-compiled kernel for calculate_transit_radii. See calculate_transit_radii for parameter docs.

calculate_transit_radii_autodiff(temperatures: jax.typing.ArrayLike, mass_fractions: dict[str, jax.typing.ArrayLike], mean_molar_masses: jax.typing.ArrayLike, reference_gravity: float, reference_pressure: float, planet_radius: float, *, pressures: jax.typing.ArrayLike = None, variable_gravity: bool = True, cloud_parameters: dict[str, Any] | None = None, additional_absorption_opacities_function: Callable = None, additional_scattering_opacities_function: Callable = None, frequencies_to_wavelengths: bool = True) tuple[jax.typing.ArrayLike, jax.typing.ArrayLike, dict[str, Any]]#

Autodiff-oriented transmission-spectrum API with grouped cloud controls.

The method mirrors calculate_transit_radii while collapsing cloud controls into a single keyword argument and keeping the differentiated call surface small.

Example:
>>> cloud_parameters = {
...     'cloud_f_sed': cloud_f_sed,
...     'eddy_diffusion_coefficients': eddy_diffusion_coefficients,
...     'cloud_particle_radius_distribution_std': 1.05,
... }
>>> _, transit_radii, _ = atmosphere.calculate_transit_radii_autodiff(
...     temperatures=temperatures,
...     mass_fractions=mass_fractions,
...     mean_molar_masses=mean_molar_masses,
...     reference_gravity=reference_gravity,
...     reference_pressure=reference_pressure,
...     planet_radius=planet_radius,
...     cloud_parameters=cloud_parameters,
...     frequencies_to_wavelengths=False,
... )
>>> temperature_gradient = jax.grad(
...     lambda t: jnp.sum(
...         atmosphere.calculate_transit_radii_autodiff(
...             temperatures=t,
...             mass_fractions=mass_fractions,
...             mean_molar_masses=mean_molar_masses,
...             reference_gravity=reference_gravity,
...             reference_pressure=reference_pressure,
...             planet_radius=planet_radius,
...             cloud_parameters=cloud_parameters,
...             frequencies_to_wavelengths=False,
...         )[1]
...     )
... )(temperatures)
get_wavelengths()#

Convert the frequency grid into wavelengths in centimeter.

load_all_opacities()#
load_cia_opacities(path_input_data)#
load_cloud_opacities(path_input_data)#

Load the cloud opacities.

Args:

path_input_data: path to petitRADTRANS input_data directory

classmethod load_hdf5_ktables(file_path_hdf5, frequencies, g_size, temperature_pressure_grid_size, return_radtrans_opacities=True, return_host_array=False)#

Load k-coefficient tables in HDF5 format, based on the ExoMol setup.

load_line_opacities(path_input_data)#

Load the line opacities for spectral calculation. The default pressure-temperature grid is a log-uniform (10, 13) grid.

Args:

path_input_data: path to petitRADTRANS input_data directory