@@ -86,8 +86,10 @@ def fromStructure(cls, stru, sftb, q=0):
86
86
The structure object that stores the atom species and their
87
87
occupancies. Can be any type with a registered conversion
88
88
to the StructureAdapter class.
89
- sftb : ScatteringFactorTable
89
+ sftb : ScatteringFactorTable or str
90
90
The ScatteringFactorTable object for looking up the values.
91
+ When string use `ScatteringFactorTable.createByType` to create
92
+ a new lookup table of the specified type.
91
93
q : float or NumPy array (optional)
92
94
The Q value in inverse Angstroms for which to lookup
93
95
the scattering factor values.
@@ -127,8 +129,10 @@ def fromComposition(cls, composition, sftb, q=0):
127
129
composition : dictionary or a list of (symbol, amount) pairs.
128
130
The chemical composition for evaluating the average. Atom
129
131
symbols may repeat when it is a list of (symbol, amount) pairs.
130
- sftb : ScatteringFactorTable
132
+ sftb : ScatteringFactorTable or str
131
133
The ScatteringFactorTable object for looking up the values.
134
+ When string use `ScatteringFactorTable.createByType` to create
135
+ a new lookup table of the specified type.
132
136
q : float or NumPy array (optional)
133
137
The Q value in inverse Angstroms for which to lookup
134
138
the scattering factor values.
@@ -138,6 +142,7 @@ def fromComposition(cls, composition, sftb, q=0):
138
142
SFAverage
139
143
The calculated scattering factor averages.
140
144
"""
145
+ from diffpy .srreal .scatteringfactortable import ScatteringFactorTable
141
146
sfa = cls ()
142
147
sfa .composition = {}
143
148
if isinstance (composition , dict ):
@@ -149,8 +154,11 @@ def fromComposition(cls, composition, sftb, q=0):
149
154
sfa .composition [smbl ] += cnt
150
155
sfa .f1sum = 0.0 * q
151
156
sfa .f2sum = 0.0 * q
157
+ # resolve the lookup table object `tb`
158
+ tb = (sftb if not isinstance (sftb , basestring )
159
+ else ScatteringFactorTable .createByType (sftb ))
152
160
for smbl , cnt in sfa .composition .items ():
153
- sfq = sftb .lookup (smbl , q )
161
+ sfq = tb .lookup (smbl , q )
154
162
sfa .f1sum += cnt * sfq
155
163
sfa .f2sum += cnt * sfq ** 2
156
164
sfa .count += cnt
0 commit comments