radis.api.dbmanager module

class DatabaseManager(name, molecule, local_databases, engine, extra_params=None, verbose=False, parallel=True, nJobs=-2, batch_size='auto')[source]

Bases: object

Line Database parser

Parameters:
  • name (str) – database name as registered in ~/radis.json

  • molecule (str)

  • local_databases (str) – path to local database

  • engine (‘vaex’, ‘pytables’, ‘h5py’, or ‘default’) – memory-mapping library to use with this database. If ‘default’ use the value from ~/radis.json

Other Parameters:
  • *input for :class:`~joblib.parallel.Parallel` loading of database*

  • parallel (bool) – if True, use parallel loading. Default True.

  • nJobs (int) – Number of processors to use to load a database (useful for big databases). BE CAREFUL, no check is done on processor use prior to the execution ! Default -2: use all but 1 processors. Use 1 for single processor.

  • batch_size (int or 'auto') – The number of atomic tasks to dispatch at once to each worker. When individual evaluations are very fast, dispatching calls to workers can be slower than sequential computation because of the overhead. Batching fast computations together can mitigate this. Default: 'auto'

  • More information in :class:`joblib.parallel.Parallel`

add_column(df, key, value)[source]

Create column key in DataFrame or dictionary df with value value

check_deprecated_files(local_files, auto_remove=True)[source]

Check metadata of files and remove the deprecated ones

Unless auto_remove=False: Then raise an error

clean_download_files()[source]

Fully unzipped (and working, as it was reloaded): clean files

Note : we do not let np.DataSource clean its own tempfiles; as they may be downloaded but not fully parsed / registered.

download_and_parse(urlnames, local_files)[source]
fetch_filenames()[source]
fetch_urlnames() list[source]

“This function should be overwritten by the DatabaseManager subclass

Returns:

  • list (list of urlnames)

  • See for instance (py:class:`radis.api.hitempapi.HITEMPDatabaseManager)

get_columns(local_file)[source]

Get all columns using DataFileManager class get_columns function

get_datafile_manager(engine=None)[source]
get_existing_files(files)[source]

Return files that exist among files

See also

get_filenames()

get_filenames()[source]

Get names of all files in the database (even if not downloaded yet)

See also

get_files_to_download()

get_missing_files(files)[source]

Return files that do not exist among files

Note : in ‘vaex’ mode; if “FILE.hdf5” does not exist but “FILE.h5” does (a likely ‘pytables’ file), does not consider it missing so it can be converted automatically

See also

get_filenames()

get_nrows(local_file)[source]

Get number of rows (without loading all DataFrame)

get_today()[source]
is_downloadable()[source]
is_registered()[source]
load(local_files, columns=None, lower_bound=[], upper_bound=[], within=[], output='pandas')[source]
Other Parameters:
  • columns (list of str) – list of columns to load. If None, returns all columns in the file.

  • output (‘pandas’, ‘vaex’, ‘jax’) – format of the output DataFrame. If 'jax', returns a dictionary of jax arrays.

  • lower_bound (list of tuples [(column, lower_bound), etc.]) –

    lower_bound =[("wav", load_wavenum_min)]
    
  • upper_bound_bound (list of tuples [(column, upper_bound), etc.]) –

    upper_bound=[("wav", load_wavenum_max)]
    
  • within (list of tuples [(column, within_list), etc.]) –

    within=[("iso", isotope.split(","))]
    
plot(local_files, isotope, wavenum_min, wavenum_max)[source]

Convenience function to plot linestrengths of the database

register(dict_entries)[source]
remove_local_files(local_files)[source]
rename_columns(df, rename_dict)[source]

Example:

mdb.rename_columns(df, {“nu_lines”:”wav”})

open_zip(zipname, mode='r', encoding=None, newline=None)[source]
register_database(databank_name, dict_entries, verbose)[source]

Add to registered databases in RADIS config file.

If database exists, assert it has the same entries.

Parameters:

databank_name (str) – name of the database in ~/radis.json config file

Other Parameters:

verbose (bool)

Returns:

adds to ~/radis.json with all the input parameters. Also adds

format : "hitemp-radisdb"
parfuncfmt : "hapi"   # TIPS-2017 for equilibrium partition functions

And if the molecule is in MOLECULES_LIST_NONEQUILIBRIUM:

levelsfmt : "radis"   # use RADIS spectroscopic constants for rovibrational energies (nonequilibrium)

Return type:

None