:py:mod:`exo_k.data_table` ========================== .. py:module:: exo_k.data_table .. autoapi-nested-parse:: @author: jeremy leconte Module Contents --------------- .. py:class:: Data_table Bases: :py:obj:`exo_k.util.spectral_object.Spectral_object` An abstract class that will serve as a basis for Ktable and Xtable. This class includes all the interpolation and remapping methods. Initializes all attributes to `None` .. py:property:: shape Returns the shape that self.kdata should have to be compatible with the parameter grid. .. py:property:: molar_mass Computes molar mass from molecule name .. py:method:: finalize_init(p_unit='unspecified', file_p_unit='unspecified', kdata_unit='unspecified', file_kdata_unit='unspecified', remove_zeros=False) Common code at the end of the initialization of inheriting classes put here to avoid duplicates .. py:method:: copy_attr(other, cp_kdata=False) Copy attributes from other :param other: :class:`Data_table` object that will be copied :type other: :class:`Data_table` :param cp_kdata: If `False`, only metadata are copied :type cp_kdata: :class:`bool`, *optional* .. py:method:: remove_zeros(deltalog_min_value=10.0) Finds zeros in the kdata 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. :param deltalog_min_value: :type deltalog_min_value: :class:`float` .. py:method:: convert_p_unit(p_unit='unspecified', file_p_unit='unspecified') Converts pressure to a new unit (inplace). :param p_unit: String identifying the pressure units to convert to (e.g. 'bar', 'Pa', 'mbar', or any pressure unit recognized by the astropy.units library). If ='unspecified', no conversion is done. :type p_unit: :class:`str` :param file_p_unit: String to specify the current pressure 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 pressure grid and the pressure unit do not correspond) :type file_p_unit: :class:`str`, *optional* .. py:method:: convert_kdata_unit(kdata_unit='unspecified', file_kdata_unit='unspecified') Converts kdata to a new unit (inplace). :param kdata_unit: String to identify the units to convert to. Accepts 'cm^2', 'm^2' or any surface unit recognized by the astropy.units library. If ='unspecified', no conversion is done. In general, kdata should be kept in 'per number' or 'per volume' units (as opposed to 'per mass' units) as composition will always be assumed to be a number or volume mixing ratio. Opacities per unit mass are not supported yet. Note that you do not need to specify the '/molec' or '/molecule' in the unit. :type kdata_unit: :class:`str` :param file_kdata_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 file_kdata_unit: :class:`str` .. py:method:: convert_to_mks() Converts units to MKS (inplace). .. py:method:: interpolate_kdata(logp_array=None, t_array=None, x_array=1.0, log_interp=None, logp_interp=True, wngrid_limit=None, **kwargs) interpolate_kdata interpolates the kdata at on a given temperature and log pressure profile. If a volume mixing ratio profile (`x_array`) is given, the cross section computed for the species is multiplied by `x_array` to account for the 'dilution' of the opacity. :param logp_array: log 10 pressure array to interpolate to :type logp_array: :class:`array`, :class:`np.ndarray` :param t_array: Temperature array to interpolate to :type t_array: :class:`array`, :class:`np.ndarray`, :class:`same size as logp_array` :param x_array: Volume mixing ratio array used to renormalize the cross section. :type x_array: :obj:`None` If floats are given, they are interpreted as arrays of size 1. :param wngrid_limit: if an array of to values is given, interpolates only within this array :type wngrid_limit: :class:`list` or :class:`array` :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 (, self.Ng)) The interpolated kdata. .. py:method:: remap_logPT(logp_array=None, t_array=None, x_array=None) remap_logPT re-interpolates the kdata on a new temperature and log pressure grid (inplace). :param logp_array: log 10 pressure array to interpolate to :type logp_array: :class:`Array` :param t_array: temperature array to interpolate to :type t_array: :class:`Array` :param x_array: :type x_array: :class:`dummy argument` to :class:`be consistent with interpolate_kdata in Ktable5d` Whether the interpolation is linear in kdata or in log10(kdata) is controlled by self._settings._log_interp .. py:method:: pindex(p) Finds and returns the index corresponding to the given pressure p (units must be the same as the ktable) .. py:method:: tindex(t) Finds and returns the index corresponding to the given temperature t (in K) .. py:method:: wlindex(wl) Finds and returns the index corresponding to the given wavelength (in microns) .. py:method:: plot_spectrum(ax, p=1e-05, t=200.0, x=1.0, g=None, 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 p: Pressure (Ktable pressure unit) :type p: :class:`float` :param t: Temperature (K) :type t: :class:`float` :param g: Gauss point :type g: :class:`float` :param x: Mixing ratio of the species :type x: :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:: spectrum_to_plot(p=1e-05, t=200.0, x=1.0, g=None) :abstractmethod: Dummy function to be defined in inheriting classes .. py:method:: vmr_normalize(x_self) Rescales kdata to account for the fact that the gas is not a pure species :param x_self: The volume mixing ratio of the species. :type x_self: :class:`float` or :class:`array` of :class:`shape (`self.Np,self.Nt`)` :returns: array The vmr normalized kdata (x_self*self.kdata). .. py:method:: combine_with(other, x_self=None, x_other=None, **kwargs) Method to create a new `Data_table` where the kdata of 'self' are: * randomly mixed with 'other' for a `Ktable`. * added to 'other' for an `Xtable` :param other: A :class:`Data_table` object to be mixed with. Dimensions should be the same as self. :type other: :class:`same class as self` :param x_self: Volume mixing ratio of self. :type x_self: :class:`float` or :class:`array`, *optional* :param x_other: Volume mixing ratio of the species to be mixed with (other). :type x_other: :class:`float` or :class:`array`, *optional* If either x_self or x_other are set to `None` (default), the cross section of the species in question are considered to be already normalized with respect to the mixing ratio. :returns: :class:`Data_table` A new table for the mix .. py:method:: set_kdata(new_kdata) Changes kdata (inplace). this is preferred to directly accessing kdata because this method checks that the array has the right dimensions :param new_kdata: New array of kdata. :type new_kdata: :class:`array`, :class:`np.ndarray` .. py:method:: clip_spectral_range(wn_range=None, wl_range=None) Limits the data to the provided spectral range (inplace): * Wavenumber in cm^-1 if using wn_range argument * Wavelength in micron if using wl_range .. py:method:: extend_spectral_range(wngrid_left=None, wngrid_right=None, wnedges_left=None, wnedges_right=None, remove_zeros=False) Extends the spectral range of an existing table (inplace). The new bins are filled with zeros (except if remove_zeros=True) :param wngrid_left: Array of wavenumbers to add to the small wn end of the table. :type wngrid_left: :class:`array`, :class:`np.ndarray` :param wngrid_right: Array of wavenumbers to add to the high wn end of the table. :type wngrid_right: :class:`array`, :class:`np.ndarray` .. warning:: There should not be any overlap between wngrid_left, wngrid_right, and the current wavenumber grid of the table. :param remove_zeros: Whether zeros in the resulting table should be removed using :func:`remove_zeros`. :type remove_zeros: :class:`bool (optional)` .. py:method:: bin_down_cp(wnedges=None, **kwargs) Creates a copy of the instance and bins it down using the methods in Ktable or Xtable. See :func:`exo_k.ktable.Ktable.bin_down` or :func:`exo_k.xtable.Xtable.bin_down` for details on parameters. :returns: :class:`~exo_k.ktable.Ktable` or :class:`~exo_k.xtable.Xtable` object The binned down table. .. py:method:: change_molecule_name(mol_name) Changes name of the molecule (self.mol attribute). :param mol_name: New molecule name :type mol_name: :class:`str` .. py:method:: blackbody(Temperature, **kwargs) See Spectral_object.blackbody .. py:method:: write_hdf5_common(f, compression='gzip', compression_level=9, p_unit=None) Method that writes datasets and attributes that are common to X and Ktables. :param f: The file to write that is created in daughter classes :type f: :class:`h5py file instance` .. py:method:: toLogK() Changes kdata to log 10. .. py:method:: toLinK() Changes kdata back from log to linear scale.