Chemistry Models (taurex.chemistry)

Base

Base chemical profile class.

class Chemistry(name: str)[source]

Bases: Fittable, Loggable, Writeable, Citable

Skeleton for defining chemistry. Abstract Class

Must implement methods:

Active are those that are actively absorbing in the atmosphere. In technical terms they are molecules that have absorption cross-sections. You can see which molecules are able to actively absorb by doing: You can find out what molecules can actively absorb by doing:

>>> avail_active_mols = OpacityCache().find_list_of_molecules()

Active gases are only determined at initialization and cannot be changed during runtime. If you want to change the active gases you will need to reinitialize the chemistry class.

property activeGasMixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mix profile of actively absorbing gases. Requires implementation

Should return profiles of shape (nactivegases,nlayers). Active refers to gases that are actively absorbing in the atmosphere. Another way to put it these are gases where molecular cross-sections are used.

property activeGases: List[str]

Actively absorbing gases.

Requires implementation

Should return a list of molecule names

Returns:

active – List of active gases

Return type:

list

property availableActive: List[str]

Returns a list of available actively absorbing molecules.

Returns:

molecules – Actively absorbing molecules

Return type:

list

compute_mu_profile(nlayers: int | None = None) None[source]

Computes molecular weight of atmosphere for each layer

Parameters:

nlayers (int) – Number of layers, deprecated

property condensateMixProfile: ndarray[tuple[int, ...], dtype[float64]]

Get condensate mix profile. Requires implementation

Should return profiles of shape (ncondensates,nlayers).

property condensates: List[str]

Returns a list of condensates in the atmosphere.

Returns:

active – List of condensates

Return type:

list

property gases: List[str]

Total list of gases in atmosphere

get_condensate_mix_profile(condensate_name: str) ndarray[tuple[int, ...], dtype[float64]][source]

Returns the mix profile of a particular condensate.

Parameters:

condensate_name (str) – Name of condensate

Returns:

mixprofile – Mix profile of condensate with shape (nlayer)

Return type:

array

get_gas_mix_profile(gas_name: str) ndarray[tuple[int, ...], dtype[float64]][source]

Returns the mix profile of a particular gas

Parameters:

gas_name (str) – Name of gas

Returns:

mixprofile – Mix profile of gas with shape (nlayer)

Return type:

array

get_molecular_mass(molecule: str) float[source]

Returns the molecular mass of a molecule.

property hasCondensates: bool

Returns True if there are condensates in the atmosphere.

property inactiveGasMixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mixing profile of non absorbing gases.

Requires implementation

Should return profiles of shape (ninactivegases,nlayers).

property inactiveGases: List[str]

Non absorbing gases. Requires implementation

Should return a list of molecule names

Returns:

inactive – List of inactive gases

Return type:

list

initialize_chemistry(nlayers: int, temperature_profile: ndarray[tuple[int, ...], dtype[float64]], pressure_profile: ndarray[tuple[int, ...], dtype[float64]], altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]

Initialize the profile.

Parameters:
  • nlayers (int) – number of layers

  • temperature_profile (np.ndarray) – temperature profile

  • pressure_profile (np.ndarray) – pressure profile

  • altitude_profile (np.ndarray , optional) – altitude profile, deprecated

classmethod input_keywords() Tuple[str, ...][source]

Input keywords for chemistry class.

property mixProfile: ndarray[tuple[int, ...], dtype[float64]]
property mu: float

Mean molecular weight at surface (amu).

property muProfile: ndarray[tuple[int, ...], dtype[float64]]

Molecular weight for each layer of atmosphere in kg

Returns:

mix_profile

Return type:

array

set_star_planet(star: Star, planet: Planet)[source]

Supplies the star and planet to chemistryfor photochemistry reasons.

Does nothing by default

Parameters:
  • star (Star) – A star object

  • planet (Planet) – A planet object

write(output: OutputGroup) OutputGroup[source]

Writes chemistry class and arguments to file.

Parameters:

output (Output)

Base (Auto)

