CIA (taurex.cia)

Base Class

Contains the abstract class used by all collisionally induced absorption objects.

class CIA(name, pair_name)[source]

Bases: taurex.log.logger.Logger

Abstract class

This is the base class for collisionally induced absorption opacities. To function in Taurex3, it requires concrete implementations of:

Parameters
  • name (str) – Name to use for logging

  • pair_name (str) – pair of molecules this class represents. e.g. ‘H2-H2’ or ‘H2-He’

cia(temperature, wngrid=None)[source]

For a given temperature, computes the appropriate cross section. If wavenumber grid ( wngrid ) is provided then the cross-section is interpolated to it.

Parameters
  • temperature (float) – Temeprature in Kelvin

  • wngrid (array , optional) – Wavenumber grid to interpolate to

Returns

CIA cross section at desired temeprature on either its native grid or interpolated on wngrid if supplied

Return type

array

compute_cia(temperature)[source]

Computes the collisionaly induced cross-section for a given temeprature

Unimplemented, this must be implemented in any derived class to be considered compatible in Taurex3

The rules are:
  1. It must accept temperature in Kelvin (K)

  2. If the temperature falls outside of temperatureGrid() it must be set to zero

  3. The returned array must be of equal size to wavenumberGrid()

Parameters

temperature (float) – Temeprature in Kelvin

Returns

CIA cross section at desired temeprature on its native grid

Return type

array

Raises

NotImplementedError – Only if derived class does not implement this

property pairName

The assigned pair of molecules of this CIA

Returns

The pair of molecules of this object in the form: Molecule1-Molecule2

Return type

str

property pairOne

The name of the first molecule in the pair

Returns

First molecule in the pair

Return type

str

property pairTwo

The name of the second molecule in the pair

Returns

Second molecule in the pair

Return type

str

property temperatureGrid

The native temperature grid of the CIA cross-sections.

Returns

Native temeprature grid in Kelvin

Return type

array

Raises

NotImplementedError – Only if derived class does not implement this

property wavenumberGrid

The native wavenumber grid (cm-1) of the CIA. Must be implemented in derived classes

Returns

Native wavenumber grid

Return type

array

Raises

NotImplementedError – Only if derived class does not implement this

HITRAN CIA (.cia)

Module contains classes that handle loading of HITRAN cia files

exception EndOfHitranCIAException[source]

Bases: Exception

An exception that occurs when the end of a HITRAN file is reached

class HitranCIA(filename)[source]

Bases: taurex.cia.cia.CIA

A class that directly deals with HITRAN cia files and turns them into generic CIA objects that nicely produces cross sections for us. This will handle CIAs that have wavenumber grids split across temperatures by unifying them into single grids.

To use it simply do:

>>> h2h2 = HitranCIA('path/to/H2-He.cia')

And now you can painlessly compute cross-sections like this:

>>> h2h2.cia(400)

Or if you have a wavenumber grid, we can also interpolate it:

>>> h2h2.cia(400,mywngrid)

And all it cost was buying me a beer!

Parameters

filename (str) – Path to HITRAN cia file

compute_cia(temperature)[source]

Computes the collisionally induced absorption cross-section using our final native temperature and cross-section grids

Parameters

temperature (float) – Temperature in Kelvin

Returns

out – Temperature interpolated cross-section

Return type

array

compute_final_grid()[source]

Collects all HitranCiaGrid objects we’ve created and unifies them into a single temperature, cross-section and wavenumber grid for us to FINALLY interpolate and produce collisionaly induced cross-sections

fill_gaps(temperature)[source]

Fills gaps in temperature grid for all wavenumber grid objects we’ve created

Parameters

temperature (array_like) – Master temperature grid

find_closest_temperature_index(temperature)[source]

Finds the nearest indices for a particular temperature

Parameters

temperature (float) – Temeprature in Kelvin

Returns

  • t_min (int) – index on temprature grid to the left of temperature

  • t_max (int) – index on temprature grid to the right of temperature

interp_linear_grid(T, t_idx_min, t_idx_max)[source]

For a given temperature and indicies. Interpolate the cross-sections linearly from temperature grid to temperature T

Parameters
  • temperature (float) – Temeprature in Kelvin

  • t_min (int) – index on temprature grid to the left of temperature

  • t_max (int) – index on temprature grid to the right of temperature

Returns

