Skip to content

Commit

Permalink
Merge pull request #247 from hamogu:rowlandorient
Browse files Browse the repository at this point in the history
Increase consistency in where the Rowland tori are oriented
  • Loading branch information
hamogu committed Feb 9, 2024
2 parents 318bf0c + da0ba93 commit f2ebb5b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
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])

0 comments on commit f2ebb5b

Please sign in to comment.