Chemistry that automatically seperates out active and inactive gases.

class AutoChemistry(name)[source]

Bases: Chemistry

Chemistry class that automatically seperates out active and inactive gases

Has a helper function that should be called at the end of initialization. determine_active_inactive() once gases() has been set.

You’ll only need to implement gases() and mixProfile() to use this class.

property activeGasMixProfile: ndarray[tuple[int, ...], dtype[float64]] | None

Active gas layer by layer mix profile

Returns:

active_mix_profile – Active gas mix profile with shape (nactive, nlayer)

Return type:

array

property activeGases: ndarray[tuple[int, ...], dtype[float64]]

Actively absorbing gases.

compute_mu_profile(nlayers: int | None = None) None[source]

Computes molecular weight of atmosphere for each layer

Parameters:

nlayers (int) – Number of layers, deprecated

determine_active_inactive() None[source]

Determines active and inactive gases.

property gases: List[str]

List of gases in atmosphere.

property inactiveGasMixProfile: ndarray[tuple[int, ...], dtype[float64]] | None

Inactive gas layer by layer mix profile.

Returns:

inactive_mix_profile

Return type:

array

property inactiveGases: ndarray[tuple[int, ...], dtype[float64]]

Non absorbing gases.

property mixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mix profile of gases.

Equilibrium Chemistry (ACE)

Warning

This is no longer available in the base TauREx 3 since version 3.1. To use this you must install the acepython plugin.

Free chemistry

Main free chemistry model.

exception InvalidChemistryException[source]

Bases: InvalidModelException

Called when atmosphere mix is greater than unity.

class TaurexChemistry(fill_gases: List[str] | None = None, ratio: float | List[float] = 0.17567, derived_ratios: List[str] | None = None, base_metallicity: float = 0.013)[source]

Bases: AutoChemistry

The standard chemical model used in Taurex.

This allows for the combinationof different mixing profiles for each molecule. Lets take an example profile, we want an atmosphere with a constant mixing of H2O but two layer mixing for CH4. First we initialize our chemical model:

>>> chemistry = TaurexChemistry()

Then we can add our molecules using the addGas() method. Lets start with H2O, since its a constant profile for all layers of the atmosphere we thus add the ConstantGas object:

>>> chemistry.addGas(ConstantGas('H2O',mix_ratio = 1e-4))

Easy right? Now the same goes for CH4, we can add the molecule into the chemical model by using the correct profile (in this case TwoLayerGas):

>>> chemistry.addGas(TwoLayerGas('CH4',mix_ratio_surface=1e-4,
                                 mix_ratio_top=1e-8))

Chaining is also supported:

>>> chemistry.addGas(gas1).addGas(gas2)
Molecular profiles available are:
addGas(gas: Gas) TaurexChemistry[source]

Adds a gas in the atmosphere.

Parameters:

gas (Gas) – Gas to add into the atmosphere. Only takes effect on next initialization call.

citations()[source]

Collect and return citations from all gases.

compute_elements_mix() Dict[str, ndarray[tuple[int, ...], dtype[float64]]][source]

Determines the elemental mix of the atmosphere.

fill_atmosphere(mixratio_remainder: float) List[float][source]

Fills the atmosphere with the fill gases.

fitting_parameters() Dict[str, Tuple[str, str, Callable[[], float], Callable[[float], None], Literal['linear', 'log'], bool, Tuple[float, float]]][source]

Overrides the fitting parameters to return one with all the gas profile parameters as well

Returns:

Dictionary of fitting parameters

Return type:

fit_param

property gases: List[str]

List of gases in the atmosphere.

get_element_ratio(elem_ratio: str) ndarray[tuple[int, ...], dtype[float64]][source]

Get element ratio of atmosphere.

Parameters:

elem_ratio (str) – Element ratio to compute of form elem1/elem2

Returns:

Element ratio

Return type:

float

get_metallicity() float[source]

Metallicity of the atmosphere.

Determines metallicity of the atmosphere by computing the elemental mix of the atmosphere and then determining the metallicity by the following formula:

