exo_k.kdatabase
@author: jeremy leconte
Module Contents
- class exo_k.kdatabase.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
orXtable
objects for each molecule.In addition, the informations about the P, T, Wn, g grids are reloaded as attributes of the Kdatabase object.
Initializes k coeff tables and supporting data from a list of molecules
- Parameters:
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()
.Important
By default, Ktables have zeros removed when loaded to avoid log interpolation issues. You can avoid that with the remove_zeros=False keyword.
- ktables
- _settings
- consolidated_wn_grid = True
- consolidated_PT_grid = True
- consolidated_p_unit = True
- consolidated_kdata_unit = True
- N_ktable5d = 0
- molecules = None
- add_ktables(*ktables)[source]
Adds as many
Ktable
orXtable
to the database as you want (inplace).- Parameters:
ktables (
Ktable
orXtable
objects) – Tables to be added.
- remap_logPT(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(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()
orexo_k.xtable.Xtable.bin_down()
for details.
- bin_down_cp(wnedges=None, **kwargs)[source]
Creates a copy of the database and bins it down.
- Parameters:
parameters (See bin_down for details on)
- Returns:
Kdatabase
objectThe binned down database
- sample(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(wngrid, **kwargs)[source]
Creates a copy of the database and re-samples it.
- Parameters:
parameters (See sample for details on)
- Returns:
Kdatabase
objectThe re-sampled database
- clip_spectral_range(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(p_unit='unspecified')[source]
Converts pressure unit of all Data_tables (inplace). See Data_table.convert_p_unit() for details.
- convert_kdata_unit(kdata_unit='unspecified')[source]
Converts kdata unit of all Data_tables (inplace). See Data_table.convert_kdata_unit() for details.
- create_mix_ktable(composition, inactive_species=None, cia_database=None, verbose=False, mol=None, random_overlap=True)[source]
Creates a
Ktable
orXtable
for a mix of molecules.The table is computed over the P,T grid of the Kdatabase instance.
- Parameters:
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 aGas_mix
object. In particular, if a value is ‘background’, this gas will be used to fill up to sum(vmr)=1 (SeeGas_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.cia_database (
CIAdatabase
) – If a CIAdatabase is provided, cia opacity is added to the resulting table.verbose (
bool
) – Enables verbose mode.
- Returns:
- create_mix_ktable5d(bg_comp=None, vgas_comp=None, x_array=None, bg_inac_species=None, vgas_inac_species=None, mol=None, **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
- blackbody(temperature, integral=True)[source]
Computes the surface black body flux (in W/m^2/cm^-1) at temperature.
- Parameters:
temperature (
float
) – Blackbody temperatureintegral (
boolean
, optional) –If true, the black body is integrated within each wavenumber bin.
If not, only the central value is used. False is faster and should be ok for small bins, but True is the correct version.
- Returns:
- Spectrum object
Spectral flux in W/m^2/cm^-1