Using XrayDB from Python¶
The wrappers/python directly contains a Python module for XrayDB. This module gives a higher-level wrapping of the XrayDB, including the conversion of data from json-encoded data to numpy arrays. The module requires the json, numpy, and sqlalchemy modules, and can be installed with:
python setup.py install
XrayDB module¶
To use the XrayDB from python, create an instance, and start using it:
>>> from xraydb import XrayDB
>>> xdb = XrayDB()
>>> xdb.xray_edge('Ag', 'K')
XrayEdge(edge=25514.0, fyield=0.821892, jump_ratio=6.334)
Table of XrayDB methods for Atomic and X-ray data for the elements. calculate and return some element-specific properties, given the element symbol or atomic number. Most data extends to Z=98 (Cf), but much data for elements with atomic number > 92 (U) may not be available, and may not be very reliable when provided. Except where noted, the data comes from Elam et al.
XrayDB method description XrayDB.atomic_number()
atomic number from symbol XrayDB.atomic_number()
atomic number from symbol XrayDB.symbol()
atomic symbol from number XrayDB.molar_mass()
atomic mass XrayDB.density()
density of pure element XrayDB.xray_edge()
xray edge data for a particular element and edge XrayDB.xray_edges()
dictionary of all X-ray edges data for an element XrayDB.xray_lines()
dictionary of all X-ray emission line data for an element XrayDB.xray_line_strengths()
absolute line strength in cm^2/gr for all available lines XrayDB.mu_elam()
absorption cross sectionm photo-electric or total XrayDB.cross_section_elam()
photo-electric, coherent, or incoherent cross sections. XrayDB.corehole_width()
core level width for an element and edge () XrayDB.f0()
elastic scattering factor (Waasmaier and Kirfel ) XrayDB.f0_ions()
list of valid "ions" for f0()
(Waasmaier and Kirfel )XrayDB.chantler_energies()
energies of tabulation for Chantler data (Chantler ) XrayDB.f1_chantler()
\(f'(E)\) anomalous scattering factor (Chantler ) XrayDB.f2_chantler()
\(f"(E)\) anomalous scattering factor (Chantler ) XrayDB.mu_chantler()
absorption cross section (Chantler )
-
class
xraydb.
XrayDB
(dbname='xraydb.sqlite', read_only=True)¶ Database of Atomic and X-ray Data
This XrayDB object gives methods to access the Atomic and X-ray data in th SQLite3 database xraydb.sqlite.
Much of the data in this database comes from the compilation of Elam, Ravel, and Sieber, with additional data from Chantler, and other sources. See the documention and bibliography for a complete listing.
-
atomic_number
(element)¶ return element's atomic number
Parameters: element (string or int) -- atomic number or symbol Returns: atomic number Return type: integer
-
symbol
(element)¶ return element symbol
Parameters: element (string or int) -- atomic number or symbol Returns: element symbol Return type: string
-
molar_mass
(element)¶ return molar mass of element
Parameters: element (string or int) -- atomic number or symbol Returns: molar mass of element in amu Return type: float
-
density
(element)¶ return density of pure element
Parameters: element (string or int) -- atomic number or symbol Returns: density of element in gr/cm^3 Return type: float
-
xray_edges
(element)¶ returns dictionary of X-ray absorption edge energy (in eV), fluorescence yield, and jump ratio for an element.
Parameters: element (string or int) -- atomic number or symbol Returns: - keys of edge (iupac symbol), and values of
- XrayEdge namedtuple of (energy, fyield, edge_jump))
Return type: dictionary References
Elam, Ravel, and Sieber.
-
xray_edge
(element, edge)¶ returns XrayEdge for an element and edge
Parameters: - element (string or int) -- atomic number or symbol
- edge (string) -- X-ray edge
Returns: namedtuple of (energy, fyield, edge_jump))
Return type: XrayEdge
Example
>>> xdb = XrayDB() >>> xdb.xray_edge('Co', 'K') XrayEdge(edge=7709.0, fyield=0.381903, jump_ratio=7.796)
References
Elam, Ravel, and Sieber.
-
xray_lines
(element, initial_level=None, excitation_energy=None)¶ returns dictionary of X-ray emission lines of an element, with
Parameters: - initial_level (string or list/tuple of string) -- initial level(s) to limit output.
- excitation_energy (float) -- energy of excitation, limit output those excited by X-rays of this energy (in eV).
Returns: keys of lines (iupac symbol), values of Xray Lines
Return type: dictionary
Notes
if both excitation_energy and initial_level are given, excitation_level will limit output
Example
>>> xdb = XrayDB() >>> for key, val in xdb.xray_lines('Ga', 'K').items(): >>> print(key, val) 'Ka3', XrayLine(energy=9068.0, intensity=0.000326203, initial_level=u'K', final_level=u'L1') 'Ka2', XrayLine(energy=9223.8, intensity=0.294438, initial_level=u'K', final_level=u'L2') 'Ka1', XrayLine(energy=9250.6, intensity=0.57501, initial_level=u'K', final_level=u'L3') 'Kb3', XrayLine(energy=10263.5, intensity=0.0441511, initial_level=u'K', final_level=u'M2') 'Kb1', XrayLine(energy=10267.0, intensity=0.0852337, initial_level=u'K', final_level=u'M3') 'Kb5', XrayLine(energy=10348.3, intensity=0.000841354, initial_level=u'K', final_level=u'M4,5')
References
Elam, Ravel, and Sieber.
-
xray_line_strengths
(element, excitation_energy=None)¶ return the absolute line strength in cm^2/gr for all available lines
Parameters: - element (string or int) -- Atomic symbol or number for element
- excitation_energy (float) -- incident energy, in eV
Returns: elemental line with fluorescence cross section in cm2/gr.
Return type: dictionary
References
Elam, Ravel, and Sieber.
-
ck_probability
(element, initial, final, total=True)¶ return Coster-Kronig transition probability for an element and initial/final levels
Parameters: - element (string or int) -- Atomic symbol or number for element
- initial (string) -- initial level
- final (string) -- final level
- total (bool) -- whether to return total or partial probability
Returns: transition probability
Return type: float
Example
>>> xdb = XrayDB() >>> xdb.CK_probability('Cu', 'L1', 'L3', total=True) 0.681
References
Elam, Ravel, and Sieber.
-
corehole_width
(element, edge)¶ returns core hole width for an element and edge
Parameters: - element (string, integer) -- atomic number or symbol for element
- edge (string) -- edge for hole.
Returns: corehole width in eV.
Return type: float
References
Keski-Rahkonen and Krause
-
cross_section_elam
(element, energies, kind='photo')¶ returns Elam Cross Section values for an element and energies
Parameters: - element (string or int) -- atomic number or symbol for element
- energies (float or ndarray) -- energies (in eV) to calculate cross-sections
- kind (string) -- one of 'photo', 'coh', and 'incoh' for photo-absorption, coherent scattering, and incoherent scattering cross sections, respectively. Default is 'photo'.
Returns: ndarray of scattering data
References
Elam, Ravel, and Sieber.
-
mu_elam
(element, energies, kind='total')¶ returns attenuation cross section for an element at energies (in eV)
Parameters: - element (string or int) -- atomic number or symbol for element
- energies (float or ndarray) -- energies (in eV) to calculate cross-sections
- kind (string) -- one of 'photo' or 'total' for photo-electric or total attenuation, respectively. Default is 'total'.
Returns: ndarray of scattering values in units of cm^2/gr
References
Elam, Ravel, and Sieber.
-
chantler_energies
(element, emin=0, emax=1000000000.0)¶ return array of energies (in eV) at which data is tabulated in the Chantler tables for a particular element.
Parameters: - element (string or int) -- atomic number or symbol
- emin (float) -- minimum energy (in eV) [0]
- emax (float) -- maximum energy (in eV) [1.e9]
Returns: energies
Return type: ndarray
References
Chantler
-
f1_chantler
(element, energy, **kws)¶ returns f1 -- real part of anomalous X-ray scattering factor for selected input energy (or energies) in eV.
Parameters: - element (string or int) -- atomic number or symbol
- energy (float or ndarray) -- energies (in eV).
Returns: real part of anomalous scattering factor
Return type: ndarray
References
Chantler
-
f2_chantler
(element, energy, **kws)¶ returns f2 -- imaginary part of anomalous X-ray scattering factor for selected input energy (or energies) in eV.
Parameters: - element (string or int) -- atomic number or symbol
- energy (float or ndarray) -- energies (in eV).
Returns: imaginary part of anomalous scattering factor
Return type: ndarray
References
Chantler
-
mu_chantler
(element, energy, incoh=False, photo=False)¶ returns X-ray mass attenuation coefficient, mu/rho in cm^2/gr for selected input energy (or energies) in eV. default is to return total attenuation coefficient.
Parameters: - element (string or int) -- atomic number or symbol
- energy (float or ndarray) -- energies (in eV).
- photo (bool) -- return only the photo-electric contribution [False]
- incoh (bool) -- return only the incoherent contribution [False]
Returns: mass attenuation coefficient in cm^2/gr
Return type: ndarray
References
Chantler
-
f0_ions
(element=None)¶ return list of ion names supported for the .f0() function.
Parameters: element (string, int, pr None) -- atomic number, symbol, or ionic symbol of scattering element. Returns: - if element is None, all 211 ions are returned.
- if element is not None, the ions for that element are returned
Return type: list Example
>>> xdb = XrayDB() >>> xdb.f0_ions('Fe') ['Fe', 'Fe2+', 'Fe3+']
Notes
Z values from 1 to 98 (and symbols 'H' to 'Cf') are supported.
References
Waasmaier and Kirfel
-
f0
(ion, q)¶ return f0(q) -- elastic X-ray scattering factor from Waasmaier and Kirfel
Parameters: - ion (string, int, or None) -- atomic number, symbol or ionic symbol of scattering element.
- q (float, list, ndarray) -- value(s) of q for scattering factors
Returns: elastic scattering factors
Return type: ndarray
Example
>>> xdb = XrayDB() >>> xdb.f0('Fe', range(10)) array([ 25.994603 , 6.55945765, 3.21048827, 1.65112769, 1.21133507, 1.0035555 , 0.81012185, 0.61900285, 0.43883403, 0.27673021])
Notes
q = sin(theta) / lambda, where theta = incident angle, and lambda = X-ray wavelength
References
Waasmaier and Kirfel
-