:py:mod:`exo_k.kdatabase` ========================= .. py:module:: exo_k.kdatabase .. autoapi-nested-parse:: @author: jeremy leconte Module Contents --------------- .. py:class:: Kdatabase(molecules, *str_filters, search_path=None, remove_zeros=True, **kwargs) Bases: :py:obj:`exo_k.util.spectral_object.Spectral_object` This object contains mainly a dictionary of individual :class:`~exo_k.ktable.Ktable` or :class:`~exo_k.xtable.Xtable` 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 :param molecules: * 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 :class:`~exo_k.settings.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. :type molecules: :class:`list` or :class:`dict` :param search_path: If search_path is provided, it locally overrides the global _search_path settings and only files in search_path are returned. :type search_path: :class:`str`, *optional* See also the options of :class:`~exo_k.ktable.Ktable` >>> Kdatabase(None) Loads an empty database to be filled later with :func:`~exo_k.kdatabase.Kdatabase.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. .. py:method:: add_ktables(*ktables) Adds as many :class:`~exo_k.ktable.Ktable` or :class:`~exo_k.xtable.Xtable` to the database as you want (inplace). :param ktables: Tables to be added. :type ktables: :class:`Ktable` or :class:`Xtable` objects .. py:method:: copy() Creates a new instance of :class:`~exo_k.kdatabase.Kdatabase` object and (deep) copies data into it .. py:method:: remap_logPT(logp_array=None, t_array=None) 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 :func:`exo_k.data_table.Data_table.remap_logPT` for details. .. py:method:: bin_down(wnedges=None, **kwargs) 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 :func:`exo_k.ktable.Ktable.bin_down` or :func:`exo_k.xtable.Xtable.bin_down` for details. .. py:method:: bin_down_cp(wnedges=None, **kwargs) Creates a copy of the database and bins it down. :param See `bin_down` for details on parameters: :returns: :class:`Kdatabase` object The binned down database .. py:method:: sample(wngrid, **kwargs) 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. .. py:method:: sample_cp(wngrid, **kwargs) Creates a copy of the database and re-samples it. :param See `sample` for details on parameters: :returns: :class:`Kdatabase` object The re-sampled database .. py:method:: clip_spectral_range(wn_range=None, wl_range=None) 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 .. py:method:: convert_p_unit(p_unit='unspecified') Converts pressure unit of all Data_tables (inplace). See Data_table.convert_p_unit() for details. .. py:method:: convert_kdata_unit(kdata_unit='unspecified') Converts kdata unit of all Data_tables (inplace). See Data_table.convert_kdata_unit() for details. .. py:method:: convert_to_mks() Converts units of all `Data_table`s to MKS (inplace) .. py:method:: create_mix_ktable(composition, inactive_species=None, cia_database=None, verbose=False, mol=None, random_overlap=True) Creates a :class:`~exo_k.ktable.Ktable` or :class:`~exo_k.xtable.Xtable` for a mix of molecules. The table is computed over the P,T grid of the `Kdatabase` instance. :param composition: 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 :class:`Gas_mix` object. In particular, if a value is 'background', this gas will be used to fill up to sum(vmr)=1 (See :class:`~exo_k.gas_mix.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. :type composition: :class:`dict` :param inactive_species: List the gases that are in composition but for which we do not want the opacity to be accounted for. :type inactive_species: :class:`list`, *optional* :param cia_database: If a `CIAdatabase` is provided, cia opacity is added to the resulting table. :type cia_database: :class:`~exo_k.ciadatabase.CIAdatabase` :param verbose: Enables verbose mode. :type verbose: :class:`bool` :returns: :class:`~exo_k.ktable.Ktable` or :class:`~exo_k.xtable.Xtable` object A new `Ktable`or `Xtable` for the mix. .. py:method:: create_mix_ktable5d(bg_comp = None, vgas_comp = None, x_array=None, bg_inac_species = None, vgas_inac_species = None, mol=None, **kwargs) 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 :func:`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 :returns: :class:`~exo_k.ktable5d.Ktable5d` object A new ktable for the mix with a dimension for the vmr of the variable gas. .. py:method:: blackbody(temperature, integral=True) Computes the surface black body flux (in W/m^2/cm^-1) at temperature. :param temperature: Blackbody temperature :type temperature: :class:`float` :param integral: * 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. :type integral: :class:`boolean`, *optional* :returns: Spectrum object Spectral flux in W/m^2/cm^-1