Skip to content

Commit

Permalink
Change default direction of angle 0 in azimuthal integration
Browse files Browse the repository at this point in the history
  • Loading branch information
viljarjf committed Apr 27, 2024
1 parent cfb91a9 commit f1fd4e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyxem/tests/signals/test_diffraction2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
],
],
)
Expand Down
11 changes: 11 additions & 0 deletions pyxem/utils/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1fd4e4

Please sign in to comment.