From 004ae2b2686947bb1773deb4e620e527e2724f6d Mon Sep 17 00:00:00 2001 From: Robert Tuck Date: Thu, 25 Jun 2026 13:24:56 +0100 Subject: [PATCH 1/2] Initial fix for rotation scanspec direction --- src/mx_bluesky/common/parameters/rotation.py | 3 +- .../good_test_rotation_scan_parameters.json | 5 +-- .../common/parameters/test_rotation.py | 37 +++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 tests/unit_tests/common/parameters/test_rotation.py diff --git a/src/mx_bluesky/common/parameters/rotation.py b/src/mx_bluesky/common/parameters/rotation.py index 4819e1895b..5d39eb2430 100644 --- a/src/mx_bluesky/common/parameters/rotation.py +++ b/src/mx_bluesky/common/parameters/rotation.py @@ -120,7 +120,8 @@ def scan_points(self) -> AxesPoints: start=self.omega_start_deg, stop=( self.omega_start_deg - + (self.scan_width_deg - self.rotation_increment_deg) + + self.rotation_direction.multiplier + * (self.scan_width_deg - self.rotation_increment_deg) ), num=self.num_images, ) diff --git a/tests/test_data/parameter_json_files/good_test_rotation_scan_parameters.json b/tests/test_data/parameter_json_files/good_test_rotation_scan_parameters.json index 4484d6c47c..8c0a35b0fa 100644 --- a/tests/test_data/parameter_json_files/good_test_rotation_scan_parameters.json +++ b/tests/test_data/parameter_json_files/good_test_rotation_scan_parameters.json @@ -5,10 +5,7 @@ "detector_distance_mm": 100.0, "demand_energy_ev": 100, "exposure_time_s": 0.1, - "omega_starts_deg": [ - 0, - 90 - ], + "omega_start_deg": 0.0, "file_name": "file_name", "scan_width_deg": 180.0, "rotation_axis": "omega", diff --git a/tests/unit_tests/common/parameters/test_rotation.py b/tests/unit_tests/common/parameters/test_rotation.py new file mode 100644 index 0000000000..e7b2170add --- /dev/null +++ b/tests/unit_tests/common/parameters/test_rotation.py @@ -0,0 +1,37 @@ +from pathlib import Path + +import numpy as np +import pytest + +from mx_bluesky.common.parameters.rotation import SingleRotationScan + +from ...conftest import raw_params_from_file + + +@pytest.mark.parametrize( + "omega_start_deg, rotation_direction, rotation_increment_deg, scan_width_deg, expected_omegas", + [ + [0, "Positive", 0.25, 0.5, [0.0, 0.25]], + [0, "Negative", 0.25, 0.5, [0.0, -0.25]], + ], +) +def test_single_rotation_scan_scan_points( + omega_start_deg: float, + rotation_direction: str, + rotation_increment_deg: float, + scan_width_deg: float, + expected_omegas: list[float], + tmp_path: Path, +): + params = raw_params_from_file( + "tests/test_data/parameter_json_files/good_test_rotation_scan_parameters.json", + tmp_path, + ) + params |= { + "omega_start_deg": omega_start_deg, + "rotation_direction": rotation_direction, + "rotation_increment_deg": rotation_increment_deg, + "scan_width_deg": scan_width_deg, + } + rotation_scan = SingleRotationScan(**params) + assert np.all(rotation_scan.scan_points["omega"] == np.array(expected_omegas)) From 18ec48a01e54cd5977157e38181da9ded444b9ea Mon Sep 17 00:00:00 2001 From: Robert Tuck Date: Thu, 25 Jun 2026 14:56:57 +0100 Subject: [PATCH 2/2] WIP add system test, issues with imginfo --- .../external_interaction/test_nexgen.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/system_tests/hyperion/external_interaction/test_nexgen.py b/tests/system_tests/hyperion/external_interaction/test_nexgen.py index 8bff181cb3..a223725687 100644 --- a/tests/system_tests/hyperion/external_interaction/test_nexgen.py +++ b/tests/system_tests/hyperion/external_interaction/test_nexgen.py @@ -7,6 +7,7 @@ import bluesky.preprocessors as bpp import pytest +from dodal.devices.zebra.zebra import RotationDirection from mx_bluesky.common.experiment_plans.inner_plans.read_hardware import ( standard_read_hardware_during_collection, @@ -28,7 +29,7 @@ @pytest.fixture -def test_params(tmp_path, config_client): +def test_params(tmp_path, config_client, request): param_dict = raw_params_from_file( "tests/test_data/parameter_json_files/good_test_rotation_scan_parameters.json", tmp_path, @@ -41,23 +42,36 @@ def test_params(tmp_path, config_client): params.y_start_um = 0 params.z_start_um = 0 params.exposure_time_s = 0.004 + params.rotation_direction = request.param + params.omega_start_deg = ( + 0 if params.rotation_direction == RotationDirection.POSITIVE else 360 + ) return params @pytest.mark.parametrize( - "test_data_directory, prefix, reference_file", + "test_data_directory, prefix, reference_file, test_params", [ ( "tests/test_data/nexus_files/rotation", "ins_8_5", "ins_8_5_expected_output.txt", + RotationDirection.POSITIVE, + ), + ( + "tests/test_data/nexus_files/rotation", + "ins_8_5", + "ins_8_5_expected_output.txt", + RotationDirection.NEGATIVE, ), ( "tests/test_data/nexus_files/rotation_unicode_metafile", "ins_8_5", "ins_8_5_expected_output.txt", + RotationDirection.POSITIVE, ), ], + indirect=["test_params"], ) @patch( "mx_bluesky.common.external_interaction.nexus.nexus_utils.time.time",