exo_k.xtable

@author: jeremy leconte

Module Contents

class Xtable(*filename_filters, filename=None, p_unit='unspecified', file_p_unit='unspecified', kdata_unit='unspecified', file_kdata_unit='unspecified', remove_zeros=False, search_path=None, mol=None)[source]

Bases: exo_k.data_table.Data_table

A class that handles tables of cross sections.

Initializes cross section table and supporting data from a file based on its extension.

Parameters
  • filename (str) – Relative or absolute path to the input file.

  • filename_filters (sequence of string) – As many strings as necessary to uniquely define a file in the global search path defined in Settings. This path will be searched for a file with all the filename_filters in the name. The filename_filters can contain ‘*’.

If there is no filename or filename_filters provided, just creates an empty object to be filled later

See Ktable __init__ mehthod for documentation on p_unit, file_p_unit, kdata_unit, file_kdata_unit, remove_zeros, search_path, and mol keywords.

read_hdf5(self, filename=None, mol=None)[source]

Initializes k coeff table and supporting data from an Exomol hdf5 file

Parameters
  • filename (str) – Name of the input hdf5 file

  • mol (str, optional) – Overrides the name of the molecule to be put in the Xtable object.

write_hdf5(self, filename, compression='gzip', compression_level=9, kdata_unit=None, p_unit=None, exomol_units=False)[source]

Saves data in a hdf5 format

Parameters
  • filename (str) – Name of the file to be created and saved

  • exomol_units (bool (optional)) – If True, data are converted back to cm^2 and bar units before being written.

read_exo_transmit(self, filename, mol=None)[source]

Creates an xsec object from an exo_transmit like spectra. See https://github.com/elizakempton/Exo_Transmit or Kempton et al. (2016) for details. Pressures are expected to be in Pa and cross sections in m^2/molecule

Parameters
  • filename (str) – Name of the input file.

  • mol (str) – Overrides the name of the molecule to be put in the Xtable object.

hires_to_xtable(self, path=None, filename_grid=None, logpgrid=None, tgrid=None, write=0, mol=None, grid_p_unit='Pa', p_unit='unspecified', kdata_unit='unspecified', file_kdata_unit='unspecified', **kwargs)[source]

Loads an Xtable from high-resolution spectra (inplace).

Warning

By default, log pressures are specified in Pa in logpgrid!!! If you want to use another unit, do not forget to specify it with the grid_p_unit keyword.

see exo_k.ktable.Ktable.hires_to_ktable() method for details on the arguments and options.

bin_down(self, wnedges=None, remove_zeros=False, write=0)[source]

Method to bin down a xsec table to a new grid of wavenumbers (inplace).

Parameters
  • wnedges (array) – Edges of the new bins of wavenumbers (cm-1) onto which the xsec should be binned down. if you want Nwnew bin in the end, wngrid.size must be Nwnew+1 wnedges[0] should be greater than self.wnedges[0] wnedges[-1] should be lower than self.wnedges[-1]

  • remove_zeros (bool, optional) – If True, remove zeros in kdata.

sample(self, wngrid, remove_zeros=False, log_interp=None)[source]

Method to re sample a xsec table to a new grid of wavenumbers (inplace).

Parameters

wngrid (array) – Location of the new wavenumbers points (cm-1)

sample_cp(self, wngrid, **kwargs)[source]

Creates a copy of the instance before resampling it.

Parameters

sample method for details. (See) –

Returns

the re-sampled Xtable

Return type

Xtable object

spectrum_to_plot(self, p=1e-05, t=200.0, x=1.0, g=None)[source]

provide the spectrum for a given point to be plotted

Parameters
  • p (float) – Pressure (Ktable pressure unit)

  • t (float) – Temperature(K)

  • x (float) – Volume mixing ratio of the species

  • g (is unused but here to be consistent with the method in data_table) –

copy(self, cp_kdata=True)[source]

Creates a new instance of Xtable object and (deep) copies data into it

Parameters

cp_kdata (bool, optional) – If false, the kdata table is not copied and only the structure and metadata are.

Returns

A new Xtable instance with the same structure as self.

Return type

Xtable

property shape(self)

Returns the shape of self.kdata

read_pickle(self, filename=None)[source]

Initializes xsec table and supporting data from an Exomol pickle file

Parameters
  • filename (str) – Relative or absolute name of the input pickle file

  • mol (str, optional) – Overrides the name of the molecule to be put in the Xtable object.

write_pickle(self, filename)[source]

Saves data in a pickle format

Parameters

filename (str) – Relative or absolute name of the file to be created and saved