exo_k.cia_table
@author: jeremy leconte
A class to handle continuum absorption (CIA)
Module Contents
- class exo_k.cia_table.Cia_table(*filename_filters, filename=None, molecule_pair=None, search_path=None, mks=False, remove_zeros=False, old_cia_unit=None, deltalog_min_value=0.0, wn_range=None, wl_range=None)[source]
Bases:
exo_k.util.spectral_object.Spectral_object
A class to handle CIA opacity data tables.
Important
In the 2018 release of Hitran, some CIA files can contain data for multiple wavenumber range but for different temperatures in each range. This is not yet supported so only the first wavenumber range is used. For H2-H2 cia files, one should manually replace all the n-H2 – n-H2 in H2-H2 for the format to be readable.
Initialization for Cia_tables.
- Parameters:
filename (
str
, optional) – Relative or absolute name of the file to be loaded.filename_filters (
sequence
ofstring
) – As many strings as necessary to uniquely define a file in the global search path defined withexo_k.settings.Settings.set_cia_search_path()
. This path will be searched for a file with all the filename_filters in the name. The filename_filters can contain ‘*’.molecule_pair (
list
ofsize 2
, optional) – The molecule pair we want to consider, specified as an array with two strings (like [‘H2’,’H2’] or [‘N2’,’H2O’]). The order of the molecules in the pair is irrelevant.old_cia_unit (
str
, optional) – String to specify the current cia unit if it is unspecified or if you have reasons to believe it is wrong (e.g. you just read a file where you know that the cia grid and the cia unit do not correspond). Available units are: ‘cm^5’, ‘cm^2’ that stand for cm^2/amagat, and ‘cm^-1’ that stand for cm^-1/amagat^2. Leave to None if unsure.remove_zeros (
boolean
, optional) –- If True, the zeros in the kdata table are replaced by
a value 10 orders of magnitude smaller than the smallest positive value
search_path (
str
, optional) – If search_path is provided, it locally overrides the global search path defined withexo_k.settings.Settings.set_cia_search_path()
and only files in search_path are returned.
- _settings
- read_hitran_cia(filename, old_cia_unit=None)[source]
Reads hitran cia files and load temperature, wavenumber, and absorption coefficient grid.
- _read_header(file)[source]
Reads the header lines in a Hitran CIA file.
- Parameters:
file (
file stream
) – file to be read.
- read_hdf5(filename, wn_range=None, wl_range=None)[source]
Reads hdf5 cia files and load temperature, wavenumber, and absorption coefficient grid.
- Parameters:
filename (
str
) – Name of the file to be read.
- write_hdf5(filename)[source]
Writes hdf5 cia files.
- Parameters:
filename (
str
) – Name of the file to be written.
- write_cia(filename)[source]
Writes simplified .cia files.
To be consistent with Hitran CIA files, data is converted back to cm^5 before writing.
- Parameters:
filename (
str
) – Name of the file to be written.
- read_cia_turbet(filename, old_cia_unit=None)[source]
Reads cia files in a 2D table in .dat format from M. Turbet.
1st line is the temperature grid, then 1 line per wavenumber
- sample(wngrid, remove_zeros=False, use_grid_filter=False, **kwargs)[source]
Method to re sample a cia table to a new grid of wavenumbers (inplace).
- Parameters:
wngrid (
array
,np.ndarray
) – new wavenumber grid (cm-1)use_grid_filter (
boolean
, optional) – If true, the table is sampled only within the boundaries of its current wavenumber grid. The coefficients are set to zero elswere (except if remove_zeros is set to True). If false, the values at the boundaries are used when sampling outside the grid.
- interpolate_cia(t_array=None, log_interp=None, wngrid_limit=None)[source]
interpolate_cia interpolates the kdata at on a given temperature profile.
- Parameters:
t_array (
float
orarray
) – Temperature array to interpolate to. If a float is given, it is interpreted as an array of size 1.wngrid_limit (
array
,np.ndarray
, optional) – If an array is given, interpolates only within this array.log_interp (
bool
, optional) – Whether the interpolation is linear in kdata or in log(kdata).
- Returns:
- array of shape (logp_array.size, self.Nw)
The interpolated kdata.
- equivalent_xsec(logP, T, x_mol2, wngrid_limit=None)[source]
Computes the cross section due to CIA in area per molecule of type 1.
- effective_cross_section(logP, T, x_mol1, x_mol2, wngrid_limit=None)[source]
Computes the total cross section for a molecule pair (in m^2 per total number of molecules; assumes data in MKS).
- Parameters:
- Returns:
- float or array
total cross section for the molecule pair in m^2 per total number of molecules.
- plot_spectrum(ax, t=200.0, x_axis='wls', xscale=None, yscale=None, **kwarg)[source]
Plot the spectrum for a given point
- convert_abs_coeff_unit(abs_coeff_unit='unspecified', old_abs_coeff_unit='unspecified')[source]
Converts abs_coeff to a new unit (inplace).
- Parameters:
abs_coeff_unit (
str
) – String to identify the units to convert to. Accepts ‘cm^5’, ‘m^5’. or any length^5 unit recognized by the astropy.units library. If =’unspecified’, no conversion is done.old_abs_coeff_unit (
str
, optional) – String to specify the current kdata unit if it is unspecified or if you have reasons to believe it is wrong (e.g. you just read a file where you know that the kdata grid and the kdata unit do not correspond)
- remove_zeros(deltalog_min_value=0.0, **kwargs)[source]
Finds zeros in the abs_coeff and set them to (10.^-deltalog_min_value) times the minimum positive value in the table (inplace). This is to be able to work in logspace.