Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

526 do rotation scans#621

Merged
d-perl merged 66 commits into
mainfrom
526_do_rotation_scans
May 26, 2023
Merged

526 do rotation scans#621
d-perl merged 66 commits into
mainfrom
526_do_rotation_scans

Conversation

@d-perl

@d-perl d-perl commented Apr 20, 2023

Copy link
Copy Markdown
Contributor

Fixes #526
Implements a rotation_scan_plan and a few small support things necessary for it:

Requires dodal PR DiamondLightSource/dodal#49

To test:

  1. Run tests including system tests
  2. Test on beamline

@codecov

codecov Bot commented Apr 20, 2023

Copy link
Copy Markdown

Codecov Report

Merging #621 (58bcc5a) into main (bc18cce) will increase coverage by 2.14%.
The diff coverage is 99.40%.

@@            Coverage Diff             @@
##             main     DiamondLightSource/hyperion#621      +/-   ##
==========================================
+ Coverage   89.75%   91.90%   +2.14%     
==========================================
  Files          34       36       +2     
  Lines        1494     1630     +136     
==========================================
+ Hits         1341     1498     +157     
+ Misses        153      132      -21     
Impacted Files Coverage Δ
src/artemis/__main__.py 88.70% <50.00%> (-0.45%) ⬇️
src/artemis/device_setup_plans/setup_zebra.py 100.00% <100.00%> (ø)
...rc/artemis/experiment_plans/experiment_registry.py 100.00% <100.00%> (+5.26%) ⬆️
...rc/artemis/experiment_plans/fast_grid_scan_plan.py 86.98% <100.00%> (+4.10%) ⬆️
src/artemis/experiment_plans/rotation_scan_plan.py 100.00% <100.00%> (ø)
...l_interaction/callbacks/rotation/nexus_callback.py 100.00% <100.00%> (ø)
...callbacks/rotation/rotation_callback_collection.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@DominicOram

Copy link
Copy Markdown
Collaborator

Review and comment on glaring things only, new issues created for smaller things

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, some comments in code. I think it would have been a little cleaner to not have done any Nexus Callback stuff in this PR as we'll now end up with placeholder/half finished stuff on main but there's no point being a purist and removing it now. Given the rotation_scan_plan is a bit more scientist facing it would be good for it to have some docstrings. I think for the major stuff I've put it in new issues. Feel free to make other new issues for things (apart from the must comment).

Comment thread .vscode/launch.json
Comment on lines 17 to 19
"env": {
"EPICS_CA_SERVER_PORT": "5066"
"EPICS_CA_SERVER_PORT": "5364"
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: This is specific to you, should remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just the default for anyone

from artemis.log import LOGGER


def arm_zebra(zebra: Zebra, timeout: float = 3):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added these to the growing list of nasty waits (https://github.com/DiamondLightSource/python-artemis/issues/426)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cheers

Comment on lines +52 to +66
"""Set up the Zebra to collect a rotation dataset. Any plan using this is
responsible for setting the smargon velocity appropriately so that the desired
image width is achieved with the exposure time given here.

Parameters:
axis: I03 axes enum representing which axis to use for position
compare. Currently always omega.
start_angle: Position at which the scan should begin, in degrees.
scan_width: Total angle through which to collect, in degrees.
direction: 1 for positive direction or -1 for negative direction of
rotation. Other values cause a ValueError. Used for
adjusting the start angle based on shutter time.
shutter_time_and_velocity: tuple[float, float] representing the time it takes
(in seconds) for the shutter to open and the velocity of the
scan (in deg/s). Used to ajust the gate start so that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice commenting, thanks!

Comment thread src/artemis/device_setup_plans/setup_zebra.py Outdated
Comment on lines +74 to +78
# if shutter_time_and_velocity[0] != 0:
# shutter_time = shutter_time_and_velocity[0]
# velocity = shutter_time_and_velocity[1]
# start_angle += direction * (shutter_time * velocity)
# TODO FIX THIS HERE AND IN MAIN PLAN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Move out into an issue and remove this comment (also probably shutter_time_and_velocity)

Comment on lines +18 to +19
def test_do_nothing():
do_nothing()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could: do_nothing is no longer used and was always a placeholder, we should remove it and this test


# TODO planify these
eiger.set_detector_parameters(params.artemis_params.detector_params)
eiger.set_num_triggers_and_captures()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Why are we calling this function here? It's done as part of stage

"bluesky.preprocessors.__read_and_stash_a_motor",
__fake_read,
):
# with patch.object(RE, "_read", MagicMock(return_value=0)):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Remove commented out code

)
)

assert mock_omega_sets.call_count == 4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: This seems like an arbitrary assertion. Maybe better to assert the values are as expected


@patch("artemis.experiment_plans.rotation_scan_plan.cleanup_plan")
@patch("bluesky.plan_stubs.wait")
def test_cleanup_happens(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would split this into two tests, one with the failure and one without. Probably also add a third that confirms it cleans up when no error happens

@d-perl
d-perl requested a review from DominicOram May 22, 2023 15:11
"""Move an EpicsMotor 'axis' to angle 'start_angle', modified by an offset and
against the direction of rotation."""
# can move to start as fast as possible
yield from bps.abs_set(axis.velocity, 120, wait=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: See #685

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@d-perl
d-perl merged commit 7115c93 into main May 26, 2023
@d-perl
d-perl deleted the 526_do_rotation_scans branch May 26, 2023 12:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coordinate setting up the Eiger and Zebra for rotation scans (i.e. implement a rotation scan plan)

2 participants