Skip to content

Commit f4f90ae

Browse files
authored
Merge pull request #2007 from HEXRD/wppf-diff
WPPF difference curve update.
2 parents 9aa279a + 101605f commit f4f90ae

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

hexrdgui/calibration/wppf_options_dialog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,13 @@ def write_data(self, filename: str | Path) -> None:
341341

342342
# Prepare the data to write out
343343
two_theta, intensity = obj.spectrum_sim.x, obj.spectrum_sim.y
344+
weights = obj.weights.y
344345
bkg = obj.background.y
345346
data = {
346347
'two_theta': two_theta,
347348
'intensity': intensity,
348349
'lineout_intensity': lineout_intensity,
349-
'difference_curve': intensity - lineout_intensity,
350+
'difference_curve': (intensity - lineout_intensity) * np.sqrt(weights),
350351
'background': bkg,
351352
}
352353
if obj.amorphous_model is not None:

hexrdgui/image_canvas.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,22 +2020,19 @@ def update_wppf_plot(self) -> None:
20202020
if is_percent:
20212021
# Express `y` as a percentage instead
20222022
y *= 100 / last_lineout[1].filled(np.nan)
2023+
else:
2024+
denom = np.sqrt(last_lineout[1].filled(np.nan))
2025+
denom[denom == 0] = np.nan
2026+
y /= denom
20232027

20242028
(self.wppf_difference_plot,) = diff_axis.plot(x, y, **style)
20252029

20262030
# Rescale
20272031
diff_axis.relim()
20282032
diff_axis.autoscale_view(scalex=False)
20292033

2030-
if is_percent:
2031-
# Force an auto-scale
2032-
diff_axis.autoscale(enable=True, axis='y')
2033-
else:
2034-
# When the difference plot resets, always set it to be
2035-
# initially the same y range as the azimuthal.
2036-
new_ymin = min(diff_axis.get_ylim()[0], -axis.get_ylim()[1])
2037-
new_ymax = max(diff_axis.get_ylim()[1], axis.get_ylim()[1])
2038-
diff_axis.set_ylim((new_ymin, new_ymax))
2034+
# Force an auto-scale
2035+
diff_axis.autoscale(enable=True, axis='y')
20392036

20402037
# Update the difference label even if there's no data
20412038
self.update_wppf_difference_labels()
@@ -2048,7 +2045,7 @@ def update_wppf_difference_labels(self) -> None:
20482045
if HexrdConfig().show_wppf_difference_as_percent:
20492046
label = r'WPPF Diff (%)'
20502047
else:
2051-
label = r'WPPF Diff'
2048+
label = r'$\Delta$I/$\sigma$(I)'
20522049

20532050
axis.set_ylabel(label, **self.label_kwargs_polar_y)
20542051

0 commit comments

Comments
 (0)