:py:mod:`exo_k.hires_spectrum` ============================== .. py:module:: exo_k.hires_spectrum .. autoapi-nested-parse:: @author: jeremy leconte Module Contents --------------- .. py:class:: Hires_spectrum(filename, file_kdata_unit='unspecified', kdata_unit='unspecified', mult_factor=None, binary=False, **kwargs) Bases: :py:obj:`exo_k.util.spectral_object.Spectral_object` A class defining a Hires_spectrum object. Reads a high-resolution spectrum from a file (either hdf5 or ascii). :param filename: Full pathname to the file. Extension defines the format used. :type filename: :class:`str` :param file_kdata_unit: Specifies the unit for the opacity data in the file. This is needed for ascii formats as the units are not known. The type of quantity may differ whether we are handling cross sections (surface) or absorption coefficients (inverse length) :type file_kdata_unit: :class:`str` :param kdata_unit: Unit to convert to. :type kdata_unit: :class:`str` :param mult_factor: A multiplicative factor that can be applied to kdata (for example to correct for any dilution effect, or specific conversion). :type mult_factor: :class:`float` see :func:`read_ascii` for additional arguments to use with ascii files .. py:method:: read_turbet(filename, data_type='abs_coeff', file_kdata_unit='cm^-1', wns=None, binary=False, wns_filename='sigma_grid.bin', **kwargs) Read native format from HR code by M. Turbet anf G. Chaverot :param filename: Initial hires-spectrum filename. :type filename: :class:`str` .. py:method:: read_ascii(filename, data_type=None, skiprows=0, wn_column=None, kdata_column=None) Read native kspectrum format :param filename: Initial hires-spectrum filename. :type filename: :class:`str` :param data_type: Whether the data read are cross-sections or absorption coefficients. :type data_type: ``'xsec'`` or ``'abs_coeff'`` :param skiprows: Number of header lines to skip. For the latest Kspectrum format, the header is skipped automatically. :type skiprows: :class:`int`, *optional* :param wn_column/kdata_column: Number of column to be read for wavenumber and kdata in python convention (0 is first, 1 is second, etc.) :type wn_column/kdata_column: :class:`int`, *optional* .. py:method:: write_hdf5(filename) Writes kspectrum file to hdf5 .. py:method:: read_hdf5(filename) Reads kspectrum file from hdf5 .. py:method:: read_binary(filename, mass_amu=None) Reads spectra file in binary format (petitRADTRANS style) Assumed to be in cm^2/g with wavelength in cm. Will be automatically converted to cm^2/molecule and wns in cm^-1 (unless conversion to mks is requested). .. 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:: plot_spectrum(ax, x_axis='wls', xscale=None, yscale=None, x=1.0, **kwarg) Plot the spectrum :param ax: A pyplot axes instance where to put the plot. :type ax: :class:`pyplot.Axes` :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_data_type(pressure, temperature, kdata_unit=None, convert_to=None) Converts from one data_type (cross sections or absorption coefficents) to the other (inplace). Conversion to mks is done by default if a conversion takes place and no kdata_unit is specified. :param pressure: Pressure used for the conversion (in Pa) :type pressure: :class:`float` :param temperature: Temperature used for the conversion (in K) :type temperature: :class:`float` :param kdata_unit: Unit to use for the output :type kdata_unit: :class:`str (optional)` :param convert_to: Data type to convert to. Nothing is done if convert_to is equal to self.data_type. If None, converts to the other type. :type convert_to: :class:`str (```'xsec'`` or ``'abs_coeff'``, :class:`optional)` .. 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