Contributions (taurex.contributions)

Classes related to the computation of the optical depth

Base Contribution

Base contribution classes and functions for computing optical depth.

class Contribution(name: str | None = None)[source]

Bases: Fittable, Loggable, Writeable, Citable

The base class for modelling contributions to the optical depth.

Abstract class

By default this handles contributions from cross-sections. If the type of contribution being implemented is a sigma-type like the form given in contribute_tau() then To function in Taurex3, it only requires the concrete implementation of:

Different forms may require reimplementing contribute() as well as prepare()

build(model: object) None[source]

Called during forward model build phase.

Does nothing by default

Parameters:

model (ForwardModel) – Forward model

contribute(model: object, start_layer: int, end_layer: int, density_offset: int, layer: int, density: ndarray[tuple[int, ...], dtype[float64]], tau: ndarray[tuple[int, ...], dtype[float64]], path_length: ndarray[tuple[int, ...], dtype[float64]] | None = None)[source]

Computes an integral for a single layer for the optical depth.

Parameters:
  • model (ForwardModel) – A forward model

  • start_layer (int) – Lowest layer limit for integration

  • end_layer (int) – Upper layer limit of integration

  • density_offset (int) – offset in density layer

  • layer (int) – atmospheric layer being computed

  • density (array) – density profile of atmosphere

  • tau (array) – optical depth to store result

  • path_length (array) – integration length

finalize(model: object, tau: ndarray[tuple[int, ...], dtype[float64]])[source]

Called in the last phase of the calculation, after the optical depth has be completely computed.

classmethod input_keywords() List[str][source]

List of input keywords for identification.

property name: str

Name of the contribution. Identifier for plots

property order: int

Computational order.

Lower numbers are given higher priority and are computed first.

Returns:

Order of computation

Return type:

int

prepare(model: object, wngrid: ndarray[tuple[int, ...], dtype[float64]]) None[source]

Used to prepare the contribution for the calculation. Called before the forward model performs the main optical depth calculation. Default behaviour is to loop through prepare_each() and sum all results into a single cross-section.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

prepare_each(model: object, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Requires implementation

Used to prepare each component of the contribution. For context when the main taurex program is run with the option each spectra is the component for the contribution. For cross-section based contributions, the components are each molecule Should yield the name of the component and the component itself

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

Yields:

component (tuple of type (str, array)) – Name of component and component itself

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

(Effective) Cross-section for contribution.

write(output: OutputGroup) OutputGroup[source]

Writes contribution class and arguments to file.

Parameters:

output (Output) – Output object to write to.

contribute_tau(startk: int, endk: int, density_offset: int, sigma: ndarray[tuple[int, ...], dtype[float64]], density: ndarray[tuple[int, ...], dtype[float64]], path: ndarray[tuple[int, ...], dtype[float64]], nlayers: int, ngrid: int, layer: int, tau: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]]

Generic cross-section integration function for tau

This has the form:

