diff --git a/live_test_rotation_params.json b/live_test_rotation_params.json index 3c5fb4c69..489c5bdda 100644 --- a/live_test_rotation_params.json +++ b/live_test_rotation_params.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03I", "insertion_prefix": "SR03I", diff --git a/live_test_rotation_params_move_xyz.json b/live_test_rotation_params_move_xyz.json index 41d6e18f7..f88eb16ec 100644 --- a/live_test_rotation_params_move_xyz.json +++ b/live_test_rotation_params_move_xyz.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03I", "insertion_prefix": "SR03I", diff --git a/src/artemis/experiment_plans/full_grid_scan.py b/src/artemis/experiment_plans/full_grid_scan.py index 426b502ac..2c6d5325e 100644 --- a/src/artemis/experiment_plans/full_grid_scan.py +++ b/src/artemis/experiment_plans/full_grid_scan.py @@ -137,6 +137,7 @@ def run_grid_detection_plan( fgs_params, snapshot_template, snapshot_dir, + grid_width_microns=experiment_params.grid_width_microns, ) yield from run_grid_detection_plan( diff --git a/src/artemis/experiment_plans/oav_grid_detection_plan.py b/src/artemis/experiment_plans/oav_grid_detection_plan.py index 0a98411ad..a1b3a0326 100644 --- a/src/artemis/experiment_plans/oav_grid_detection_plan.py +++ b/src/artemis/experiment_plans/oav_grid_detection_plan.py @@ -34,7 +34,7 @@ def grid_detection_plan( out_parameters: GridScanParams, snapshot_template: str, snapshot_dir: str, - width=600, + grid_width_microns: float, box_size_microns=20, ): yield from finalize_wrapper( @@ -43,7 +43,7 @@ def grid_detection_plan( out_parameters, snapshot_template, snapshot_dir, - width, + grid_width_microns, box_size_microns, ), reset_oav(), @@ -56,7 +56,7 @@ def grid_detection_main_plan( out_parameters: GridScanParams, snapshot_template: str, snapshot_dir: str, - grid_width_px: int, + grid_width_microns: int, box_size_um: float, ): """ @@ -68,7 +68,7 @@ def grid_detection_main_plan( out_parameters (GridScanParams): The returned parameters for the gridscan snapshot_template (str): A template for the name of the snapshots, expected to be filled in with an angle snapshot_dir (str): The location to save snapshots - grid_width_px (int): The width of the grid to scan in pixels + grid_width_microns (int): The width of the grid to scan in microns box_size_um (float): The size of each box of the grid in microns """ oav: OAV = i03.oav() @@ -88,6 +88,8 @@ def grid_detection_main_plan( box_size_x_pixels = box_size_um / parameters.micronsPerXPixel box_size_y_pixels = box_size_um / parameters.micronsPerYPixel + grid_width_pixels = int(grid_width_microns / parameters.micronsPerXPixel) + # The FGS uses -90 so we need to match it for angle in [0, -90]: yield from bps.mv(smargon.omega, angle) @@ -105,8 +107,8 @@ def grid_detection_main_plan( full_image_height_px = yield from bps.rd(oav.cam.array_size.array_size_y) # only use the area from the start of the pin onwards - top_edge = top_edge[tip_x_px : tip_x_px + grid_width_px] - bottom_edge = bottom_edge[tip_x_px : tip_x_px + grid_width_px] + top_edge = top_edge[tip_x_px : tip_x_px + grid_width_pixels] + bottom_edge = bottom_edge[tip_x_px : tip_x_px + grid_width_pixels] # the edge detection line can jump to the edge of the image sometimes, filter # those points out, and if empty after filter use the whole image @@ -118,10 +120,10 @@ def grid_detection_main_plan( max_y = max(filtered_bottom) grid_height_px = max_y - min_y - LOGGER.info(f"Drawing snapshot {grid_width_px} by {grid_height_px}") + LOGGER.info(f"Drawing snapshot {grid_width_pixels} by {grid_height_px}") boxes = ( - math.ceil(grid_width_px / box_size_x_pixels), + math.ceil(grid_width_pixels / box_size_x_pixels), math.ceil(grid_height_px / box_size_y_pixels), ) box_numbers.append(boxes) diff --git a/src/artemis/experiment_plans/tests/test_full_grid_scan_plan.py b/src/artemis/experiment_plans/tests/test_full_grid_scan_plan.py index 46cbfc684..77744059b 100644 --- a/src/artemis/experiment_plans/tests/test_full_grid_scan_plan.py +++ b/src/artemis/experiment_plans/tests/test_full_grid_scan_plan.py @@ -32,7 +32,7 @@ def _fake_grid_detection( out_parameters, snapshot_template: str, snapshot_dir: str, - grid_width_px: int = 0, + grid_width_microns: float = 0, box_size_um: float = 0.0, ): out_parameters.x_start = 0 diff --git a/src/artemis/experiment_plans/tests/test_grid_detection_plan.py b/src/artemis/experiment_plans/tests/test_grid_detection_plan.py index 483176d5a..01a4d30d9 100644 --- a/src/artemis/experiment_plans/tests/test_grid_detection_plan.py +++ b/src/artemis/experiment_plans/tests/test_grid_detection_plan.py @@ -67,6 +67,7 @@ def test_grid_detection_plan_runs_and_triggers_snapshots( out_parameters=gridscan_params, snapshot_dir="tmp", snapshot_template="test_{angle}", + grid_width_microns=161.2, ) ) assert fake_devices[3].save.call_count == 6 @@ -99,6 +100,7 @@ def test_grid_detection_plan_gives_warningerror_if_tip_not_found( out_parameters=gridscan_params, snapshot_dir="tmp", snapshot_template="test_{angle}", + grid_width_microns=161.2, ) ) assert "No pin found" in excinfo.value.args[0] @@ -148,6 +150,7 @@ def test_given_when_grid_detect_then_upper_left_and_start_position_as_expected( snapshot_dir="tmp", snapshot_template="test_{angle}", box_size_microns=0.2, + grid_width_microns=161.2, ) ) @@ -181,6 +184,7 @@ def test_when_grid_detection_plan_run_twice_then_values_do_not_persist_in_callba out_parameters=gridscan_params, snapshot_dir="tmp", snapshot_template="test_{angle}", + grid_width_microns=161.2, ) ) assert len(cb.snapshot_filenames) == 2 diff --git a/src/artemis/parameters/plan_specific/grid_scan_with_edge_detect_params.py b/src/artemis/parameters/plan_specific/grid_scan_with_edge_detect_params.py index d896e4646..c12e6795d 100644 --- a/src/artemis/parameters/plan_specific/grid_scan_with_edge_detect_params.py +++ b/src/artemis/parameters/plan_specific/grid_scan_with_edge_detect_params.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any +from typing import Any, Optional import numpy as np from dodal.devices.detector import TriggerMode @@ -31,6 +31,9 @@ class GridScanWithEdgeDetectParams(AbstractExperimentParameterBase): detector_distance: float omega_start: float + # This is the correct grid size for single pin + grid_width_microns: Optional[float] = 161 + def get_num_images(self): return 0 diff --git a/src/artemis/parameters/schemas/experiment_schemas/grid_scan_with_edge_detect_params_schema.json b/src/artemis/parameters/schemas/experiment_schemas/grid_scan_with_edge_detect_params_schema.json index db1f4da33..a026b54cb 100644 --- a/src/artemis/parameters/schemas/experiment_schemas/grid_scan_with_edge_detect_params_schema.json +++ b/src/artemis/parameters/schemas/experiment_schemas/grid_scan_with_edge_detect_params_schema.json @@ -13,6 +13,9 @@ }, "omega_start": { "type": "number" + }, + "grid_width_microns": { + "type": "number" } }, "required": [ diff --git a/src/artemis/parameters/schemas/full_external_parameters_schema.json b/src/artemis/parameters/schemas/full_external_parameters_schema.json index 3ac0e7f4a..e694fc6d9 100644 --- a/src/artemis/parameters/schemas/full_external_parameters_schema.json +++ b/src/artemis/parameters/schemas/full_external_parameters_schema.json @@ -3,7 +3,7 @@ "type": "object", "properties": { "params_version": { - "const": "2.1.0" + "const": "2.2.0" }, "artemis_params": { "type": "object", diff --git a/src/artemis/parameters/tests/test_data/good_test_grid_with_edge_detect_parameters.json b/src/artemis/parameters/tests/test_data/good_test_grid_with_edge_detect_parameters.json index 115bdb095..d623ef8cd 100644 --- a/src/artemis/parameters/tests/test_data/good_test_grid_with_edge_detect_parameters.json +++ b/src/artemis/parameters/tests/test_data/good_test_grid_with_edge_detect_parameters.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03S", "insertion_prefix": "SR03S", @@ -41,6 +41,7 @@ "snapshot_dir": "/tmp", "exposure_time": 0.1, "detector_distance": 100.0, - "omega_start": 0.0 + "omega_start": 0.0, + "grid_width_microns": 151 } } \ No newline at end of file diff --git a/src/artemis/parameters/tests/test_data/good_test_parameters.json b/src/artemis/parameters/tests/test_data/good_test_parameters.json index b6a082e10..a52d20d8d 100644 --- a/src/artemis/parameters/tests/test_data/good_test_parameters.json +++ b/src/artemis/parameters/tests/test_data/good_test_parameters.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03S", "insertion_prefix": "SR03S", diff --git a/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters.json b/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters.json index 6a707a416..3471edf87 100644 --- a/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters.json +++ b/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03S", "insertion_prefix": "SR03S", diff --git a/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters_nomove.json b/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters_nomove.json index d3e054233..9786a0105 100644 --- a/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters_nomove.json +++ b/src/artemis/parameters/tests/test_data/good_test_rotation_scan_parameters_nomove.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03S", "insertion_prefix": "SR03S", diff --git a/test_parameter_defaults.json b/test_parameter_defaults.json index cbde8d004..e4f540389 100644 --- a/test_parameter_defaults.json +++ b/test_parameter_defaults.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "zocalo_environment": "dev_artemis", "beamline": "BL03S", diff --git a/test_parameters.json b/test_parameters.json index b6a082e10..a52d20d8d 100644 --- a/test_parameters.json +++ b/test_parameters.json @@ -1,5 +1,5 @@ { - "params_version": "2.1.0", + "params_version": "2.2.0", "artemis_params": { "beamline": "BL03S", "insertion_prefix": "SR03S",