Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mx_bluesky/common/parameters/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
18 changes: 16 additions & 2 deletions tests/system_tests/hyperion/external_interaction/test_nexgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 37 additions & 0 deletions tests/unit_tests/common/parameters/test_rotation.py
Original file line number Diff line number Diff line change
@@ -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))
Loading