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

Commit

Permalink
(#836) Rotation scan plan gets accl from motor
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Aug 7, 2023
1 parent 3604bef commit 11c81b8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/artemis/experiment_plans/rotation_scan_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def create_devices() -> dict[str, Device]:

DEFAULT_DIRECTION = RotationDirection.NEGATIVE
DEFAULT_MAX_VELOCITY = 120
TIME_TO_VELOCITY_S = 0.15
# Use a slightly larger time to accceleration than EPICS as it's better to be cautious
ACCELERATION_MARGIN = 1.5


def setup_sample_environment(
Expand Down Expand Up @@ -180,12 +181,12 @@ def rotation_scan_plan(
speed_for_rotation_deg_s = image_width_deg / exposure_time_s
LOGGER.info(f"calculated speed: {speed_for_rotation_deg_s} deg/s")

# TODO get this from epics instead of hardcoded - time to velocity
# https://github.com/DiamondLightSource/python-artemis/issues/836
acceleration_offset = TIME_TO_VELOCITY_S * speed_for_rotation_deg_s
motor_time_to_speed = yield from bps.rd(smargon.omega.acceleration)
motor_time_to_speed *= ACCELERATION_MARGIN
acceleration_offset = motor_time_to_speed * speed_for_rotation_deg_s
LOGGER.info(
f"calculated rotation offset for acceleration: at {speed_for_rotation_deg_s} "
f"deg/s, to take {TIME_TO_VELOCITY_S} s = {acceleration_offset} deg"
f"deg/s, to take {motor_time_to_speed} s = {acceleration_offset} deg"
)

shutter_opening_degrees = (
Expand Down
45 changes: 45 additions & 0 deletions src/artemis/experiment_plans/tests/test_rotation_scan_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,48 @@ def test_ispyb_deposition_in_plan(
assert beamsize_x == test_bs_x
assert beamsize_y == test_bs_y
assert exposure == test_exp_time


@patch(
"artemis.experiment_plans.rotation_scan_plan.move_to_start_w_buffer", autospec=True
)
def test_acceleration_offset_calculated_correctly(
mock_move_to_start: MagicMock,
RE: RunEngine,
test_rotation_params: RotationInternalParameters,
smargon: Smargon,
zebra: Zebra,
eiger: EigerDetector,
attenuator: Attenuator,
detector_motion: DetectorMotion,
backlight: Backlight,
mock_rotation_subscriptions: RotationCallbackCollection,
synchrotron: Synchrotron,
s4_slit_gaps: S4SlitGaps,
undulator: Undulator,
flux: Flux,
):
smargon.omega.acceleration.sim_put(0.2)
setup_and_run_rotation_plan_for_tests(
RE,
test_rotation_params,
smargon,
zebra,
eiger,
attenuator,
detector_motion,
backlight,
mock_rotation_subscriptions,
synchrotron,
s4_slit_gaps,
undulator,
flux,
)

expected_start_angle = (
test_rotation_params.artemis_params.detector_params.omega_start
)

mock_move_to_start.assert_called_once_with(
smargon.omega, expected_start_angle, pytest.approx(0.3)
)

0 comments on commit 11c81b8

Please sign in to comment.