radis.io.hitemp module

Created on Tue Jan 26 22:40:51 2021

@author: erwan

https://stackoverflow.com/questions/55610891/numpy-load-from-io-bytesio-stream https://stupidpythonideas.blogspot.com/2014/07/three-ways-to-read-files.html

class HITEMPDatabaseManager(name, molecule, local_databases, verbose=True, chunksize=100000)[source]

Bases: radis.io.dbmanager.DatabaseManager


requires connexion


requires connexion

get_linereturn_format(opener, urlname, columns)[source]
keep_only_relevant(inputfiles, wavenum_min=None, wavenum_max=None) list[source]

For CO2 and H2O, return only relevant files for given wavenumber range.

If other molecule, return the file anyway. see radis.io.hitemp.keep_only_relevant()

parse_to_local_file(opener, urlname, local_file, pbar_t0=0, pbar_Ntot_estimate_factor=None, pbar_Nlines_already=0, pbar_last=True, engine='pytables')[source]

Uncompress urlname into local_file. Also add metadata

  • opener (an opener with an .open() command)

  • gfile (file handler. Filename: for info)


register in ~/radis.json

engine required to differentiate ‘.h5’, ‘.hdf5’

fetch_hitemp(molecule, local_databases='~/.radisdb/hitemp/', databank_name='HITEMP-{molecule}', isotope=None, load_wavenum_min=None, load_wavenum_max=None, columns=None, cache=True, verbose=True, chunksize=100000, clean_cache_files=True, return_local_path=False, engine='pytables')[source]

Stream HITEMP file from HITRAN website. Unzip and build a HDF5 file directly.

Returns a Pandas DataFrame containing all lines.

  • molecule ("H2O", "CO2", "N2O", "CO", "CH4", "NO", "NO2", "OH") – HITEMP molecule. See https://hitran.org/hitemp/

  • local_databases (str) – where to create the RADIS HDF5 files. Default "~/.radisdb/"

  • databank_name (str) – name of the databank in RADIS Configuration file Default "HITEMP-{molecule}"

  • 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 wavenumbers.

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

Other Parameters
  • cache (bool, or 'regen') – if True, use existing HDF5 file. If False or 'regen', rebuild it.. Default True.

  • verbose (bool)

  • chunksize (int) – number of lines to process at a same time. Higher is usually faster but can create Memory problems and keep the user uninformed of the progress.

  • clean_cache_files (bool) – if True clean downloaded cache files after HDF5 are created.

  • return_local_path (bool) – if True, also returns the path of the local database file.

  • engine (‘pytables’, ‘vaex’) – which HDF5 library to use.


  • df (pd.DataFrame) – Line list A HDF5 file is also created in local_databases and referenced in the RADIS config file with name databank_name

  • local_path (str) – path of local database file if return_local_path


from radis import fetch_hitemp
df = fetch_hitemp("CO")
>>> Index(['id', 'iso', 'wav', 'int', 'A', 'airbrd', 'selbrd', 'El', 'Tdpair',
    'Pshft', 'ierr', 'iref', 'lmix', 'gp', 'gpp', 'Fu', 'branch', 'jl',
    'syml', 'Fl', 'vu', 'vl'],


if using load_only_wavenum_above/below or isotope, the whole database is anyway downloaded and uncompressed to local_databases fast access .HDF5 files (which will take a long time on first call). Only the expected wavenumber range & isotopes are returned. The .HFD5 parsing uses hdf2df()


Get non-empty lines of a chunk b, parsing the bytes.

keep_only_relevant(inputfiles, wavenum_min=None, wavenum_max=None) Union[list, float][source]

Parser file names for wavenum_format (min and max) and only keep relevant files if the requested range is [wavenum_min, wavenum_max]


  • relevant (list of relevant files)

  • files_wmin, files_wmax ((float, float) : wavenum min & max of relevant range)