e15190.utilities.atomic_mass_evaluation.DataManager¶
- class e15190.utilities.atomic_mass_evaluation.DataManager(force_download=False, auto_read_in=True)¶
A class to interacts with the atomic masses. Many kinematic calculations require the knowledge of masses of atomic isotopes. This class allows user to automatically download the data sheet of Atomic Mass Evaluation to local machine, and perform some simple query tasks on the table.
Functions
__init__([force_download, auto_read_in])A local copy has to be present before any query task can be made.
auto_column_splitter(content)This function automatically separates the columns of an ASCII table.
download([filepath, url])Download AME data from the web.
read_in_data([filepath])Updates class attribute self.df into formatted AME data.
Properties
https://www-nds.iaea.org/amdc/ame2016/mass16.txtPROJECT_DIR / 'database/utilities/mass16.txt'Dataframe for storing AME data
Specifying units for every column in
self.dfDictionary mapping atomic number to chemical symbol
Dictionary mapping chemical symbol to atomic number
- __init__(force_download=False, auto_read_in=True)¶
A local copy has to be present before any query task can be made. Hence this initializer downloads the data if local copy is not present yet, or the user has decided to turn on the
force_downloadoption.- Parameters
bool (auto_read_in, default True) – If True, a new local copy will always be downloaded from the
ame_url. If False, the program only downloads the data when no local copy is found.bool – If True, the data will be read in. If False, user has to manually call
DataManager.read_in_data().
- ame_url¶
https://www-nds.iaea.org/amdc/ame2016/mass16.txt- Type
str
- ame_loc_path¶
PROJECT_DIR / 'database/utilities/mass16.txt'- Type
pathlib.Path
- df¶
Dataframe for storing AME data
- Type
pandas.DataFrame
- units¶
Specifying units for every column in
self.df- Type
dict
- Z_to_symb¶
Dictionary mapping atomic number to chemical symbol
- Type
dict
- symb_to_Z¶
Dictionary mapping chemical symbol to atomic number
- Type
dict
- download(filepath=None, url=None)¶
Download AME data from the web.
- Parameters
filepath (str or pathlib.Path, default None) – The local filepath that store the downloaded data. Default is None, which will then be set into
self.ame_loc_path.url (str or pathlib.Path, default None) – The url to the AME data. Default is None, which will then be set into
self.ame_url.
- read_in_data(filepath=None)¶
Updates class attribute self.df into formatted AME data.
This function only reads from a local copy of AME data. Make sure the data has been downloaded from the web. Not all columns from AME data will be kept. The columns that will be returned are Z, A, symb, mass_excess and mass_excess_err. Other columns including isospin, binding energy (and its error) and mass in a.m.u (and its error) are discarded as they can all be calculated directly from mass excess.
No unit conversion has been made. The AME provides mass excess in \(\mathrm{keV}/c^2\). Nonetheless, units have been stored as
self.units.Parameters: filepath : str or pathlib.Path, default None
The local filepath that store the downloaded data. Default is None, which will then be set into
self.ame_loc_path.
- static auto_column_splitter(content)¶
This function automatically separates the columns of an ASCII table.
This function can separate the columns of .txt tables that use space characters as their delimiters.
- Parameters
content (list of str) – A list of strings that correspond to the content of the ASCII table. Each element in the list, which is a string, corresponds to each row of the table. These strings can be either ended with the newline character or not. The row of column names or headers should not be included.
- Returns
splitted_content
- Return type
2D list of str
Examples
>>> from e15190.utilities import atomic_mass_evaluation as ame >>> dm = ame.DataManager() >>> content = ['Amy 168.5cm', 'Bob 181.9cm', 'Cici 157.3cm'] >>> dm.auto_column_splitter(content) [['Amy ', '168.5cm'], ['Bob ', '181.9cm'], ['Cici ', '157.3cm']]