:py:mod:`exo_k.cia_table` ========================= .. py:module:: exo_k.cia_table .. autoapi-nested-parse:: @author: jeremy leconte A class to handle continuum absorption (CIA) Module Contents --------------- .. py:class:: 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) Bases: :py:obj:`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. :param filename: Relative or absolute name of the file to be loaded. :type filename: :class:`str`, *optional* :param filename_filters: As many strings as necessary to uniquely define a file in the global search path defined with :func:`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 '*'. :type filename_filters: :class:`sequence` of :class:`string` :param molecule_pair: 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. :type molecule_pair: :class:`list` of :class:`size 2`, *optional* :param old_cia_unit: 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. :type old_cia_unit: :class:`str`, *optional* :param remove_zeros: If True, the zeros in the kdata table are replaced by a value 10 orders of magnitude smaller than the smallest positive value :type remove_zeros: :class:`boolean`, *optional* :param search_path: If search_path is provided, it locally overrides the global search path defined with :func:`exo_k.settings.Settings.set_cia_search_path` and only files in `search_path` are returned. :type search_path: :class:`str`, *optional* .. py:method:: _init_empty() Initializes attributes to none. .. py:method:: read_hitran_cia(filename, old_cia_unit='cm^5') Reads hitran cia files and load temperature, wavenumber, and absorption coefficient grid. :param filename: Name of the file to be read. :type filename: :class:`str` :param old_cia_unit: Units found in the file. :type old_cia_unit: :class:`str`, *optional* .. py:method:: _read_header(file) Reads the header lines in a Hitran CIA file. :param file: file to be read. :type file: :class:`file stream` .. py:method:: read_hdf5(filename, wn_range=None, wl_range=None) Reads hdf5 cia files and load temperature, wavenumber, and absorption coefficient grid. :param filename: Name of the file to be read. :type filename: :class:`str` .. py:method:: write_hdf5(filename) Writes hdf5 cia files. :param filename: Name of the file to be written. :type filename: :class:`str` .. py:method:: write_cia(filename) Writes simplified .cia files. To be consistent with Hitran CIA files, data is converted back to cm^5 before writing. :param filename: Name of the file to be written. :type filename: :class:`str` .. py:method:: sample(wngrid, remove_zeros=False, use_grid_filter=False, **kwargs) Method to re sample a cia table to a new grid of wavenumbers (inplace). :param wngrid: new wavenumber grid (cm-1) :type wngrid: :class:`array`, :class:`np.ndarray` :param use_grid_filter: 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. :type use_grid_filter: :class:`boolean`, *optional* .. py:method:: sample_cp(wngrid, **kwargs) Creates a copy of the object before resampling it. :param See sample method for details.: :returns: :class:`Cia_table` object the re-sampled :class:`Cia_table` .. py:method:: interpolate_cia(t_array=None, log_interp=None, wngrid_limit=None) interpolate_cia interpolates the kdata at on a given temperature profile. :param t_array: Temperature array to interpolate to. If a float is given, it is interpreted as an array of size 1. :type t_array: :class:`float` or :class:`array` :param wngrid_limit: If an array is given, interpolates only within this array. :type wngrid_limit: :class:`array`, :class:`np.ndarray`, *optional* :param log_interp: Whether the interpolation is linear in kdata or in log(kdata). :type log_interp: :class:`bool`, *optional* :returns: array of shape (logp_array.size, self.Nw) The interpolated kdata. .. py:method:: equivalent_xsec(logP, T, x_mol2, wngrid_limit=None) Computes the cross section due to CIA in area per molecule of type 1. .. py:method:: effective_cross_section(logP, T, x_mol1, x_mol2, wngrid_limit=None) Computes the total cross section for a molecule pair (in m^2 per total number of molecules; assumes data in MKS). :param logP: Log10 of the pressure (Pa). :type logP: :class:`float` or :class:`array` :param T: Temperature (K). :type T: :class:`float` or :class:`array` :param x_mol1/2: Volume mixing ratio of the 1st and 2nd molecule of the pair. :type x_mol1/2: :class:`float` or :class:`array` :param wngrid_limit: If an array is given, interpolates only within this array. :type wngrid_limit: :class:`array`, :class:`np.ndarray`, *optional* :returns: float or array total cross section for the molecule pair in m^2 per total number of molecules. .. py:method:: plot_spectrum(ax, t=200.0, x_axis='wls', xscale=None, yscale=None, **kwarg) Plot the spectrum for a given point :param ax: A pyplot axes instance where to put the plot. :type ax: :class:`pyplot.Axes` :param t: temperature(K) :type t: :class:`float` :param x_axis: If 'wls', x axis is wavelength. Wavenumber otherwise. :type x_axis: :class:`str`, *optional* :param x/yscale: If 'log' log axes are used. :type x/yscale: :class:`str`, *optional* .. py:method:: convert_abs_coeff_unit(abs_coeff_unit='unspecified', old_abs_coeff_unit='unspecified') Converts abs_coeff to a new unit (inplace). :param abs_coeff_unit: 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. :type abs_coeff_unit: :class:`str` :param old_abs_coeff_unit: 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) :type old_abs_coeff_unit: :class:`str`, *optional* .. py:method:: convert_to_mks(verbose=False) Converts units to MKS .. py:method:: remove_zeros(deltalog_min_value=0.0, **kwargs) 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. .. py:method:: copy() Creates a new instance of :class:`CIA_table` object and (deep) copies data into it .. py:method:: read_CKD_cia(filename, old_cia_unit='cm^2') Reads hitran cia files and load temperature, wavenumber, and absorption coefficient grid. :param filename: Name of the file to be read. :type filename: :class:`str` .. py:method:: effective_cross_section2(logP, T, x_mol1, x_mol2, wngrid_limit=None) Obsolete. Computes the total cross section for a molecule pair (in m^2 per total number of molecules; assumes data in MKS).