exo_k.gas_mix

@author: jeremy leconte

Module Contents

class exo_k.gas_mix.Gas_mix(composition=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.

Narray = None
_wn_range = None
iw_min = None
iw_max = None
need_to_recompute_vmr_array = True
set_composition(composition)[source]

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

Parameters:
  • 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(logp_array=None, t_array=None)[source]

Sets the pressure (in Pa) and temperature fields.

get_background_vmr()[source]

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.

normalize()[source]

Renormalizes the vmr of all the gases so that the total be equal to 1.

This works only if the vmr of ‘inactive_gas’ is not 0.

molar_mass()[source]

Computes and returns the molar mass of a mix of gases

Returns:

float or array:

Molar mass of the active gases in kg/mol

cp()[source]

Computes and returns the specific heat capacity (cp) of a mix of gases

Returns:

float or array:

Specific cp of the gas mix

get_vmr_array(sh=None)[source]

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

Parameters:

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.

Returns:

vmr_array: 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.

get_q_array(sh=None)[source]

Returns a dictionary with an array of specific concentrations for each species.

Parameters:

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.

Returns:

q_array: dict

A dictionary with the an array of specific concentration per species.

cst_array: boolean

Is True if all the values in the arrays are constant.

get_vmr_array_basic_molecules(sh=None)[source]

Returns a dictionary with an array of vol. mix. ratios for each and decomposes gas mixtures into basic molecules.

Returns:

vmr_array_basic_mol: dictionary of arrays

A dictionary with the an array of vmr per species. Each species is considered a basic molecule.

vmr_array: dictionary of arrays

A dictionary with the an array of vmr per species. Species in this dictionary can be a gas mixture.

cst_array: boolean

Is True if all the values in the arrays are constant.

set_k_database(k_database=None)[source]

Change the radiative database attached to the current instance of Gas_mix

Parameters:

k_database (Kdatabase object) – New Kdatabase to use.

set_cia_database(cia_database=None)[source]

Changes the CIA database attached to the current instance of Gas_mix

Parameters:

cia_database (CIAdatabase object) – New CIAdatabase to use.

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

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

_compute_wn_range_indices(wn_range=None)[source]

Compute the starting and ending indices to be used for current wn_range

cross_section(composition=None, logp_array=None, t_array=None, wl_range=None, wn_range=None, rayleigh=True, write=0, random_overlap=False, logp_interp=True, use_basic_molecules=False, inactive_molecules=None, **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).

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

  • wn_range (array, np.ndarray 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).

Returns:

  • kdata_array: array, np.ndarray

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

  • 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

rosseland_mean_opacity(per_unit_mass=True, **kwargs)[source]

Computes Rosseland mean opacities in area per unit of mass of matter.

The unit for area is determined by the data used. In MKS,it will be m^2.

planck_mean_opacity(t_blackbody, per_unit_mass=True, **kwargs)[source]

Computes Plank mean opacities in area per unit of mass of matter.

The unit for area is determined by the data used. In MKS,it will be m^2.

items()[source]

Emulates dict.items() method

values()[source]

Emulates dict.values() method

keys()[source]

Emulates dict.keys() method

copy()[source]

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

abstract mix_with(other_gas, vmr_other_gas)[source]

Mix with other Gas_mix.

class exo_k.gas_mix.Known_composite_species[source]

Bases: exo_k.util.singleton.Singleton

A class to store composite gas mixes that can be used in other gas mixes This class can also store the molar mass of custom gases with arbitrary names (for example: My_gas, earth_background).

init(*args, **kwds)[source]

Initializes empty dictionary of custom molecular masses.

add_species(species_dict)[source]

Add one or several composite species to the database.

Parameters:

species_dict (dict) – Keys are gases names (they do not have to be real molecules). Values are a gas_mix object.

items()[source]

Emulates dict.items() method

values()[source]

Emulates dict.values() method

keys()[source]

Emulates dict.keys() method