Skip to content

Commit 4801d6a

Browse files
authored
Merge pull request #830 from HEXRD/amorphous-fix
Amorphous fix
2 parents 314c567 + 36d2865 commit 4801d6a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

hexrd/wppf/WPPF.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,18 +1573,28 @@ def _set_params_vals_to_class(self, params, init=False, skip_phases=False):
15731573
self.amorphous_model.center = center
15741574
self.amorphous_model.fwhm = fwhm
15751575

1576+
@property
1577+
def total_area(self):
1578+
tth, intensity = self.spectrum_sim.data
1579+
_, background = self.background.data
1580+
total_intensity = intensity-background
1581+
'''put some guard rails around the total intensity
1582+
to protect against nans in the values
1583+
'''
1584+
mask = np.isnan(total_intensity)
1585+
sum_area = np.trapz(total_intensity[~mask], tth[~mask])
1586+
return sum_area
1587+
1588+
15761589
@property
15771590
def DOC(self):
15781591
if self.amorphous_model is None:
15791592
return 1.
15801593
else:
1581-
tth, intensity = self.spectrum_sim.data
1582-
_, background = self.background.data
1583-
total_intensity = intensity-background
15841594
amorphous_area = \
15851595
self.amorphous_model.integrated_area
1586-
return 1. - amorphous_area/np.trapz(
1587-
total_intensity, tth)
1596+
total_area = self.total_area
1597+
return 1. - amorphous_area/total_area
15881598

15891599

15901600
def _nm(x):

hexrd/wppf/amorphous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ def fwhm(self, val):
312312
def amorphous_lineout(self):
313313
if self.model_type == "experimental":
314314

315+
lo = np.zeros_like(self.tth_list)
315316
for key in self.shift:
316-
lo = np.zeros_like(self.tth_list)
317317
smooth_model_data = gaussian_filter(
318318
self.model_data[key],
319319
self.smoothing

0 commit comments

Comments
 (0)