\[Z = 1 - M_{H} - M_{He}\]

where \(M_{H}\) is the mass fraction of hydrogen and \(M_{He}\) is the mass fraction of helium.

Return type:

float

initialize_chemistry(nlayers: int, temperature_profile: ndarray[tuple[int, ...], dtype[float64]], pressure_profile: ndarray[tuple[int, ...], dtype[float64]], altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]

Initialize the chemistry.

Parameters:
  • nlayers (int) – number of layers

  • temperature_profile (np.ndarray) – temperature profile

  • pressure_profile (np.ndarray) – pressure profile

  • altitude_profile (np.ndarray , optional) – altitude profile, deprecated

classmethod input_keywords() Tuple[str, ...][source]

Input keywords for free chemistry.

isActive(gas: str) bool[source]

Determines if the gas is absorbing.

Parameters:

gas (str) – Name of molecule

Returns:

True if active

Return type:

bool

property metallicity: float

Metallicity of the atmosphere.

property mixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mixing profile of all gases.

setup_derived_params(ratio_list: List[str]) None[source]

Generate derived parameters.

setup_fill_params() None[source]

Generate fill gas parameters.

write(output: OutputGroup) OutputGroup[source]

Write chemistry to output group.

Gas Models (taurex.chemistry)

Base

Base Gas class.

class Gas(name: str, molecule_name: str)[source]

Bases: Fittable, Loggable, Writeable, Citable

This class is a base for a single molecule or gas. Its used to describe how it mixes at each layer and combined with TaurexChemistry is used to build a chemical profile of the planets atmosphere. Requires implementation of:

  • func:~mixProfile

initialize_profile(nlayers: int | None = None, temperature_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, pressure_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]

Initializes and computes mix profile.

Parameters:
  • nlayers (int) – Number of layers in atmosphere

  • temperature_profile (array) – Temperature profile of atmosphere in K. Length must be equal to nlayers

  • pressure_profile (array) – Pressure profile of atmosphere in Pa. Length must be equal to nlayers

  • altitude_profile (array) – Altitude profile of atmosphere in m. Length must be equal to nlayers

property mixProfile: ndarray[tuple[int, ...], dtype[float64]]

Return mix profile for each layer. Requires implementation

Should return mix profile of molecule/gas at each layer

Returns:

mix – Mix ratio for molecule at each layer

Return type:

array

property molecule: str

returns: molecule_name – Name of molecule :rtype: str

write(output: OutputGroup) OutputGroup[source]

Writes class and arguments to file

Parameters:

output (Output)

Constant

Constant gas profile.

class ConstantGas(molecule_name: str | None = 'H2O', mix_ratio: float | None = 1e-05)[source]

Bases: Gas

Constant gas profile.

Molecular abundace is constant at each layer of the atmosphere

add_active_gas_param() None[source]

Add the mixing ratio as a fitting parameter.

Fitting parameter identifier is the molecule name. Generates a fitting parameter on the fly by building getter and setter functions and passing them to taurex.fitting.fittable.Fittable.add_fittable_param()

initialize_profile(nlayers: int | None = None, temperature_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, pressure_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]

Initialize the mixing profile.

Parameters:
  • nlayers (int) – Number of layers in atmosphere

  • temperature_profile (array) – Temperature profile of atmosphere

  • pressure_profile (array) – Pressure profile of atmosphere

  • altitude_profile (array) – Altitude profile of atmosphere, deprecated

classmethod input_keywords() Tuple[str][source]
property mixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mixing profile

Returns:

mix – Mix ratio for molecule at each layer

Return type:

array

write(output: OutputGroup)[source]

Write constant gas profile to output.

Two Layer

Two layer gas profile.

class TwoLayerGas(molecule_name: str | None = 'CH4', mix_ratio_surface: float | None = 0.0001, mix_ratio_top: float | None = 1e-08, mix_ratio_P: float | None = 1000.0, mix_ratio_smoothing: float | None = 10)[source]

Bases: Gas

Two layer gas profile.

