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='cm^5', 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 of string) – As many strings as necessary to uniquely define a file in the global search path defined with exo_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 of size 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.

  • 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 with exo_k.settings.Settings.set_cia_search_path() and only files in search_path are returned.

_init_empty()[source]

Initializes attributes to none.

read_hitran_cia(filename, old_cia_unit='cm^5')[source]

Reads hitran cia files and load temperature, wavenumber, and absorption coefficient grid.

Parameters:
  • filename (str) – Name of the file to be read.

  • old_cia_unit (str, optional) – Units found in the file.

_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.

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.

sample_cp(wngrid, **kwargs)[source]

Creates a copy of the object before resampling it.

Parameters:

details. (See sample method for) –

Returns:

Cia_table object

the re-sampled Cia_table

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 or array) – 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:
  • logP (float or array) – Log10 of the pressure (Pa).

  • T (float or array) – Temperature (K).

  • x_mol1/2 (float or array) – Volume mixing ratio of the 1st and 2nd molecule of the pair.

  • wngrid_limit (array, np.ndarray, optional) – If an array is given, interpolates only within this array.

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

Parameters:
  • ax (pyplot.Axes) – A pyplot axes instance where to put the plot.

  • t (float) – temperature(K)

  • x_axis (str, optional) – If ‘wls’, x axis is wavelength. Wavenumber otherwise.

  • x/yscale (str, optional) – If ‘log’ log axes are used.

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)

convert_to_mks(verbose=False)[source]

Converts units to MKS

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.

copy()[source]

Creates a new instance of CIA_table object and (deep) copies data into it

read_CKD_cia(filename, old_cia_unit='cm^2')[source]

Reads hitran cia files and load temperature, wavenumber, and absorption coefficient grid.

Parameters:

filename (str) – Name of the file to be read.

effective_cross_section2(logP, T, x_mol1, x_mol2, wngrid_limit=None)[source]

Obsolete.

Computes the total cross section for a molecule pair (in m^2 per total number of molecules; assumes data in MKS).