\[\tau_{\lambda}(z) = \int_{z_{0}}^{z_{1}} \sigma(z') \rho(z') dz',\]

where \(z\) is the layer, \(z_0\) and \(z_1\) are startK and endK respectively. \(\sigma\) is the weighted cross-section sigma. \(rho\) is the density and \(dz'\) is the integration path length path

Parameters:
  • startK (int) – starting layer in integration

  • endK (int) – last layer in integration

  • density_offset (int) – Which part of the density profile to start from

  • sigma (array) – cross-section

  • density (array_like) – density profile of atmosphere

  • path (array_like) – path-length or altitude gradient

  • nlayers (int) – Total number of layers (unused)

  • ngrid (int) – total number of grid points

  • layer (int) – Which layer we currently on

Returns:

tau – optical depth (well almost you still need to do exp(-tau) yourself)

Return type:

array_like

contribute_tau_numba(startK: int, endK: int, density_offset: int, sigma: ndarray[tuple[int, ...], dtype[float64]], density: ndarray[tuple[int, ...], dtype[float64]], path: ndarray[tuple[int, ...], dtype[float64]], nlayers: int, ngrid: int, layer: int, tau: ndarray[tuple[int, ...], dtype[float64]])[source]

Generic cross-section integration function for tau

numba-fied for performance.

This has the form:

\[\tau_{\lambda}(z) = \int_{z_{0}}^{z_{1}} \sigma(z') \rho(z') dz',\]

where \(z\) is the layer, \(z_0\) and \(z_1\) are startK and endK respectively. \(\sigma\) is the weighted cross-section sigma. \(rho\) is the density and \(dz'\) is the integration path length path

Parameters:
  • startK (int) – starting layer in integration

  • endK (int) – last layer in integration

  • density_offset (int) – Which part of the density profile to start from

  • sigma (array) – cross-section

  • density (array_like) – density profile of atmosphere

  • path (array_like) – path-length or altitude gradient

  • nlayers (int) – Total number of layers (unused)

  • ngrid (int) – total number of grid points

  • layer (int) – Which layer we currently on

Returns:

tau – optical depth (well almost you still need to do exp(-tau) yourself)

Return type:

array_like

contribute_tau_numpy(startk: int, endk: int, density_offset: int, sigma: ndarray[tuple[int, ...], dtype[float64]], density: ndarray[tuple[int, ...], dtype[float64]], path: ndarray[tuple[int, ...], dtype[float64]], nlayers: int, ngrid: int, layer: int, tau: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]][source]

Generic cross-section integration function for tau

This has the form:

\[\tau_{\lambda}(z) = \int_{z_{0}}^{z_{1}} \sigma(z') \rho(z') dz',\]

where \(z\) is the layer, \(z_0\) and \(z_1\) are startK and endK respectively. \(\sigma\) is the weighted cross-section sigma. \(rho\) is the density and \(dz'\) is the integration path length path

Parameters:
  • startK (int) – starting layer in integration

  • endK (int) – last layer in integration

  • density_offset (int) – Which part of the density profile to start from

  • sigma (array) – cross-section

  • density (array_like) – density profile of atmosphere

  • path (array_like) – path-length or altitude gradient

  • nlayers (int) – Total number of layers (unused)

  • ngrid (int) – total number of grid points

  • layer (int) – Which layer we currently on

Returns:

tau – optical depth (well almost you still need to do exp(-tau) yourself)

Return type:

array_like

Absorption

class AbsorptionContribution[source]

Bases: Contribution

Absorption contribution.

contribute(model: ForwardModel, start_horz_layer: int, end_horz_layer: int, density_offset: int, layer: int, density: ndarray[tuple[int, ...], dtype[float64]], tau: ndarray[tuple[int, ...], dtype[float64]], path_length: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]

Contribute to the optical depth.

Parameters:
  • model (ForwardModel) – Forward model

  • start_horz_layer (int) – Starting horizontal layer

  • end_horz_layer (int) – Ending horizontal layer

  • density_offset (int) – Offset of the density profile

  • layer (int) – Layer index

  • density (npt.NDArray[np.float64]) – Density profile

  • tau (npt.NDArray[np.float64]) – Optical depth

  • path_length (npt.NDArray[np.float64], optional) – Path length, by default None

finalize(model: ForwardModel) None[source]

Finalize the contribution.

classmethod input_keywords() Tuple[str][source]

Return input keywords for the contribution.

prepare(model: ForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) None[source]

Used to prepare the contribution for the calculation. Called before the forward model performs the main optical depth calculation. Default behaviour is to loop through prepare_each() and sum all results into a single cross-section.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

prepare_each(model: ForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Prepare each component opacity.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (npt.NDArray[np.float64]) – Wavenumber grid

Yields:

t.Generator[t.Tuple[str, npt.NDArray[np.float64]], None, None] – Gas name and opacity

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

Return effective cross-sections.

CIA

Opacity integration of collision-induced absorption.

class CIAContribution(cia_pairs: List[str] | None = None)[source]

Bases: Contribution

Computes the CIA contribution to the optical depth.

CIA is collisionally induced absorption.

property ciaPairs: Sequence[str]

Returns list of molecular pairs involved.

Returns:

list of molecule pairs of the form mol1-mol2 e.g. H2-He

Return type:

list of str

contribute(model: OneDForwardModel, start_layer: int, end_layer: int, density_offset: int, layer: int, density: ndarray[tuple[int, ...], dtype[float64]], tau: ndarray[tuple[int, ...], dtype[float64]], path_length: ndarray[tuple[int, ...], dtype[float64]] | None = None) None[source]

Integrate the optical depth for a given layer.

classmethod input_keywords() Tuple[str][source]

Return list of input keywords for CIA.

prepare_each(model: OneDForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Computes and weighs cross-section for a single pair of molecules

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

Yields:

component (tuple of type (str, array)) – Molecular pair and the weighted cia opacity.

write(output: OutputGroup) OutputGroup[source]

Write output to file.

contribute_cia(startk: int, endk: int, density_offset: int, sigma: ndarray[tuple[int, ...], dtype[float64]], density: ndarray[tuple[int, ...], dtype[float64]], path: ndarray[tuple[int, ...], dtype[float64]], nlayers: int, ngrid: int, layer: int, tau: ndarray[tuple[int, ...], dtype[float64]])

Integrate the optical depth for a given layer.

contribute_cia_numba(startk: int, endk: int, density_offset: int, sigma: ndarray[tuple[int, ...], dtype[float64]], density: ndarray[tuple[int, ...], dtype[float64]], path: ndarray[tuple[int, ...], dtype[float64]], nlayers: int, ngrid: int, layer: int, tau: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]][source]

Collisionally induced absorption integration function.

This has the form:

\[\tau_{\lambda}(z) = \int_{z_{0}}^{z_{1}} \sigma(z') \rho(z')^{2} dz',\]

where \(z\) is the layer, \(z_0\) and \(z_1\) are startK and endK respectively. \(\sigma\) is the weighted cross-section sigma. \(rho\) is the density and \(dz'\) is the integration path length path

Parameters:
  • startK (int) – starting layer in integration

  • endK (int) – last layer in integration

  • density_offset (int) – Which part of the density profile to start from

  • sigma (array) – cross-section

  • density (array_like) – density profile of atmosphere

  • path (array_like) – path-length or altitude gradient

  • nlayers (int) – Total number of layers (unused)

  • ngrid (int) – total number of grid points

  • layer (int) – Which layer we currently on

Returns:

tau – optical depth (well almost you still need to do exp(-tau) yourself)

Return type:

array_like

contribute_cia_numpy(startk: int, endk: int, density_offset: int, sigma: ndarray[tuple[int, ...], dtype[float64]], density: ndarray[tuple[int, ...], dtype[float64]], path: ndarray[tuple[int, ...], dtype[float64]], nlayers: int, ngrid: int, layer: int, tau: ndarray[tuple[int, ...], dtype[float64]])[source]

Integrate the optical depth for a given layer.

Rayleigh

Rayleigh scattering contribution.

class RayleighContribution[source]

Bases: Contribution

Computes contribution from Rayleigh scattering.

BIBTEX_ENTRIES = ['\n        @book{cox_allen_rayleigh,\n        title={Allen’s astrophysical quantities},\n        author={Cox, Arthur N},\n        year={2015},\n        publisher={Springer}\n        }\n        ']

List of bibtex entries.

classmethod input_keywords() Tuple[str][source]

Return list of keywords for contribution.

prepare_each(model: OneDForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Compute opacity due to rayleigh scattering.

Scattering is weighted by the mixing ratio of the gas from chemistry.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

Yields:

component (tuple of type (str, array)) – Name of scattering molecule and the weighted rayeligh opacity.

SimpleClouds

Flat Cloud scattering.

class SimpleCloudsContribution(clouds_pressure: float | None = 1000.0)[source]

Bases: Contribution

Optically thick cloud deck up to a certain height

These have the form:

\[\begin{split}\tau(\lambda,z) = \begin{cases} \infty & \quad \text{if } P(z) >= P_{0}\\ 0 & \quad \text{if } P(z) < P_{0} \end{cases}\end{split}\]

Where \(P_{0}\) is the pressure at the top of the cloud-deck.

property cloudsPressure

Cloud top pressure in Pascal.

contribute(model: OneDForwardModel, start_layer: int, end_layer: int, density_offset: int, layer: int, density: ndarray[tuple[int, ...], dtype[float64]], tau: ndarray[tuple[int, ...], dtype[float64]], path_length: ndarray[tuple[int, ...], dtype[float64]] | None = None)[source]

Contribute the cloud opacity to the optical depth.

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

List of input keywords for identification.

property order: int

Computational order.

Lower numbers are given higher priority and are computed first.

Returns:

Order of computation

Return type:

int

prepare_each(model: OneDForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Compute cross-section that is infinitely absorbing.

Absorption occurs up to a certain height.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

Yields:

component (tuple of type (str, array)) – Clouds and opacity array.

write(output: OutputGroup)[source]

Write the cloud pressure to the output.

Mie Scattering (BH)

Warning

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

Mie Scattering (Lee)

Mie scattering using Lee et al. 2013 formalism.

class LeeMieContribution(lee_mie_radius: float | None = 0.01, lee_mie_q: float | None = 40, lee_mie_mix_ratio: float | None = 1e-10, lee_mie_bottomP: float | None = -1, lee_mie_topP: float | None = -1)[source]

Bases: Contribution

Computes Mie scattering contribution to optica depth.

Formalism taken from: Lee et al. 2013, ApJ, 778, 97

Parameters:
  • lee_mie_radius (float) – Particle radius in um

  • lee_mie_q (float) – Extinction coefficient

  • lee_mie_mix_ratio (float) – Mixing ratio in atmosphere in particles/m3

  • lee_mie_bottomP (float) – Bottom of cloud deck in Pa

  • lee_mie_topP (float) – Top of cloud deck in Pa

BIBTEX_ENTRIES = ['\n        @article{Lee_2013,\n            doi = {10.1088/0004-637x/778/2/97},\n            url = {https://doi.org/10.1088%2F0004-637x%2F778%2F2%2F97},\n            year = 2013,\n            month = {nov},\n            publisher = {{IOP} Publishing},\n            volume = {778},\n            number = {2},\n            pages = {97},\n            author = {Jae-Min Lee and Kevin Heng and Patrick G. J. Irwin},\n            journal = {The Astrophysical Journal},\n        ']

List of bibtex entries.

contribute(model: object, start_layer: int, end_layer: int, density_offset: int, layer: int, density: ndarray[tuple[int, ...], dtype[float64]], tau: ndarray[tuple[int, ...], dtype[float64]], path_length: ndarray[tuple[int, ...], dtype[float64]] | None = None)[source]

Computes an integral for a single layer for the optical depth.

Parameters:
  • model (ForwardModel) – A forward model

  • start_layer (int) – Lowest layer limit for integration

  • end_layer (int) – Upper layer limit of integration

  • density_offset (int) – offset in density layer

  • layer (int) – atmospheric layer being computed

  • density (array) – density profile of atmosphere

  • tau (array) – optical depth to store result

  • path_length (array) – integration length

classmethod input_keywords() Tuple[str][source]

Input keywords.

property mieBottomPressure: float

Pressure at bottom of cloud deck in Pa.

property mieMixing: float

Mixing ratio in atmosphere.

property mieQ: float

Extinction coefficient.

property mieRadius: float

Particle radius in um.

property mieTopPressure: float

Pressure at top of cloud deck in Pa.

prepare_each(model: OneDForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Compute and weights the mie opacity for the pressure regions given.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

Yields:

component (tuple of type (str, array)) – Lee and the weighted mie opacity.

write(output: OutputGroup) OutputGroup[source]

Write output group.

Mie Scattering (Flat)

Module for computing flat Mie opacity.

class FlatMieContribution(flat_mix_ratio: float = 1e-10, flat_bottomP: float = -1, flat_topP: float = -1)[source]

Bases: Contribution

Computes a flat (gray) absorption contribution.

Absorption is computed as a flat value between two pressures across all wavenumbers.

Parameters:
  • flat_mix_ratio (float) – Opacity value

  • flat_bottomP (float) – Bottom of absorbing region in Pa

  • flat_topP (float) – Top of absorbing region in Pa

classmethod input_keywords() Tuple[str][source]

Return input keywords for the contribution.

property mieBottomPressure: float

Pressure at bottom of absorbing region in Pa.

property mieMixing: float

Opacity of absorbing region in \(m^2\).

property mieTopPressure: float

Pressure at top of absorbing region in Pa

prepare_each(model: OneDForwardModel, wngrid: ndarray[tuple[int, ...], dtype[float64]]) Generator[Tuple[str, ndarray[tuple[int, ...], dtype[float64]]], None, None][source]

Computes and flat absorbing opacity for the pressure regions given.

Parameters:
  • model (ForwardModel) – Forward model

  • wngrid (array) – Wavenumber grid

Yields:

component (tuple of type (str, array)) – Flat and the weighted mie opacity.

write(output: OutputGroup) OutputGroup[source]

Write contribution to output.

Parameters:

output (Output) – Output object to write to

Returns:

output – Output object that was written to

Return type:

Output