@author: jeremy leconte

Module Contents

class Hires_spectrum(filename, file_kdata_unit='unspecified', kdata_unit='unspecified', mult_factor=None, binary=False, **kwargs)[source]

Bases: 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).

  • filename (str) – Full pathname to the file. Extension defines the format used.

  • file_kdata_unit (str) – 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)

  • kdata_unit (str) – Unit to convert to.

  • mult_factor (float) – A multiplicative factor that can be applied to kdata (for example to correct for any dilution effect, or specific conversion).

see read_ascii() for additional arguments to use with ascii files

read_ascii(self, filename, data_type=None, skiprows=0, wn_column=None, kdata_column=None)[source]

Read native kspectrum format

  • filename (str) – Initial hires-spectrum filename.

  • data_type ('xsec' or 'abs_coeff') – Whether the data read are cross-sections or absorption coefficients.

  • skiprows (int, optional) – Number of header lines to skip. For the latest Kspectrum format, the header is skipped automatically.

  • wn_column/kdata_column (int, optional) – Number of column to be read for wavenumber and kdata in python convention (0 is first, 1 is second, etc.)

write_hdf5(self, filename)[source]

Writes kspectrum file to hdf5

read_hdf5(self, filename)[source]

Reads kspectrum file from hdf5

read_binary(self, filename, mass_amu=None)[source]

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).

convert_kdata_unit(self, kdata_unit='unspecified', file_kdata_unit='unspecified')[source]

Converts kdata to a new unit (inplace)

  • kdata_unit (str) – 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.

  • file_kdata_unit (str) – 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)

plot_spectrum(self, ax, x_axis='wls', xscale=None, yscale=None, x=1.0, **kwarg)[source]

Plot the spectrum

  • ax (pyplot.Axes) – A pyplot axes instance where to put the plot.

  • x_axis (str, optional) – If ‘wls’, x axis is wavelength. Wavenumber otherwise.

  • x/yscale (str, optional) – If ‘log’ log axes are used.

convert_data_type(self, pressure, temperature, kdata_unit=None, convert_to=None)[source]

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.

  • pressure (float) – Pressure used for the conversion (in Pa)

  • temperature (float) – Temperature used for the conversion (in K)

  • kdata_unit (str (optional)) – Unit to use for the output

  • convert_to (str ('xsec' or 'abs_coeff', optional)) – Data type to convert to. Nothing is done if convert_to is equal to self.data_type. If None, converts to the other type.

clip_spectral_range(self, wn_range=None, wl_range=None)[source]

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