radis.api.dbmanager module

Database manager for RADIS line databases.

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

download_and_parse(urlnames, local_files, N_files_total=None)[source]
fetch_filenames(urlnames, local_databases)[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(return_reg_urls=False)[source]

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

Parameters:

return_reg_urls ((boolean)) – When the database is registered, whether to return the registered urls (True) or None (False)

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(","))]
    
parse_to_local_file(opener, urlname, local_file, pbar_active=True, pbar_t0=0, pbar_Ntot_estimate_factor=None, pbar_Nlines_already=0, pbar_last=True) list[source]

This function should be overwritten by the DatabaseManager subclass

Uncompress urlname into local_file. Also add metadata

Returns:

  • list (list of urlnames)

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

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”})

class RequestsFileOpener(file_path)[source]

Bases: object

Simple file opener class that mimics the behavior of numpy.DataSource using the requests pip package.

abspath(url_or_path=None)[source]

Return the absolute path of the file

open(url_or_path=None)[source]

Open the file for reading

get_auto_MEMORY_MAPPING_ENGINE()[source]

see https://github.com/radis/radis/issues/653

Use Vaex by default if it exists (only Python <= 3.11 as of June 2024) , else use PyTables

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"

And if the molecule is in MOLECULES_LIST_NONEQUILIBRIUM:

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

Return type:

None