diff --git a/pyxem/tests/signals/test_diffraction2d.py b/pyxem/tests/signals/test_diffraction2d.py index b68bee7e9..08696c45d 100644 --- a/pyxem/tests/signals/test_diffraction2d.py +++ b/pyxem/tests/signals/test_diffraction2d.py @@ -620,11 +620,11 @@ def test_internal_azimuthal_integration_data_range(self, corner, shape): assert np.allclose(np.nanmax(pol.data), max_val) - # polar unwrapping `arange` should look like [3 1 0 2] + # polar unwrapping `arange` should look like [1 0 2 3] # since data looks like: # 0 1 # 2 3 - # and the data gets unwrapped from the center and downwards, using the right hand rule + # and the data gets unwrapped from the center to the right @pytest.mark.parametrize( [ "azimuthal_range", @@ -633,19 +633,19 @@ def test_internal_azimuthal_integration_data_range(self, corner, shape): [ [ (0 * np.pi / 2, 1 * np.pi / 2), - 3, + 1, ], [ (1 * np.pi / 2, 2 * np.pi / 2), - 1, + 0, ], [ (2 * np.pi / 2, 3 * np.pi / 2), - 0, + 2, ], [ (3 * np.pi / 2, 4 * np.pi / 2), - 2, + 3, ], ], ) diff --git a/pyxem/utils/calibration.py b/pyxem/utils/calibration.py index 01b969b7c..0f9fc57f8 100644 --- a/pyxem/utils/calibration.py +++ b/pyxem/utils/calibration.py @@ -409,6 +409,17 @@ def get_slices1d(self, npt, radial_range=None): return indexes, facts, factor_slices, radial_range def _get_slices_and_factors(self, npt, npt_azim, radial_range, azimuthal_range): + # In `_get_control_points`, positive x-direction is downwards, and positive y is to the right. + # This is 90 degrees off from the pyxem definition: + # https://pyxem.readthedocs.io/en/stable/tutorials/pyxem-demos/13%20Conventions.html + # As the azimuthal integration performed with a `Calibration`-object should align with + # the $X_L$ / $Y_L$-definitions in pyxem, we add pi/2 to the azimuthal range. + # This aligns the azimuthal angle 0 to $X_L$. + azimuthal_range = ( + azimuthal_range[0] + np.pi / 2, + azimuthal_range[1] + np.pi / 2, + ) + # get the points which bound each azimuthal pixel control_points = _get_control_points( npt, npt_azim, radial_range, azimuthal_range, self.affine