@author: jeremy leconte

Module Contents

class Kdatabase(molecules, *str_filters, search_path=None, remove_zeros=True, **kwargs)[source]

Bases: exo_k.util.spectral_object.Spectral_object

This object contains mainly a dictionary of individual Ktable or Xtable objects for each molecule.

In addition, the informations about the P, T, Wn, g grids are reloaded as atributes of the Kdatabase object.

Initializes k coeff tables and supporting data from a list of molecules

  • molecules (list or dict) –

    • If a list of molecules is provided, the file starting with the molecule name and containing all the str_filters are searched in the global search path defined in Settings.

    • If a dictionary is provided, the keys are the molecules to load, and the values are the path to the corresponding file. If a None value is given, the str_filters will be used as above.

  • search_path (str, optional) – If search_path is provided, it locally overrides the global _search_path settings and only files in search_path are returned.

See also the options of Ktable

>>> Kdatabase(None)

Loads an empty database to be filled later with add_ktables().


By default, Ktables have zeros removed when loaded to avoid log interpolation issues. You can avoid that with the remove_zeros=False keyword.

add_ktables(self, *ktables)[source]

Adds as many Ktable or Xtable to the database as you want (inplace).


ktables (Ktable or Xtable objects) – Tables to be added.


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

remap_logPT(self, logp_array=None, t_array=None)[source]

Applies the remap_logPT method to all the tables in the database (inplace). This can be used to put all the tables onthe same PT grid.

See exo_k.data_table.Data_table.remap_logPT() for details.

bin_down(self, wnedges=None, **kwargs)[source]

Applies the bin_down method to all the tables in the database (inplace). This can be used to put all the tables on the same wavenumber grid.

See exo_k.ktable.Ktable.bin_down() or exo_k.xtable.Xtable.bin_down() for details.

bin_down_cp(self, wnedges=None, **kwargs)[source]

Creates a copy of the database and bins it down.


bin_down for details on parameters (See) –


The binned down database

Return type

Kdatabase object

sample(self, wngrid, **kwargs)[source]

Applies the sample method to all the tables in the database (inplace). This can be used to put all the tables onthe same wavenumber grid.

See Ktable.bin_down() or Xtable.bin_down() for details.

sample_cp(self, wngrid, **kwargs)[source]

Creates a copy of the database and re-samples it.


sample for details on parameters (See) –


The re-sampled database

Return type

Kdatabase object

clip_spectral_range(self, wn_range=None, wl_range=None)[source]

Limits the data to the provided spectral range (inplace):

  • Wavenumber in cm^-1 if using wn_range argument

  • Wavelength in micron if using wl_range

convert_p_unit(self, p_unit='unspecified')[source]

Converts pressure unit of all Data_tables (inplace). See Data_table.convert_p_unit() for details.

convert_kdata_unit(self, kdata_unit='unspecified')[source]

Converts kdata unit of all Data_tables (inplace). See Data_table.convert_kdata_unit() for details.


Converts units of all `Data_table`s to MKS (inplace)

create_mix_ktable(self, composition, inactive_species=[])[source]

Creates a Ktable for a mix of molecules.

The table is computed over the P,T grid of the Kdatabase instance.

  • composition (dict) – Keys are the molecule names (they must match the names in the database). Values are either numbers or arrays of volume mixing ratios with shape (pgrid.size,tgrid.size). This composition will instantiate a Gas_mix object. In particular, if a value is ‘background’, this gas will be used to fill up to sum(vmr)=1 (See Gas_mix for details). For each (P,T) point, the sum of all the mixing ratios should be lower or equal to 1. If it is lower, it is assumed that the rest of the gas is transparent.

  • inactive_species (list, optional) – List the gases that are in composition but for which we do not want the opacity to be accounted for.


A new ktable for the mix.

Return type

Ktable object

create_mix_ktable5d(self, bg_comp={}, vgas_comp={}, x_array=None, bg_inac_species=[], vgas_inac_species=[], **kwargs)[source]

Creates a Ktable5d for a mix of molecules with a variable gas. In essence, the regular create_mix_ktable is called to create two mixes:

  • The background mix specified by composition=bg_comp, inactive_species=bg_inac_species

  • The variable gas specified by composition=vgas_comp, inactive_species=vgas_inac_species

See create_mix_ktable() for details.

These two gases are then mixed together for an array of vmr x_array where var_gas has a vmr of x_array and the background gas has a vmr of 1.-x_array


A new ktable for the mix with a dimension for the vmr of the variable gas.

Return type

Ktable5d object