diff --git a/hexrdgui/calibration/wppf_options_dialog.py b/hexrdgui/calibration/wppf_options_dialog.py index afd850903..a7b102d8b 100644 --- a/hexrdgui/calibration/wppf_options_dialog.py +++ b/hexrdgui/calibration/wppf_options_dialog.py @@ -341,12 +341,13 @@ def write_data(self, filename: str | Path) -> None: # Prepare the data to write out two_theta, intensity = obj.spectrum_sim.x, obj.spectrum_sim.y + weights = obj.weights.y bkg = obj.background.y data = { 'two_theta': two_theta, 'intensity': intensity, 'lineout_intensity': lineout_intensity, - 'difference_curve': intensity - lineout_intensity, + 'difference_curve': (intensity - lineout_intensity) * np.sqrt(weights), 'background': bkg, } if obj.amorphous_model is not None: diff --git a/hexrdgui/image_canvas.py b/hexrdgui/image_canvas.py index 00b4fcd84..bcb2439c1 100644 --- a/hexrdgui/image_canvas.py +++ b/hexrdgui/image_canvas.py @@ -2020,6 +2020,10 @@ def update_wppf_plot(self) -> None: if is_percent: # Express `y` as a percentage instead y *= 100 / last_lineout[1].filled(np.nan) + else: + denom = np.sqrt(last_lineout[1].filled(np.nan)) + denom[denom == 0] = np.nan + y /= denom (self.wppf_difference_plot,) = diff_axis.plot(x, y, **style) @@ -2027,15 +2031,8 @@ def update_wppf_plot(self) -> None: diff_axis.relim() diff_axis.autoscale_view(scalex=False) - if is_percent: - # Force an auto-scale - diff_axis.autoscale(enable=True, axis='y') - else: - # When the difference plot resets, always set it to be - # initially the same y range as the azimuthal. - new_ymin = min(diff_axis.get_ylim()[0], -axis.get_ylim()[1]) - new_ymax = max(diff_axis.get_ylim()[1], axis.get_ylim()[1]) - diff_axis.set_ylim((new_ymin, new_ymax)) + # Force an auto-scale + diff_axis.autoscale(enable=True, axis='y') # Update the difference label even if there's no data self.update_wppf_difference_labels() @@ -2048,7 +2045,7 @@ def update_wppf_difference_labels(self) -> None: if HexrdConfig().show_wppf_difference_as_percent: label = r'WPPF Diff (%)' else: - label = r'WPPF Diff' + label = r'$\Delta$I/$\sigma$(I)' axis.set_ylabel(label, **self.label_kwargs_polar_y)