A gas profile with two different mixing layers at the surface of the planet and top of the atmosphere seperated at a defined pressure point and smoothened.

BIBTEX_ENTRIES = ['\n        @misc{changeat2019complex,\n            title={Towards a more complex description of chemical profiles\n            in exoplanets retrievals: A 2-layer parameterisation},\n            author={Quentin Changeat and Billy Edwards and\n                Ingo Waldmann and Giovanna Tinetti},\n            year={2019},\n            eprint={1903.11180},\n            archivePrefix={arXiv},\n            primaryClass={astro-ph.EP}\n        }\n        ']

List of bibtex entries.

add_pressure_param() None[source]

Generates pressure fitting parameter.

Has the form [Molecule]_P

add_surface_param() None[source]

Generates surface fitting parameters.

Has the form [Molecule]_surface

add_top_param() None[source]

Generates TOA fitting parameters.

Has the form: [Molecule]_top

initialize_profile(nlayers: int | None = None, temperature_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, pressure_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None)[source]

Initialize the profile.

Parameters:
  • nlayers (int) – number of layers

  • temperature_profile (np.ndarray) – temperature profile

  • pressure_profile (np.ndarray) – pressure profile

  • altitude_profile (np.ndarray , optional) – altitude profile, deprecated

classmethod input_keywords() Tuple[str, str][source]
property mixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mixing ratio profile for molecule.

Returns:

mix – Mix ratio for molecule at each layer

Return type:

array

property mixRatioPressure: float

Pressure at which the abundance changes.

property mixRatioSmoothing: float

Smoothing window.

property mixRatioSurface: float

Abundance on the planets surface.

property mixRatioTop: float

Abundance on the top of atmosphere.

write(output: OutputGroup)[source]

Write gas profile to output.

Array

Two layer gas profile.

class TwoLayerGas(molecule_name: str | None = 'CH4', mix_ratio_surface: float | None = 0.0001, mix_ratio_top: float | None = 1e-08, mix_ratio_P: float | None = 1000.0, mix_ratio_smoothing: float | None = 10)[source]

Bases: Gas

Two layer gas profile.

A gas profile with two different mixing layers at the surface of the planet and top of the atmosphere seperated at a defined pressure point and smoothened.

BIBTEX_ENTRIES = ['\n        @misc{changeat2019complex,\n            title={Towards a more complex description of chemical profiles\n            in exoplanets retrievals: A 2-layer parameterisation},\n            author={Quentin Changeat and Billy Edwards and\n                Ingo Waldmann and Giovanna Tinetti},\n            year={2019},\n            eprint={1903.11180},\n            archivePrefix={arXiv},\n            primaryClass={astro-ph.EP}\n        }\n        ']

List of bibtex entries.

add_pressure_param() None[source]

Generates pressure fitting parameter.

Has the form [Molecule]_P

add_surface_param() None[source]

Generates surface fitting parameters.

Has the form [Molecule]_surface

add_top_param() None[source]

Generates TOA fitting parameters.

Has the form: [Molecule]_top

initialize_profile(nlayers: int | None = None, temperature_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, pressure_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None, altitude_profile: ndarray[tuple[int, ...], dtype[float64]] | None = None)[source]

Initialize the profile.

Parameters:
  • nlayers (int) – number of layers

  • temperature_profile (np.ndarray) – temperature profile

  • pressure_profile (np.ndarray) – pressure profile

  • altitude_profile (np.ndarray , optional) – altitude profile, deprecated

classmethod input_keywords() Tuple[str, str][source]
property mixProfile: ndarray[tuple[int, ...], dtype[float64]]

Mixing ratio profile for molecule.

Returns:

mix – Mix ratio for molecule at each layer

Return type:

array

property mixRatioPressure: float

Pressure at which the abundance changes.

property mixRatioSmoothing: float

Smoothing window.

property mixRatioSurface: float

Abundance on the planets surface.

property mixRatioTop: float

Abundance on the top of atmosphere.

write(output: OutputGroup)[source]

Write gas profile to output.