exo_k.util.user_func
@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
- exo_k.util.user_func.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)[source]
Create a new table with the required dimensions padded with zeros.
The class of the object created will depend on the dimensions required.
- Parameters:
logpgrid (
array
,np.ndarray
) – Grid in log ptgrid (
array
,np.ndarray
) – Grid in Txgrid (
array
,np.ndarray
) – Grid in volume mixing ratiowngrid (
array
,np.ndarray
) – Grid wavenumberggrid (
array
,np.ndarray
) – Grid g-spaceweights (
array
,np.ndarray
) – Grid of quadrature weightsp_unit (
str (optional)
) – Unit of pressure (default Pa)kdata_unit (
str (optional)
) – Unit of cross section (default is m^2/molecule)
- Returns:
- new_table: Xtable, Ktable, or Ktable5d
A new table
- exo_k.util.user_func.hires_to_ktable(filename_grid=None, xgrid=None, **kwargs)[source]
Emulates
exo_k.ktable.Ktable.hires_to_ktable()
andexo_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.
- exo_k.util.user_func.hires_to_xtable(**kwargs)[source]
Emulates
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
hires_to_xtable()
for details on the available arguments and options.
- exo_k.util.user_func.convert_kspectrum_to_hdf5(file_in, file_out=None, **kwargs)[source]
Converts kspectrum like spectra to hdf5 format for speed and space. Helper function. Real work done in
Hires_spectrum
__init__ funtion.Go there to see all the available arguments and options.
- exo_k.util.user_func.create_fname_grid(base_string, logpgrid=None, tgrid=None, xgrid=None, p_kw=None, t_kw=None, x_kw=None)[source]
Creates a grid of filenames from an array of pressures, temperatures ( and vmr if there is a variable gas).
- Parameters:
base_string (
str
) – Generic name of the spectra files with specific keywords to be replaced by the relevant numerical valueslogpgrid (
Array
) – Grid in log(pressure/Pa) of the inputtgrid (
Array
) – Grid in temperature of the inputxgrid (
Array
) – Input grid in vmr of the variable gas
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.
- Parameters:
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='<U28')
- exo_k.util.user_func.finalize_LMDZ_dir(corrkname, IRsize, VIsize)[source]
Creates the right links for a LMDZ type directory to be read by the LMDZ generic GCM.
You will need to create a proper Q.dat before using with the LMDZ GCM.
Important
You must have run
exo_k.ktable.Ktable.write_LMDZ()
orexo_k.ktable5d.Ktable5d.write_LMDZ()
for both of your IR and VI channels beforehand.