-
Notifications
You must be signed in to change notification settings - Fork 12
Vertical position derived signal for I23 Aithre goniometer #1164
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f4543ce
Add logic for vertical sample position to goniometer
JamesDoingStuff 196ac28
Change read signals to locatables in derived signal
JamesDoingStuff acb1ec0
Fix PVs used in derived signal
JamesDoingStuff 2a45ebc
Attempt fixing trigonometry of get function
JamesDoingStuff 0e53468
Revert "Attempt fixing trigonometry of get function"
JamesDoingStuff 0bbb065
Add omega to set function
JamesDoingStuff d9f8241
Appease codecov
JamesDoingStuff 807ed43
Lint
JamesDoingStuff b964077
Merge branch 'main' into mxb_931_gonio_vertical_position
JamesDoingStuff 6de447d
Merge branch 'main' into mxb_931_gonio_vertical_position
JamesDoingStuff 794b527
Merge branch 'main' into mxb_931_gonio_vertical_position
JamesDoingStuff ff1902c
Overhaul tests
JamesDoingStuff e9afdf2
Expand doc string to explain signals
JamesDoingStuff d3b9067
Merge branch 'main' into mxb_931_gonio_vertical_position
JamesDoingStuff b14f984
Add test for get method
JamesDoingStuff 9a4101b
Merge branch 'main' into mxb_931_gonio_vertical_position
JamesDoingStuff 870e0ed
Merge branch 'main' into mxb_931_gonio_vertical_position
JamesDoingStuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import math | ||
|
|
||
| import pytest | ||
| from bluesky.run_engine import RunEngine | ||
| from ophyd_async.core import init_devices | ||
|
|
||
| from dodal.beamlines import aithre | ||
| from dodal.devices.aithre_lasershaping.goniometer import Goniometer | ||
| from dodal.devices.util.test_utils import patch_motor | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def goniometer(RE: RunEngine) -> Goniometer: | ||
| with init_devices(mock=True): | ||
| gonio = aithre.goniometer(connect_immediately=True, mock=True) | ||
| patch_motor(gonio.omega) | ||
| patch_motor(gonio.sampy) | ||
| patch_motor(gonio.sampz) | ||
| return gonio | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "vertical_set_value, omega_set_value, expected_horz, expected_vert", | ||
| [ | ||
| [2, 60, 1, math.sqrt(3)], | ||
| [-10, 390, -5 * math.sqrt(3), -5], | ||
| [0.5, -135, -math.sqrt(2) / 4, -math.sqrt(2) / 4], | ||
| [1, 0, 1, 0], | ||
| [-1.5, 90, 0, -1.5], | ||
| ], | ||
| ) | ||
| async def test_vertical_signal_set( | ||
| goniometer: Goniometer, | ||
| vertical_set_value: float, | ||
| omega_set_value: float, | ||
| expected_horz: float, | ||
| expected_vert: float, | ||
| ): | ||
| await goniometer.omega.set(omega_set_value) | ||
| await goniometer.vertical_position.set(vertical_set_value) | ||
|
|
||
| assert await goniometer.sampz.user_readback.get_value() == pytest.approx( | ||
| expected_horz | ||
| ) | ||
| assert await goniometer.sampy.user_readback.get_value() == pytest.approx( | ||
| expected_vert | ||
| ) | ||
|
|
||
| await goniometer.vertical_position.set(vertical_set_value * 2) | ||
| assert await goniometer.sampz.user_readback.get_value() == pytest.approx( | ||
| expected_horz * 2 | ||
| ) | ||
| assert await goniometer.sampy.user_readback.get_value() == pytest.approx( | ||
| expected_vert * 2 | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("set_value", [-5, 2.7, 0]) | ||
| async def test_vertical_position_get(goniometer: Goniometer, set_value: float): | ||
| await goniometer.vertical_position.set(set_value) | ||
| assert await goniometer.vertical_position.get_value() == set_value |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: I think some docstrings on what
vertical_positionmeans would be good.