CIA (taurex.cia)¶
Base Class¶
Base collisionally induced absorption class.
- class CIA(name: str, pair_name: str)[source]¶
Bases:
LoggableAbstract 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: float, wngrid: ndarray[tuple[int, ...], dtype[float64]] | None = 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
wngridif supplied- Return type:
array
- compute_cia(temperature: float) ndarray[tuple[int, ...], dtype[float64]][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:
It must accept temperature in Kelvin (K)
- If the temperature falls outside of
temperatureGrid() it must be set to zero
- If the temperature falls outside of
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: str¶
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: str¶
The name of the first molecule in the pair
- Returns:
First molecule in the pair
- Return type:
str
- property pairTwo: str¶
The name of the second molecule in the pair
- Returns:
Second molecule in the pair
- Return type:
str
- property temperatureGrid: ndarray[tuple[int, ...], dtype[float64]]¶
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: ndarray[tuple[int, ...], dtype[float64]]¶
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 EndOfHitranCIAError[source]¶
Bases:
ExceptionAn exception that occurs atr the end of a HITRAN file
- class HitranCIA(filename: str)[source]¶
Bases:
CIAA class that directly deals with HITRAN
Takes HITRAN cia 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: float) ndarray[tuple[int, ...], dtype[float64]][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() None[source]¶
Build the final wavenumber grid.
Collects all
HitranCiaGridobjects. 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: float) None[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: float) Tuple[int, int][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
temperaturet_max (int) – index on temprature grid to the right of
temperature
- interp_linear_grid(temperature: float, t_idx_min: int, t_idx_max: int) ndarray[tuple[int, ...], dtype[float64]][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
temperaturet_max (int) – index on temprature grid to the right of
temperature
- Returns:
out – Interpolated cross-section
- Return type:
array
- load_hitran_file(filename: str) None[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: TextIO) Tuple[float, float, int, float, float][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: ndarray[tuple[int, ...], dtype[float64]]¶
Unified temperature grid
- Returns:
Native temperature grid in Kelvin
- Return type:
array
- property wavenumberGrid: ndarray[tuple[int, ...], dtype[float64]]¶
Unified wavenumber grid
- Returns:
Native wavenumber grid
- Return type:
array
- class HitranCiaGrid(wn_min: float, wn_max: float)[source]¶
Bases:
LoggableClass 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(temperature: float, sigma: ndarray[tuple[int, ...], dtype[float64]]) None[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: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) None[source]¶
Here the ‘master’ temperature grid is passed into here and gaps filled.
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: float) Tuple[int, int][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
temperaturet_max (int) – index on temprature grid to the right of
temperature
- interp_linear_grid(temperature: float, t_idx_min: int, t_idx_max: int) ndarray[tuple[int, ...], dtype[float64]][source]¶
For a given temperature and indicies. Interpolate the cross-sections.
Interpolates linearly from temperature grid to temperature
temperature- Parameters:
temperature (float) – Temeprature in Kelvin
t_min (int) – index on temprature grid to the left of
temperaturet_max (int) – index on temprature grid to the right of
temperature
- Returns:
out – Interpolated cross-section
- Return type:
array
- property sigma: ndarray[tuple[int, ...], dtype[float64]]¶
Gets the currently loaded crossections for this wavenumber grid.
- Returns:
Cross-section grid
- Return type:
array
- property temperature: float¶
Gets the current temeprature grid for this wavenumber grid.
- Returns:
Temeprature grid in Kelvin
- Return type:
array
Pickle CIA (.db)¶
Handling of .pickle/.db CIA files.
- class PickleCIA(filename: str, pair_name: float64 | None = None)[source]¶
Bases:
CIAClass 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: float) ndarray[tuple[int, ...], dtype[float64]][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: float) Tuple[int, int][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
temperaturet_max (int) – index on temprature grid to the right of
temperature
- interp_linear_grid(temperature: float, t_idx_min: int, t_idx_max: int) float[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
temperaturet_max (int) – index on temprature grid to the right of
temperature
- Returns:
out – Interpolated cross-section
- Return type:
array
- property temperatureGrid: ndarray[tuple[int, ...], dtype[float64]]¶
returns: Native temperature grid in Kelvin :rtype:
array
- property wavenumberGrid: ndarray[tuple[int, ...], dtype[float64]]¶
returns: Native wavenumber grid :rtype:
array