nubase_database_sgl

class reactions.nubase_database_sgl

Bases: object

Object to serve as an interface with the NuBase database. This object is declared as a singleton, using a single database file that can be modified using the set_database_path() function. This ensures that reactions are composed of NuBase elements from the same file. The database can make use of an internal cache to avoid reading from the file many times.

Methods Summary

__call__(arg)

Access an element of the database by name or NuBase ID

all_elements

Extract all the elements to a list.

clear_cache

Clear the internal cache, removing also user-registered elements

disable_cache

Disable the internal cache

enable_cache

Enable the internal cache.

get_database_path

Get the path to the database file

register_element

Register a new element in the database.

set_database_path(path)

Set the path to the database file.

Methods Documentation

__call__(arg)

Access an element of the database by name or NuBase ID

Parameters

arg (str or int) – Element name or NuBase ID

Returns

Corresponding element

Return type

nubase_element

Raises

reactions.LookupError – If the element is not found

all_elements()

Extract all the elements to a list. This includes all those elements registered by the user.

Returns

All the elements

Return type

list(nubase_element)

clear_cache()

Clear the internal cache, removing also user-registered elements

disable_cache()

Disable the internal cache

enable_cache()

Enable the internal cache. All the elements will be loaded in memory.

get_database_path()

Get the path to the database file

Returns

Path to the database file

Return type

str

register_element()

Register a new element in the database. Arguments can be either a single NuBase element object or the arguments to the constructor of reactions.nubase_element.

set_database_path(path)

Set the path to the database file. If the cache is enabled, reloads the data. If the cache is enabled, elements are reloaded in memory.

Parameters

path – Path to the database file.