radis.io.hdf5 module

Created on Tue Jan 26 21:27:15 2021

@author: erwan

class HDF5Manager(engine='pytables')[source]

Bases: object

add_metadata(fname: str, metadata: dict)[source]
classmethod guess_engine(file, verbose=True)[source]

Guess which HDF5 library file is compatible with

load(fname, columns=None, where=None, key='df', **store_kwargs) pandas.core.frame.DataFrame[source]

columns (list of str) – list of columns to load. If None, returns all columns in the file.

Other Parameters

key (store key in 'pytables' mode.)

open(file, mode='w')[source]
read_metadata(fname: str, key='df') dict[source]
Other Parameters

key (store key in 'pytables' mode.)

write(handler, df, append=True)[source]
hdf2df(fname, columns=None, isotope=None, load_wavenum_min=None, load_wavenum_max=None, verbose=True, store_kwargs={}, engine='auto')[source]

Load a HDF5 line databank into a Pandas DataFrame.

Adds HDF5 metadata in df.attrs

  • fname (str) – HDF5 file name

  • columns (list of str) – list of columns to load. If None, returns all columns in the file.

  • isotope (str) – load only certain isotopes : '2', '1,2', etc. If None, loads everything. Default None.

  • load_wavenum_min, load_wavenum_max (float (cm-1)) – load only specific wavelength.

Other Parameters
  • store_kwargs (dict) – arguments forwarded to read_hdf()

  • engine ('h5py', 'pytables', 'vaex', 'auto') – which HDF5 library to use. If 'auto', try to guess. Note: 'vaex' uses 'h5py' compatible HDF5.


df – dataframe containing all lines or energy levels

Return type

pandas Dataframe


path = getDatabankEntries("HITEMP-OH")['path'][0]
df = hdf2df(path)

df = hdf2df(path, columns=['wav', 'int'])

df = hdf2df(path, isotope='2')
df = hdf2df(path, isotope='1,2)

df = hdf2df(path, load_wavenum_min=2300, load_wavenum_max=2500)


DataFrame metadata in df.attrs is still experimental in Pandas and can be lost during groupby, pivot, join or loc operations on the Dataframe. See https://stackoverflow.com/questions/14688306/adding-meta-information-metadata-to-pandas-dataframe

Always check for existence !

update_pytables_to_vaex(fname, remove_initial=False, verbose=True)[source]

Convert a HDF5 file generated from PyTables to a Vaex-friendly HDF5 format, preserving metadata