Skip to content

Commit 81ace0c

Browse files
authored
Merge pull request #823 from HEXRD/wppf-amorphous-fixes
Implement a few various fixes for WPPF amorphous
2 parents f205782 + c4d9193 commit 81ace0c

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

hexrd/wppf/WPPF.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@ def peakshape(self, val):
996996
"""
997997
if hasattr(self, "params"):
998998
params = wppfsupport._generate_default_parameters_LeBail(
999-
self.phases, self.peakshape, self.bkgmethod
999+
self.phases, self.peakshape, self.bkgmethod,
1000+
amorphous_model=self.amorphous_model,
10001001
)
10011002
for p in params:
10021003
if p in self.params:
@@ -1343,7 +1344,7 @@ def params(self, param_info):
13431344
self.peakshape,
13441345
self.bkgmethod,
13451346
init_val=self.cheb_init_coef,
1346-
amorphous_model=self.amorphous_model
1347+
amorphous_model=self.amorphous_model,
13471348
)
13481349
self._params = params
13491350

@@ -1577,7 +1578,7 @@ def DOC(self):
15771578
if self.amorphous_model is None:
15781579
return 1.
15791580
else:
1580-
tth, intensity = self.spectrum_expt.data
1581+
tth, intensity = self.spectrum_sim.data
15811582
_, background = self.background.data
15821583
total_intensity = intensity-background
15831584
amorphous_area = \
@@ -2569,7 +2570,7 @@ def params(self, param_info):
25692570
self.peakshape,
25702571
self.bkgmethod,
25712572
init_val=self.cheb_init_coef,
2572-
amorphous_model=self.amorphous_model
2573+
amorphous_model=self.amorphous_model,
25732574
)
25742575
self._params = params
25752576

@@ -2957,7 +2958,8 @@ def peakshape(self, val):
29572958
self.phases,
29582959
self.peakshape,
29592960
self.bkgmethod,
2960-
init_val=self.cheb_init_coef
2961+
init_val=self.cheb_init_coef,
2962+
amorphous_model=self.amorphous_model,
29612963
)
29622964
for p in params:
29632965
if p in self.params:

hexrd/wppf/amorphous.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
_split_unit_gaussian as sp_gauss,
77
_split_unit_pv as sp_pv)
88

9+
10+
AMORPHOUS_MODEL_TYPES = {
11+
'Split Gaussian': 'split_gaussian',
12+
'Split Pseudo-Voigt': 'split_pv',
13+
'Experimental': 'experimental',
14+
}
15+
16+
917
class Amorphous:
1018
'''
1119
>> @AUTHOR: Saransh Singh,
@@ -112,7 +120,12 @@ def __init__(self,
112120
center = {'c1': 30.}
113121

114122
if fwhm is None:
115-
fwhm = {'c1': np.array([5, 5])}
123+
if model_type == 'split_pv':
124+
array = np.array([5, 5, 5, 5])
125+
else:
126+
array = np.array([5, 5])
127+
128+
fwhm = {'c1': array}
116129

117130
self.tth_list = tth_list
118131

@@ -147,7 +160,10 @@ def tth_list(self):
147160

148161
@tth_list.setter
149162
def tth_list(self, val):
150-
if isinstance(val, np.ndarray):
163+
if isinstance(val, np.ma.MaskedArray):
164+
print('here')
165+
self._tth_list = val.filled()
166+
elif isinstance(val, np.ndarray):
151167
self._tth_list = val
152168
elif isinstance(val, (list, tuple)):
153169
self._tth_list = np.array(val)
@@ -300,6 +316,7 @@ def amorphous_lineout(self):
300316
for key in self.center:
301317
p = np.hstack((self.center[key],
302318
self.fwhm[key]))
319+
303320
lo += self.scale[key]*self.peak_model(p, self.tth_list)
304321

305322
return lo

hexrd/wppf/wppfsupport.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,13 @@ def convert(**kwargs):
406406

407407
if amorphous_model.model_type == "split_gaussian":
408408
params.add(f'{key}_amorphous_fwhm_l', **convert(
409-
nn,
410409
value=amorphous_model.fwhm[key][0],
411410
min=0,
412411
max=np.inf,
413412
vary=False,
414413
))
415414

416415
params.add(f'{key}_amorphous_fwhm_r', **convert(
417-
nn,
418416
value=amorphous_model.fwhm[key][1],
419417
min=0,
420418
max=np.inf,

0 commit comments

Comments
 (0)