petitRADTRANS¶

Package Contents¶

Classes¶

 Radtrans Class defining objects for carrying out spectral calculations for a

Attributes¶

class petitRADTRANS.Radtrans(line_species=None, rayleigh_species=None, cloud_species=None, continuum_opacities=None, wlen_bords_micron=None, mode='c-k', test_ck_shuffle_comp=False, do_scat_emis=False, lbl_opacity_sampling=None, pressures=None, temperatures=None, stellar_intensity=None, geometry='dayside_ave', mu_star=1.0, semimajoraxis=None, hack_cloud_photospheric_tau=None, path_input_data=os.environ.get('pRT_input_data_path'))

Class defining objects for carrying out spectral calculations for a given set of opacities

Args:
line_species (Optional):

list of strings, denoting which line 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.

continuum_opacities (Optional):

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

wlen_bords_micron (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.

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.

do_scat_emis (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!

lbl_opacity_sampling (Optional[int]):

Will be None by default. If integer positive value, and if mode == 'lbl' is True, then this will only consider every lbl_opacity_sampling-nth point of the high-resolution opacities. This may be desired in the case where medium-resolution spectra are required with a $$\\lambda/\\Delta \\lambda > 1000$$, but much smaller than $$10^6$$, which is the resolution of the lbl mode. In this case it may make sense to carry out the calculations with lbl_opacity_sampling = 10, for example, and then rebinning to the final desired resolution: this may save time! The user should verify whether this leads to solutions which are identical to the rebinned results of the fiducial $$10^6$$ resolution. If not, this parameter must not be used.

_check_cloud_effect(mass_mixing_ratios)

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

Args:

mass_mixing_ratios: atmospheric mass mixing ratios

Returns:

_init_line_opacities_parameters()
_init_pressure_dependent_parameters(pressures)

Setup opacity arrays at atmospheric structure dimensions, and set the atmospheric pressure array.

Args:
pressures:

the atmospheric pressure (1-d numpy array, sorted in increasing order), in units of bar. Will be converted to cgs internally.

static calc_borders(x)
setup_opa_structure(P)

Setup opacity arrays at atmospheric structure dimensions, and set the atmospheric pressure array.

Args:
P:

the atmospheric pressure (1-d numpy array, sorted in increasing order), in units of bar. Will be converted to cgs internally.

interpolate_species_opa(temp)
interpolate_cia(key, mfrac)
mix_opa_tot(abundances, mmw, gravity, sigma_lnorm=None, fsed=None, Kzz=None, radius=None, add_cloud_scat_as_abs=None, dist='lognormal', a_hans=None, b_hans=None, give_absorption_opacity=None, give_scattering_opacity=None)
calc_opt_depth(gravity, cloud_wlen=None)
calc_RT(contribution)

Calculate the flux.

calc_tr_rad(P0_bar, R_pl, gravity, mmw, contribution, variable_gravity)
calc_flux(temp, abunds, gravity, mmw, R_pl=None, sigma_lnorm=None, fsed=None, Kzz=None, radius=None, contribution=False, gray_opacity=None, Pcloud=None, kappa_zero=None, gamma_scat=None, add_cloud_scat_as_abs=None, Tstar=None, Rstar=None, semimajoraxis=None, geometry='dayside_ave', theta_star=0, hack_cloud_photospheric_tau=None, dist='lognormal', a_hans=None, b_hans=None, stellar_intensity=None, give_absorption_opacity=None, give_scattering_opacity=None, cloud_wlen=None)

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

Args:
temp:

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

abunds:

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

gravity (float):

Surface gravity in cgs. Vertically constant for emission spectra.

mmw:

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

R_pl: planet radius at maximum pressure in cm. If specified, the planet’s changing photospheric radius

as function of wavelength will be calculated and saved in the self.phot_radius attribute (in cm).

sigma_lnorm (Optional[float]):

width of the log-normal cloud particle size distribution

fsed (Optional[float]):

cloud settling parameter

Kzz (Optional):

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

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.

contribution (Optional[bool]):

If True the emission contribution function will be calculated. Default is False.

gray_opacity (Optional[float]):

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

Pcloud (Optional[float]):

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

kappa_zero (Optional[float]):

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

gamma_scat (Optional[float]):

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

If True, 20 % of the cloud scattering opacity will be added to the absorption opacity, introduced to test for the effect of neglecting scattering.

Tstar (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.

Rstar (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.

semimajoraxis (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.

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.

theta_star (Optional[float]):

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

hack_cloud_photospheric_tau (Optional[float]):

Median optical depth (across wlen_bords_micron) 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.

dist (Optional[string]):

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

a_hans (Optional[dict]):

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

b_hans (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/a_hans^2)

give_absorption_opacity (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.

stellar_intensity (Optional[array]):

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

give_scattering_opacity (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.

cloud_wlen (Optional[Tuple[float, float]]):

Tuple with the wavelength range (in micron) that is used for calculating the median optical depth of the clouds at gas-only photosphere and then scaling the cloud optical depth to the value of hack_cloud_photospheric_tau. The range of cloud_wlen should be encompassed by wlen_bords_micron. The full wavelength range is used when cloud_wlen=None.

get_star_spectrum(Tstar, distance, Rstar=None)

Method to get the PHOENIX spectrum of the star and rebin it to the wavelength points. If Tstar is not explicitly written, the spectrum will be 0. If the distance is not explicitly written, the code will raise an error and break to urge the user to specify the value.

Args:
Tstar (float):

the stellar temperature in K.

distance (float):

the semi-major axis of the planet in cm.

Rstar (float):

if specified, uses this radius in cm to scale the flux, otherwise it uses PHOENIX radius.

calc_transm(temp, abunds, gravity, mmw, P0_bar, R_pl, sigma_lnorm=None, fsed=None, Kzz=None, radius=None, Pcloud=None, kappa_zero=None, gamma_scat=None, contribution=False, haze_factor=None, gray_opacity=None, variable_gravity=True, dist='lognormal', b_hans=None, a_hans=None, give_absorption_opacity=None, give_scattering_opacity=None)

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

Args:
temp:

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

abunds:

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

gravity (float):

Surface gravity in cgs at reference radius and pressure.

mmw:

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

P0_bar (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)

R_pl (float):

sigma_lnorm (Optional[float]):

width of the log-normal cloud particle size distribution

fsed (Optional[float]):

cloud settling parameter

Kzz (Optional):

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

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.

contribution (Optional[bool]):

If True the transmission and emission contribution function will be calculated. Default is False.

gray_opacity (Optional[float]):

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

Pcloud (Optional[float]):

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

kappa_zero (Optional[float]):

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

gamma_scat (Optional[float]):

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

haze_factor (Optional[float]):

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

variable_gravity (Optional[bool]):

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

dist (Optional[string]):

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

a_hans (Optional[dict]):

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

b_hans (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/a_hans^2)

give_absorption_opacity (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.

give_scattering_opacity (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.

calc_flux_transm(temp, abunds, gravity, mmw, P0_bar, R_pl, sigma_lnorm=None, fsed=None, Kzz=None, radius=None, Pcloud=None, kappa_zero=None, gamma_scat=None, contribution=False, gray_opacity=None, add_cloud_scat_as_abs=None, variable_gravity=True, dist='lognormal', b_hans=None, a_hans=None, give_absorption_opacity=None, give_scattering_opacity=None)

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

Args:
temp:

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

abunds:

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

gravity (float):

Surface gravity in cgs at reference radius and pressure, constant durng the emission spectrum calculation.

mmw:

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

P0_bar (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)

R_pl (float):

sigma_lnorm (Optional[float]):

width of the log-normal cloud particle size distribution

fsed (Optional[float]):

cloud settling parameter

Kzz (Optional):

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

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.

contribution (Optional[bool]):

If True the transmission contribution function will be calculated. Default is False.

gray_opacity (Optional[float]):

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

Pcloud (Optional[float]):

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

kappa_zero (Optional[float]):

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

gamma_scat (Optional[float]):

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

If True, 20 % of the cloud scattering opacity will be added to the absorption opacity, introduced to test for the effect of neglecting scattering.

variable_gravity (Optional[bool]):

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

dist (Optional[string]):

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

a_hans (Optional[dict]):

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

b_hans (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/a_hans^2)

give_absorption_opacity (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.

give_scattering_opacity (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.

calc_rosse_planck(temp, abunds, gravity, mmw, sigma_lnorm=None, fsed=None, Kzz=None, radius=None, contribution=False, gray_opacity=None, Pcloud=None, kappa_zero=None, gamma_scat=None, haze_factor=None, add_cloud_scat_as_abs=None, dist='lognormal', b_hans=None, a_hans=None)

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

Args:
temp:

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

abunds:

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

gravity (float):

Surface gravity in cgs. Vertically constant for emission spectra.

mmw:

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

sigma_lnorm (Optional[float]):

width of the log-normal cloud particle size distribution

fsed (Optional[float]):

cloud settling parameter

Kzz (Optional):

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

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.

contribution (Optional[bool]):

If True the emission contribution function will be calculated. Default is False.

gray_opacity (Optional[float]):

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

Pcloud (Optional[float]):

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

kappa_zero (Optional[float]):

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

gamma_scat (Optional[float]):

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

haze_factor (Optional[float]):

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

If True, 20 % of the cloud scattering opacity will be added to the absorption opacity, introduced to test for the effect of neglecting scattering.

dist (Optional[string]):

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

a_hans (Optional[dict]):

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

b_hans (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/a_hans^2)

get_opa(temp)

Method to calculate and return the line opacities (assuming an abundance of 100 % for the inidividual species) of the Radtrans object. This method updates the line_struc_kappas attribute within the Radtrans class. For the low resolution (c-k) mode, the wavelength-mean within every frequency bin is returned.

Args:
temp:

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

Returns:
• wavelength in cm (1-d numpy array)

• dictionary of opacities, keys are the names of the line_species dictionary, entries are 2-d numpy arrays, with the shape being (number of frequencies, number of atmospheric layers). Units are cm^2/g, assuming an absorber abundance of 100 % for all respective species.

plot_opas(species, temperature, pressure_bar, mass_fraction=None, CO=0.55, FeH=0.0, **kwargs)
calc_tau_cloud(gravity)

Method to calculate the optical depth of the clouds as function of frequency and pressure. The array with the optical depths is set to the tau_cloud attribute. The optical depth is calculated from the top of the atmosphere (i.e. the smallest pressure). Therefore, below the cloud base, the optical depth is constant and equal to the value at the cloud base.

Args:
gravity (float):

Surface gravity in cgs. Vertically constant for emission spectra.

write_out_rebin(resolution, path='', species=None, masses=None)
calc_radius_hydrostatic_equilibrium(temperatures, MMWs, gravity, P0, R_pl, variable_gravity=True, pressures=None)
calc_pressure_hydrostatic_equilibrium(MMW, gravity, R_pl, P0, temperature, radii, rk4=True)