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:
objectLine 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. DefaultTrue.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. Use1for 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
keyin DataFrame or dictionarydfwith valuevalue
- 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
- 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_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) orNone(False)
See also
get_files_to_download()
- get_missing_files(files)[source]¶
Return files that do not exist among
filesNote : 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
- 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
urlnameintolocal_file. Also add metadata- Returns:
list (list of urlnames)
See for instance (py:class:`radis.api.hitempapi.HITEMPDatabaseManager)
- class RequestsFileOpener(file_path)[source]¶
Bases:
objectSimple file opener class that mimics the behavior of numpy.DataSource using the requests pip package.
- 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