out – Interpolated cross-section

Return type

array

load_hitran_file(filename)[source]

Handles loading of the HITRAN file by reading and figuring out the wavenumber and temperature grids and matching them up

Parameters

filename (str) – Path to HITRAN cia file

read_header(f)[source]

Reads single header in the file

Parameters

f (file object) –

Returns

  • start_wn (float) – Start wavenumber for temperature

  • end_wn (float) – End wavenumber for temperature

  • total_points (int) – total number of points in temperature

  • T (float) – Temperature in Kelvin

  • max_cia (float) – Maximum CIA value in temperature

property temperatureGrid

Unified temperature grid

Returns

Native temperature grid in Kelvin

Return type

array

property wavenumberGrid

Unified wavenumber grid

Returns

Native wavenumber grid

Return type

array

class HitranCiaGrid(wn_min, wn_max)[source]

Bases: taurex.log.logger.Logger

Class that handles a particular HITRAN cia wavenumber grid Since temperatures for CIA sometimes have different wavenumber grids this class helps to simplify managing them by only dealing with one at a time. These will help us unify into a single grid eventually

Parameters
  • wn_min (float) – The minimum wavenumber for this grid

  • wn_max (float) – The maximum wavenumber for this grid

add_temperature(T, sigma)[source]

Adds a temeprature and crossection to this wavenumber grid

Parameters
  • T (float) – Temeprature in Kelvin

  • sigma (array) – cross-sections for this grid

fill_temperature(temperatures)[source]

Here the ‘master’ temperature grid is passed into here and any gaps in our grid is filled with zero cross-sections to produce our final temperature-crosssection grid that matches with every other wavenumber grid. Temperatures that don’t exist in the current grid but are withing the minimum and maximum for us are produced by linear interpolation

Parameters

temperatures (array_like) – Master temperature grid

find_closest_temperature_index(temperature)[source]

Finds the nearest indices for a particular temperature

Parameters

temperature (float) – Temeprature in Kelvin

Returns

  • t_min (int) – index on temprature grid to the left of temperature

  • t_max (int) – index on temprature grid to the right of temperature

interp_linear_grid(T, t_idx_min, t_idx_max)[source]

For a given temperature and indicies. Interpolate the cross-sections linearly from temperature grid to temperature T

Parameters
  • temperature (float) – Temeprature in Kelvin

  • t_min (int) – index on temprature grid to the left of temperature

  • t_max (int) – index on temprature grid to the right of temperature

Returns

out – Interpolated cross-section

Return type

array

property sigma

Gets the currently loaded crossections for this wavenumber grid

Returns

Cross-section grid

Return type

array

sortTempSigma()[source]

Sorts the temperature-sigma list

property temperature

Gets the current temeprature grid for this wavenumber grid

Returns

Temeprature grid in Kelvin

Return type

array

hashwn(start_wn, end_wn)[source]

Simple wavenumber hash function

Pickle CIA (.db)

class PickleCIA(filename, pair_name=None)[source]

Bases: taurex.cia.cia.CIA

Class for using pickled (.db) collisionally induced absorptions Very simple since the format is simple

Parameters
  • filename (str) – Path to pickle

  • pair_name (str , optional) – Whilst the name of the pair is determined by the pickle filename since these can be different you can optionally force the name through this parameter

compute_cia(temperature)[source]

Computes the collisionally induced absorption cross-section using our native temperature and cross-section grids

Parameters

temperature (float) – Temperature in Kelvin

Returns

out – Temperature interpolated cross-section

Return type

array

find_closest_temperature_index(temperature)[source]

Finds the nearest indices for a particular temperature

Parameters

temperature (float) – Temeprature in Kelvin

Returns

  • t_min (int) – index on temprature grid to the left of temperature

  • t_max (int) – index on temprature grid to the right of temperature

interp_linear_grid(T, t_idx_min, t_idx_max)[source]

For a given temperature and indicies. Interpolate the cross-sections linearly from temperature grid to temperature T

Parameters
  • temperature (float) – Temeprature in Kelvin

  • t_min (int) – index on temprature grid to the left of temperature

  • t_max (int) – index on temprature grid to the right of temperature

Returns

out – Interpolated cross-section

Return type

array

property temperatureGrid

returns: Native temperature grid in Kelvin :rtype: array

property wavenumberGrid

returns: Native wavenumber grid :rtype: array