:py:mod:`exo_k.util.user_func` ============================== .. py:module:: exo_k.util.user_func .. autoapi-nested-parse:: @author: jeremy leconte Library of useful functions for users (only). Functions here CANNOT be called into the library itself: importing this module in others would lead to recursive import problems. Module Contents --------------- .. py:function:: create_table(logpgrid=None, tgrid=None, xgrid=None, wngrid=None, wnedges=None, ggrid=None, weights=None, p_unit='Pa', kdata_unit='m^2/molecule', value=None, mol=None) Create a new table with the required dimensions padded with zeros. The class of the object created will depend on the dimensions required. :param logpgrid: Grid in log p :type logpgrid: :class:`array`, :class:`np.ndarray` :param tgrid: Grid in T :type tgrid: :class:`array`, :class:`np.ndarray` :param xgrid: Grid in volume mixing ratio :type xgrid: :class:`array`, :class:`np.ndarray` :param wngrid: Grid wavenumber :type wngrid: :class:`array`, :class:`np.ndarray` :param ggrid: Grid g-space :type ggrid: :class:`array`, :class:`np.ndarray` :param weights: Grid of quadrature weights :type weights: :class:`array`, :class:`np.ndarray` :param p_unit: Unit of pressure (default Pa) :type p_unit: :class:`str (optional)` :param kdata_unit: Unit of cross section (default is m^2/molecule) :type kdata_unit: :class:`str (optional)` :returns: new_table: `Xtable`, `Ktable`, or `Ktable5d` A new table .. py:function:: hires_to_ktable(filename_grid=None, xgrid=None, **kwargs) Emulates :func:`exo_k.ktable.Ktable.hires_to_ktable` and :func:`exo_k.ktable5d.Ktable5d.hires_to_ktable` as functions and not methods so that the user can call them without creating a Ktable first. See those methods for details on the available arguments and options. .. py:function:: hires_to_xtable(**kwargs) Emulates :func:`exo_k.xtable.Xtable.hires_to_xtable` as a function and not a method so that the user can call it without creating an Xtable first. See :func:`~exo_k.xtable.Xtable.hires_to_xtable` for details on the available arguments and options. .. py:function:: convert_kspectrum_to_hdf5(file_in, file_out=None, **kwargs) Converts kspectrum like spectra to hdf5 format for speed and space. Helper function. Real work done in :class:`~exo_k.util.hires_spectrum.Hires_spectrum` __init__ funtion. Go there to see all the available arguments and options. :param file_in: Initial kspectrum filename. :type file_in: :class:`str` :param file_out: Name of the final hdf5 file to be created. If not provided, 'file_in.h5' will be used. :type file_out: :class:`str` .. py:function:: create_fname_grid(base_string, logpgrid=None, tgrid=None, xgrid=None, p_kw=None, t_kw=None, x_kw=None) Creates a grid of filenames from an array of pressures, temperatures ( and vmr if there is a variable gas). :param base_string: Generic name of the spectra files with specific keywords to be replaced by the relevant numerical values :type base_string: :class:`str` :param logpgrid: Grid in log(pressure/Pa) of the input :type logpgrid: :class:`Array` :param tgrid: Grid in temperature of the input :type tgrid: :class:`Array` :param xgrid: Input grid in vmr of the variable gas :type xgrid: :class:`Array` .. warning:: The result of this function is much more predictable if the values in the above arrays are given as integers or directly strings. If you want to use floats anyway, good luck. :param p_kw: :type p_kw: :class:`str` :param t_kw: :type t_kw: :class:`str` :param x_kw: The pattern string that will be recognized as keywords between {} in base_string (See examples). :type x_kw: :class:`str` .. rubric:: Examples >>> logpgrid=[1,2] >>> tgrid=np.array([100.,150.,200.]) >>> file_grid=exo_k.create_fname_grid('spectrum_CO2_1e{logp}Pa_{t}K.hdf5', logpgrid=logpgrid,tgrid=tgrid,p_kw='logp',t_kw='t') array([['spectrum_CO2_1e1Pa_100K.hdf5', 'spectrum_CO2_1e1Pa_150K.hdf5', 'spectrum_CO2_1e1Pa_200K.hdf5'], ['spectrum_CO2_1e2Pa_100K.hdf5', 'spectrum_CO2_1e2Pa_150K.hdf5', 'spectrum_CO2_1e2Pa_200K.hdf5']], dtype='