:py:mod:`exo_k.gas_mix` ======================= .. py:module:: exo_k.gas_mix .. autoapi-nested-parse:: @author: jeremy leconte Module Contents --------------- .. py:class:: Gas_mix(composition=None, logp_array=None, t_array=None, k_database=None, cia_database=None) Bases: :py:obj:`exo_k.util.spectral_object.Spectral_object` Dict-like class to handle gas composition (with background gas) and molar mass. If `logp_array`, `t_array`, and radiative databases are provided, :any:`cross_section` can be used to compute the opacity of the gas __init_ Instantiates a Gas_mix object and computes the vmr of the 'background' gas. .. py:method:: set_composition(composition) Reset composition and computes the vmr of the 'background' gas. :param composition: Keys are molecule names. Values are vmr or arrays of vmr. :type composition: :class:`dict` :param bg_gas: Name of the background molecule. If None, it is inferred from the molecule for which vmr='background'. :type bg_gas: :class:`str` .. py:method:: set_logPT(logp_array=None, t_array=None) Sets the pressure (in Pa) and temperature fields. .. py:method:: get_background_vmr() Computes the volume mixing ratio of the background gas in a mix Uses the fact that self.composition is a dictionary with the name of the molecules as keys and the vmr as values. vmr are either float or arrays. At this stage, the background gas should be identified by `self.bg_gas`, and its Vol. Mix. Ratio will be updated in the composition dict. .. py:method:: normalize() Renormalizes the vmr of all the gases so that the total be equal to 1. This works only if the vmr of 'inactive_gas' is not 0. .. py:method:: molar_mass() Computes and returns the molar mass of a mix of gases :returns: float or array: Molar mass of the active gases in kg/mol .. py:method:: cp() Computes and returns the specific heat capacity (cp) of a mix of gases :returns: float or array: Specific cp of the gas mix .. py:method:: get_vmr_array(sh=None) Returns a dictionary with an array of vol. mix. ratios for each species. :param sh: shape of the array wanted if all the vmr are floats. If some are already arrays, check whether the shape is the correct one. :type sh: :class:`set` or :class:`list` :returns: vmr_array: dict A dictionary with the an array of vmr per species. cst_array: boolean Is True if all the values in the arrays are constant. .. py:method:: get_q_array(sh=None) Returns a dictionary with an array of specific concentrations for each species. :param sh: shape of the array wanted if all the vmr are floats. If some are already arrays, check whether the shape is the correct one. :type sh: :class:`set` or :class:`list` :returns: q_array: dict A dictionary with the an array of specific concentration per species. cst_array: boolean Is True if all the values in the arrays are constant. .. py:method:: get_vmr_array_basic_molecules(sh=None) Returns a dictionary with an array of vol. mix. ratios for each and decomposes gas mixtures into basic molecules. :returns: vmr_array_basic_mol: dictionary of arrays A dictionary with the an array of vmr per species. Each species is considered a basic molecule. vmr_array: dictionary of arrays A dictionary with the an array of vmr per species. Species in this dictionary can be a gas mixture. cst_array: boolean Is True if all the values in the arrays are constant. .. py:method:: set_k_database(k_database=None) Change the radiative database attached to the current instance of Gas_mix :param k_database: New Kdatabase to use. :type k_database: :class:`~exo_k.kdatabase.Kdatabase` object .. py:method:: set_cia_database(cia_database=None) Changes the CIA database attached to the current instance of Gas_mix :param cia_database: New CIAdatabase to use. :type cia_database: :class:`~exo_k.ciadatabase.CIAdatabase` object .. py:method:: set_spectral_range(wn_range=None, wl_range=None) Sets the default spectral range in which computations will be done by specifying either the wavenumber or the wavelength range. :param wn_range: Minimum and maximum wavenumber (in cm^-1). :type wn_range: :class:`list` or :class:`array` of :class:`size 2` :param wl_range: Minimum and maximum wavelength (in micron) :type wl_range: :class:`list` or :class:`array` of :class:`size 2` .. py:method:: _compute_wn_range_indices(wn_range=None) Compute the starting and ending indices to be used for current wn_range .. py:method:: cross_section(composition=None, logp_array=None, t_array=None, wl_range=None, wn_range=None, rayleigh=True, write=0, random_overlap=False, logp_interp=True, use_basic_molecules=False, inactive_molecules=None, **kwargs) Computes the cross section (m^2/total number of molecule) for the mix at each of the logPT points as a function of wavenumber (and possibly g point). :param wl_range: Wavelength range to cover. :type wl_range: :class:`array`, :class:`np.ndarray` or :class:`list` of :class:`two values`, *optional* :param wn_range: Wavenumber range to cover. :type wn_range: :class:`array`, :class:`np.ndarray` or :class:`list` of :class:`two values`, *optional* :param rayleigh: Whether to compute rayleigh scattering. :type rayleigh: :class:`boolean`, *optional* :param random_overlap: Whether Ktable opacities are added linearly (False), or using random overlap method (True). :type random_overlap: :class:`boolean`, *optional* :returns: * kdata_array: array, np.ndarray Cross section array of shape (layer number, Nw (, Ng if corrk)). * :class:`After every computation`, :class:`the following variables are updated` to :class:`account for any possible` * :class:`change in spectral range` -- * self.Nw, Number of wavenumber bins * self.wns, Wavenumber array * self.wnedges, Wavenumber of the edges of the bins .. py:method:: rosseland_mean_opacity(per_unit_mass=True, **kwargs) Computes Rosseland mean opacities in area per unit of mass of matter. The unit for area is determined by the data used. In MKS,it will be m^2. .. py:method:: planck_mean_opacity(t_blackbody, per_unit_mass=True, **kwargs) Computes Plank mean opacities in area per unit of mass of matter. The unit for area is determined by the data used. In MKS,it will be m^2. .. py:method:: items() Emulates dict.items() method .. py:method:: values() Emulates dict.values() method .. py:method:: keys() Emulates dict.keys() method .. py:method:: copy() Deep copy of the dict and arrays. The databases are not deep copied. .. py:method:: mix_with(other_gas, vmr_other_gas) :abstractmethod: Mix with other Gas_mix. .. py:class:: Known_composite_species Bases: :py:obj:`exo_k.util.singleton.Singleton` A class to store composite gas mixes that can be used in other gas mixes This class can also store the molar mass of custom gases with arbitrary names (for example: My_gas, earth_background). .. py:method:: init(*args, **kwds) Initializes empty dictionary of custom molecular masses. .. py:method:: add_species(species_dict) Add one or several composite species to the database. :param species_dict: Keys are gases names (they do not have to be real molecules). Values are a gas_mix object. :type species_dict: :class:`dict` .. py:method:: items() Emulates dict.items() method .. py:method:: values() Emulates dict.values() method .. py:method:: keys() Emulates dict.keys() method