Skip to content

Commit 3060f50

Browse files
authored
Merge pull request #826 from HEXRD/wppf-amorphous-fix
deal with cases where the input experimental liquid data grid is different from the experimental spectrum
2 parents 81ace0c + 83d1192 commit 3060f50

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

hexrd/wppf/amorphous.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,24 @@ def model_data(self, data):
180180
if self.model_type.lower() == "experimental":
181181
if data is not None:
182182
if isinstance(data, dict):
183-
self._model_data = data
183+
'''the liquid diffraction data might be
184+
on a different grid size and shape than the
185+
lineout. we will deal with that here via
186+
interpolation
187+
'''
188+
data_interp = dict.fromkeys(data.keys())
189+
for k, v in data.items():
190+
if v.ndim == 2:
191+
# potential case with different tth step size
192+
mi = np.nanmin(v[:,1])
193+
data_interp[k] = np.interp(self.tth_list,
194+
v[:, 0],
195+
v[:, 1],
196+
left=mi,
197+
right=mi)
198+
elif v.ndim == 1:
199+
data_interp[k] = v.copy()
200+
self._model_data = data_interp
184201
else:
185202
msg = f'data should be passed as a dictionary'
186203
raise ValueError(msg)
@@ -303,12 +320,13 @@ def amorphous_lineout(self):
303320
self.smoothing
304321
)
305322

323+
mi = np.nanmin(smooth_model_data)
306324
lo += self.scale[key]*np.interp(
307325
self.tth_list,
308326
self.tth_list+self.shift[key],
309-
smooth_model_data,
327+
smooth_model_data-mi,
310328
left=0.,
311-
right=0.)
329+
right=0.) + mi
312330

313331
elif self.model_type in ["split_gaussian",
314332
"split_pv"]:

0 commit comments

Comments
 (0)