:py:mod:`exo_k.atable` ====================== .. py:module:: exo_k.atable .. autoapi-nested-parse:: @author: jeremy leconte A class to handle continuum absorption (CIA) Module Contents --------------- .. py:class:: Atable(*filename_filters, filename=None, aerosol_name=None, search_path=None, mks=False, remove_zeros=False, N_per_line=5, wn_range=None, wl_range=None) Bases: :py:obj:`exo_k.util.spectral_object.Spectral_object` A class to handle aerosol optical properties in table form. Initialization for Atables. :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 in :class:`~exo_k.settings.Settings`. 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 search_path: If search_path is provided, it locally overrides the global _search_path in :class:`~exo_k.settings.Settings` 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_LMDZ(filename, aerosol_name=None, N_per_line=5) Reads LMDZ like optical properties files. :param filename: Name of the file to be read. :type filename: :class:`str` .. py:method:: _read_arrays(file, Nvalue, Narray, N_per_line=5) Reads an array in an optical property LMDZ file. Assumes that the arrays are arranged 5 values per line. :param file: File to be read. :type file: :class:`file stream` :param Nvalue: Number of values to be read in each array. :type Nvalue: :class:`int` :param Narray: Number of arrays to be read. :type Narray: :class:`int` :param N_per_line: Number of values per lines :type N_per_line: :class:`int` :returns: Array A numpy array with the values. .. py:method:: read_hdf5(filename, aerosol_name=None, 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:: sample(wngrid, remove_zeros=False, use_grid_filter=False, sample_all_vars=True, **kwargs) Method to re sample an Atable to a new grid of wavenumbers (in place) :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* :param sample_all_vars: Whether to sample the single_scattering albedo and asymmetry_factor as well. :type sample_all_vars: :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:`Atable` object the re-sampled :class:`Atable` .. py:method:: interpolate_optical_properties(r_array=None, var_type=0, log_interp=None, wngrid_limit=None) interpolate_cia interpolates the kdata at on a given temperature profile. :param r_array: Effective radius array to interpolate to. If a float is given, it is interpreted as an array of size 1. :type r_array: :class:`float` or :class:`array` :param var_type: type of data to interpolate: * 0 is extinction coefficient * 1 is single scattering albedo * 2 is asymmetry factor :type var_type: :class:`int` :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* .. py:method:: cross_section(r_array, wngrid_limit=None, log_interp=None) Computes the cross section due to the aerosol in area per particles. :param r_array: Effective radius array to interpolate to. If a float is given, it is interpreted as an array of size 1. :type r_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* .. py:method:: absorption_coefficient(r_array, n_density, wngrid_limit=None, log_interp=None) Computes the opacity due to the aerosols. .. warning:: If n_density is the number density of aerosol particles (in m^-3), then the result is the absorption coefficient in m^-1. If n_density is the ratio of the number density of aerosol particles normalized to the number density of gas molecules (dimless), then the result is a cross section (in m^2) for aerosols normalized "per gas molecule". This latter choice allows us to directly add it to gaseous cross sections later-on without further normalizations. This is what needs to be used when coupling with the atmospheric model. :param r_array: Effective radius array to interpolate to. If a float is given, it is interpreted as an array of size 1. :type r_array: :class:`float` or :class:`1d array` :param n_density: Number density of aerosol or ratio of aerosol to gas particle number density (see above). :type n_density: :class:`float` or :class:`1d array (same dim as r_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* .. py:method:: optical_properties(r_array, n_density, wngrid_limit=None, log_interp=None, compute_all_opt_prop=True) Computes all the optical properties for the aerosols. .. warning:: If n_density is the number density of aerosol particles (in m^-3), then kdata is the absorption coefficient in m^-1. If n_density is the ratio of the number density of aerosol particles normalized to the number density of gas molecules (dimless), then kdata is a cross section (in m^2) for aerosols normalized "per gas molecule". This latter choice allows us to directly add it to gaseous cross sections later-on without further normalizations. This is what needs to be used when coupling with the atmospheric model. :param r_array: Effective radius array to interpolate to. If a float is given, it is interpreted as an array of size 1. :type r_array: :class:`float` or :class:`1d array` :param n_density: Number density of aerosol or ratio of aerosol to gas particle number density (see above). :type n_density: :class:`float` or :class:`1d array (same dim as r_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* .. py:method:: plot_spectrum(ax, r=1e-06, x_axis='wls', xscale=None, yscale=None, var_type=0, **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 r: Effective radius (m) :type r: :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_to_mks() Converts units to MKS .. py:method:: rindex(r) Finds the index corresponding to the given radius r (units must be the same as the ktable) .. py:method:: remove_zeros(deltalog_min_value=0.0) Finds zeros in the ext_coeff and set them to (10.^-deltalog_min_value) times the minimum positive value in the table. This is to be able to work in logspace. .. py:method:: copy() Creates a new instance of :class:`Atable` object and (deep) copies data into it .. py:method:: concatenate_spectral_range(atab1, atab2, verbose=False) :classmethod: Combine the instance of atable with another one for which there is some overlap of the spectral range. .. py:function:: combine_tables(aerosol_name, *atables) Combine several tables representing the same aerosol type for different wavelength range. Deprecated, use concatenate_spectral_range .. py:function:: interp_data(data_to_interp, rind, rweight, Nw, wngrid_filter, log_interp)