petitRADTRANS.radtrans

Module Contents

Classes

Radtrans

Class defining objects for carrying out spectral calculations for a

Functions

py_calc_cloud_opas(rho, rho_p, cloud_mass_fracs, r_g, sigma_n, cloud_rad_bins, cloud_radii, cloud_lambdas, cloud_specs_abs_opa, cloud_specs_scat_opa, cloud_aniso)

This function reimplements calc_cloud_opas from fort_spec.f90. For some reason

class petitRADTRANS.radtrans.Radtrans(line_species=[], rayleigh_species=[], cloud_species=[], continuum_opacities=[], H2H2CIA=False, H2HeCIA=False, N2N2CIA=False, CO2CO2CIA=False, O2O2CIA=False, N2O2CIA=False, wlen_bords_micron=[0.05, 300.0], mode='c-k', test_ck_shuffle_comp=False, do_scat_emis=False, lbl_opacity_sampling=None)

Bases: petitRADTRANS._read_opacities.ReadOpacities

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_species (Optional):

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

H2H2CIA (Optional[bool]):

Will be False by default. If True, will add H2-H2 Collision induced absoprtion as continuum absorber (alternatively, put 'H2-H2' into continuum_species list).

H2HeCIA (Optional[bool]):

Will be False by default. If True, will add H2-He Collision induced absoprtion as continuum absorber (alternatively, put 'H2-He' into continuum_species list).

N2N2CIA (Optional[bool]):

Will be False by default. If True, will add N2-N2 Collision induced absoprtion as continuum absorber (alternatively, put 'N2-N2' into continuum_species list).

O2O2CIA (Optional[bool]):

Will be False by default. If True, will add O2-O2 Collision induced absoprtion as continuum absorber (alternatively, put 'O2-O2' into continuum_species list).

N2O2CIA (Optional[bool]):

Will be False by default. If True, will add N2-O2 Collision induced absoprtion as continuum absorber (alternatively, put 'N2-O2' into continuum_species list).

CO2CO2CIA (Optional[bool]):

Will be False by default. If True, will add CO2-CO2 Collision induced absoprtion as continuum absorber (alternatively, put 'CO2-CO2' into continuum_species list).

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.

calc_borders(self, x)
setup_opa_structure(self, 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(self, temp)
interpolate_cia(self, CIA_cpair_lambda, CIA_cpair_temp, CIA_cpair_alpha_grid, mfrac, mu_part)
mix_opa_tot(self, 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)
calc_cloud_opacity(self, abundances, mmw, gravity, sigma_lnorm, fsed=None, Kzz=None, radius=None, add_cloud_scat_as_abs=None, dist='lognormal', a_hans=None, b_hans=None)
add_rayleigh(self, abundances)
calc_opt_depth(self, gravity)
calc_RT(self, contribution)
calc_tr_rad(self, P0_bar, R_pl, gravity, mmw, contribution, variable_gravity)
calc_flux(self, 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, 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)

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).

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).

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

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.

add_cloud_scat_as_abs (Optional[bool]):

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 Solar radii. 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.

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_star_spectrum(self, Tstar, distance, Rstar)

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 AU.

Radius (float):

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

calc_transm(self, 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)

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):

Reference radius R_pl, 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).

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

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.

add_cloud_scat_as_abs (Optional[bool]):

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)

calc_flux_transm(self, 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)

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):

Reference radius R_pl, 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).

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

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.

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)

calc_rosse_planck(self, 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).

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

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.

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(self, 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(self, species, temperature, pressure_bar, mass_fraction=None, CO=0.55, FeH=0.0, **kwargs)
calc_tau_cloud(self, 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 calculate 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(self, resolution, path='', species=[], masses=None)
petitRADTRANS.radtrans.py_calc_cloud_opas(rho, rho_p, cloud_mass_fracs, r_g, sigma_n, cloud_rad_bins, cloud_radii, cloud_lambdas, cloud_specs_abs_opa, cloud_specs_scat_opa, cloud_aniso)

This function reimplements calc_cloud_opas from fort_spec.f90. For some reason it runs faster in python than in fortran, so we’ll use this from now on. This function integrates the cloud opacity throught the different layers of the atmosphere to get the total optical depth, scattering and anisotropic fraction.

See the fortran implementation for details of the input arrays.