@author: jeremy leconte

Module Contents

class Gas_mix(composition={}, bg_gas=None, logp_array=None, t_array=None, k_database=None, cia_database=None)[source]

Bases: exo_k.util.spectral_object.Spectral_object

Dict-like class to handle gas composition (with background gas) and molar mass.

If logp_array, t_array, and radiative databases are provided, cross_section can be used to compute the opacity of the gas

__init_ Instantiates a Gas_mix object and computes the vmr of the ‘background’ gas.

set_composition(self, composition, bg_gas=None)[source]

Reset composition and computes the vmr of the ‘background’ gas.

  • composition (dict) – Keys are molecule names. Values are vmr or arrays of vmr.

  • bg_gas (str) – Name of the background molecule. If None, it is inferred from the molecule for which vmr=’background’.

set_logPT(self, logp_array=None, t_array=None)[source]

Sets the pressure (in Pa) and temperature fields.


Computes the volume mixing ratio of the background gas in a mix Uses the fact that self.composition is a dictionary with the name of the molecules as keys and the vmr as values. vmr are either float or arrays.

At this stage, the background gas should be identified by self.bg_gas, and its Vol. Mix. Ratio will be updated in the composition dict.


Computes and returns the molar mass of a mix of gases


Molar mass of the active gases in kg/mol

Return type

float or array

get_vmr_array(self, sh=None)[source]

Returns a dictionary with an array of vol. mix. ratios for each species.


sh (set or list) – shape of the array wanted if all the vmr are floats. If some are already arrays, check whether the shape is the correct one.


  • res (dict) – A dictionary with the an array of vmr per species.

  • cst_array (boolean) – Is True if all the values in the arrays are constant.

set_k_database(self, k_database=None)[source]

Change the radiative database attached to the current instance of Gas_mix


k_database (Kdatabase object) – New Kdatabase to use.

set_cia_database(self, cia_database=None)[source]

Changes the CIA database attached to the current instance of Gas_mix


cia_database (CIAdatabase object) – New CIAdatabase to use.

set_spectral_range(self, wn_range=None, wl_range=None)[source]

Sets the default spectral range in which computations will be done by specifying either the wavenumber or the wavelength range.

  • wn_range (list or array of size 2) – Minimum and maximum wavenumber (in cm^-1).

  • wl_range (list or array of size 2) – Minimum and maximum wavelength (in micron)

cross_section(self, composition=None, logp_array=None, t_array=None, wl_range=None, wn_range=None, rayleigh=True, write=0, random_overlap=False, logp_interp=True, **kwargs)[source]

Computes the cross section (m^2/total number of molecule) for the mix at each of the logPT points as a function of wavenumber (and possibly g point).

  • wl_range (array or list of two values, optional) – Wavelength range to cover.

  • wn_range (array or list of two values, optional) – Wavenumber range to cover.

  • rayleigh (boolean, optional) – Whether to compute rayleigh scattering.

  • random_overlap (boolean, optional) – Whether Ktable opacities are added linearly (False), or using random overlap method (True).


kdata_array – Cross section array of shape (layer number, Nw (, Ng if corrk)).

Return type


After every computation, the following variables are updated to account for any possible change in spectral range:

  • self.Nw, Number of wavenumber bins

  • self.wns, Wavenumber array

  • self.wnedges, Wavenumber of the edges of the bins


Emulates dict.items() method


Emulates dict.values() method


Emulates dict.keys() method


Deep copy of the dict and arrays. The databases are not deep copied.

abstract mix_with(self, other_gas, vmr_other_gas)[source]

Mix with other Gas_mix.