Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase consistency in where the Rowland tori are oriented #247

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions marxs/design/rowland.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,11 @@ def double_rowland_from_channel_distance(d_BF, R, f):
(r + R) * np.sin(-alpha),
0]

orientm = [[-np.cos(alpha), np.sin(alpha), 0],
[-np.sin(alpha), -np.cos(alpha), 0],
[0., 0., 1]]

orientm = [
[np.cos(-alpha), np.sin(-alpha), 0],
[-np.sin(-alpha), np.cos(-alpha), 0],
[0.0, 0.0, 1],
]

geometry = {'d_BF': d_BF,
'd': d,
Expand Down
19 changes: 18 additions & 1 deletion marxs/design/tests/test_design.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Licensed under GPL version 3 - see LICENSE.rst
import numpy as np
from numpy.testing import assert_allclose
from scipy.stats import kstest
import transforms3d
import pytest
Expand Down Expand Up @@ -496,4 +497,20 @@ def test_offset_double_rowland_channels():
'2m': [0, 2.5, 12.5],
})
assert geom['pos_opt_ax']['2m'] == pytest.approx([0, 302.5, 12.5, 1. ])
assert geom['rowland_1'].geometry['center'] == pytest.approx([7.48596673, 297.12570166, -7.5, 1.])
assert geom['rowland_1'].geometry['center'] == pytest.approx([7.48596673, 297.12570166, -7.5, 1.])


def test_rowlands_are_oriented_the_same_way():
"""When there are two rowland tori, they should be oriented the same way."""
double = double_rowland_from_channel_distance(100, 500, 1000.0)
add_offset_double_rowland_channels(
double, offsets={"1": [0, -5, 0], "1m": [0, +5, 0]}
)
assert_allclose(
double["rowland_central"].parametric(0, 0),
double["rowland_central_m"].parametric(0, 0),
)
# The "top" points in the same direction. Of course, they are offset from each other
# so the numbers are not exactly the same.
assert_allclose(double["rowland_1"].parametric(0, 0), [1000.0, -55.0, 0.0, 1.0])
assert_allclose(double["rowland_1m"].parametric(0, 0), [1000.0, 55.0, 0.0, 1.0])