Skip to content

Commit 6f11257

Browse files
committed
minor updates to atom properties
functions_crystallography.py - added keywords for properties files
1 parent 1f58f80 commit 6f11257

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Dans_Diffraction/data/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The data is taken from a number of sources:
3131
* Element weights and radii: [Wikipedia](http://en.wikipedia.org/wiki/List_of_elements_by_atomic_properties)
3232
* X-ray Mass Attenuation Coefficients: [NIST](https://www.nist.gov/pml/x-ray-mass-attenuation-coefficients)
3333
* X-ray Atomic Scattering Factors: [CXRO](http://henke.lbl.gov/optical_constants/asf.html)
34-
* X-ray edges: [x-ray database](http://xdb.lbl.gov/Section1/Table_1-1.pdf)
34+
* X-ray edges: [x-ray database](https://xdb.lbl.gov/Section1/Sec_1-1.html)
3535
* Electron configurations: [Wikipedia](https://en.wikipedia.org/wiki/Electron_configurations_of_the_elements_(data_page))
3636
* Space Group symmetry operations: [Bilbao Crystallographic Server](https://www.cryst.ehu.es/)
3737

Dans_Diffraction/functions_crystallography.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@
7070
datadir = os.path.join(datadir, 'data')
7171
ATOMFILE = os.path.join(datadir, 'Dans Element Properties.txt')
7272
PENGFILE = os.path.join(datadir, 'peng.dat')
73+
WAASKIRF_FILE = os.path.join(datadir, 'f0_WaasKirf.dat')
7374
NSLFILE = os.path.join(datadir, 'neutron_isotope_scattering_lengths.dat')
7475
NSLFILE_SEARS = os.path.join(datadir, 'neutron_isotope_scattering_lengths_sears.dat')
7576
ASFFILE = os.path.join(datadir, 'atomic_scattering_factors.npy')
77+
XMAFILE = os.path.join(datadir, 'XRayMassAtten_mup.dat')
7678

7779
# List of Elements in order sorted by length of name
7880
ELEMENT_LIST = [
@@ -879,12 +881,12 @@ def atom_properties(elements=None, fields=None):
879881

880882
if elements is not None:
881883
# elements must be a list e.g. ['Co','O']
882-
elements = np.char.lower(np.asarray(elements).reshape(-1))
883-
all_elements = [el.lower() for el in data['Element']]
884+
elements = [str2element(el) for el in np.asarray(elements).reshape(-1)]
885+
all_elements = data['Element'].tolist()
884886
# This will error if the required element doesn't exist
885887
try:
886888
# regex to remove additional characters
887-
index = [all_elements.index(regex_sub_element.sub('', el)) for el in elements]
889+
index = [all_elements.index(el) for el in elements]
888890
except ValueError as ve:
889891
raise Exception('Element not available: %s' % ve)
890892
data = data[index]
@@ -1083,10 +1085,9 @@ def xray_scattering_factor_WaasKirf(element, Qmag=0):
10831085
:return: [m*n] array of scattering factors
10841086
"""
10851087

1086-
filename = os.path.join(datadir, 'f0_WaasKirf.dat')
1087-
data = np.loadtxt(filename)
1088+
data = np.loadtxt(WAASKIRF_FILE)
10881089
# get names
1089-
with open(filename) as f:
1090+
with open(WAASKIRF_FILE) as f:
10901091
lines = re.findall(r'#S\s+\d+\s+[A-Z].*?\n', f.read())
10911092
table_names = [line[7:].strip() for line in lines]
10921093

@@ -1215,8 +1216,7 @@ def attenuation(element_z, energy_kev):
12151216
element_z = np.asarray(element_z).reshape(-1)
12161217
energy_kev = np.asarray(energy_kev).reshape(-1)
12171218

1218-
xma_file = os.path.join(datadir, 'XRayMassAtten_mup.dat')
1219-
xma_data = np.loadtxt(xma_file)
1219+
xma_data = np.loadtxt(XMAFILE)
12201220

12211221
energies = xma_data[:, 0] / 1000.
12221222
out = np.zeros([len(energy_kev), len(element_z)])

0 commit comments

Comments
 (0)