The PeriodicTable class#

class rockverse.dualenergyct.PeriodicTable(zgroup)[source]#

Manages periodic table information for the Monte Carlo Dual Energy Computed Tomography (DECT) processing. This class allows for the retrieval and modification of atomic numbers and masses for elements used in DECT processing.

Note

This class is designed to be created and managed within the main Group. It should not be called directly.

Parameters:

zgroup (zarr.hierarchy.Group) – The Zarr group where the main Group is stored.

Examples

Create a dual energy CT group. The periodic table will be created using default values:

>>> import drp
>>> dectgroup = drp.dualenergyct.create_group('/path/to/group/dir')
>>> dectgroup.periodic_table

You can get the values for a specific element using a key in the format ‘<element>/Z’ for atomic number or ‘<element>/M’ for atomic mass:

>>> dectgroup.periodic_table['O/Z'] # Oxygen atomic number
8
>>> dectgroup.periodic_table['C/M'] # Carbon atomic mass
12.011

If you want to fine tune Z or M values, you can set new values just like you get current values:

>>> dectgroup.periodic_table['C/M']  get current value
12.011
>>> dectgroup.periodic_table['C/M'] = 12.109999 # set new value
>>> dectgroup.periodic_table['C/M'] # check...
12.109999

Exceptions will be raised if the element is not in the table, if value for Z is not a positive integer, or if value for M is not a positive integer or float.

Methods#

PeriodicTable.as_dict()[source]#

Returns the periodic table as a dictionary.

Example

>>> import drp
>>> dectgroup = drp.dualenergyct.create_group('/path/to/group/dir')
>>> dectgroup.periodic_table.as_dict()
{'Ac': {'M': 227.0278, 'Z': 89},
'Ag': {'M': 107.868, 'Z': 47},
'Al': {'M': 26.98154, 'Z': 13},
'Am': {'M': 243, 'Z': 95},
.
.
.
'Xe': {'M': 131.3, 'Z': 54},
'Y': {'M': 88.9059, 'Z': 39},
'Yb': {'M': 173.04, 'Z': 70},
'Zn': {'M': 65.38, 'Z': 30},
'Zr': {'M': 91.22, 'Z': 40}}
PeriodicTable.as_dataframe()[source]#

Returns the periodic table as a pandas DataFrame.

Example

>>> import drp
>>> dectgroup = drp.dualenergyct.create_group('/path/to/group/dir')
>>> dectgroup.periodic_table.as_dataframe()
    Z          M
H     1    1.00797
He    2    4.00260
Li    3    6.94100
Be    4    9.01218
B     5   10.81000
..  ...        ...
Sg  106  263.00000
Bh  107  262.00000
Hs  108  255.00000
Mt  109  256.00000
Ds  110  269.00000
PeriodicTable.add_element(name, Z, M)[source]#

Adds a new element to the periodic table.

Parameters:
  • name (str) – The name of the element.

  • Z (int) – The atomic number of the element.

  • M (int or float) – The atomic mass of the element.

Example

Use this method to add new elements to the table:

>>> dectgroup.periodic_table['Hi/M'] # This will raise KeyError
...
KeyError: 'Element Hi not found in database.'
>>> dectgroup.periodic_table.add_element(name='Hi', Z=123, M=244.345)
>>> dectgroup.periodic_table['Hi/Z']
123
>>> dectgroup.periodic_table['Hi/M']
244.345