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

Commit

Permalink
Merge pull request #821 from DiamondLightSource/820_control_zoom
Browse files Browse the repository at this point in the history
Control zoom and flatfield correctly in tip/grid detect
  • Loading branch information
DominicOram authored Jul 24, 2023
2 parents f2d5e3a + a38a123 commit 1f5755f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/artemis/device_setup_plans/setup_oav.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@ def pre_centring_setup_oav(oav: OAV, parameters: OAVParameters):
parameters.detection_script_filename,
)

# Connect MXSC output to MJPG input for debugging
yield from bps.abs_set(oav.snapshot.input_plugin, "OAV.MXSC")

zoom_level_str = f"{float(parameters.zoom)}x"
if zoom_level_str not in oav.zoom_controller.allowed_zoom_levels:
raise OAVError_ZoomLevelNotFound(
f"Found {zoom_level_str} as a zoom level but expected one of {oav.zoom_controller.allowed_zoom_levels}"
)

yield from bps.abs_set(
oav.zoom_controller.level,
oav.zoom_controller,
zoom_level_str,
wait=True,
)

# Connect MXSC output to MJPG input for debugging
yield from bps.abs_set(oav.snapshot.input_plugin, "OAV.MXSC")

yield from bps.wait()

"""
Expand Down
51 changes: 51 additions & 0 deletions src/artemis/device_setup_plans/unit_tests/test_setup_oav.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import pytest
from bluesky.run_engine import RunEngine
from dodal.beamlines import i03
from dodal.devices.oav.oav_parameters import OAVParameters

from artemis.device_setup_plans.setup_oav import pre_centring_setup_oav

ZOOM_LEVELS_XML = (
"src/artemis/experiment_plans/tests/test_data/jCameraManZoomLevels.xml"
)
OAV_CENTRING_JSON = "src/artemis/experiment_plans/tests/test_data/OAVCentring.json"
DISPLAY_CONFIGURATION = (
"src/artemis/experiment_plans/tests/test_data/display.configuration"
)


@pytest.fixture
def mock_parameters():
return OAVParameters(
"loopCentring", ZOOM_LEVELS_XML, OAV_CENTRING_JSON, DISPLAY_CONFIGURATION
)


@pytest.mark.parametrize(
"zoom, expected_plugin",
[
("1.0", "proc"),
("7.0", "CAM"),
],
)
def test_when_set_up_oav_with_different_zoom_levels_then_flat_field_applied_correctly(
zoom, expected_plugin, mock_parameters: OAVParameters
):
oav = i03.oav(fake_with_ophyd_sim=True)

oav.proc.port_name.sim_put("proc")
oav.cam.port_name.sim_put("CAM")

oav.zoom_controller.zrst.set("1.0x")
oav.zoom_controller.onst.set("2.0x")
oav.zoom_controller.twst.set("3.0x")
oav.zoom_controller.thst.set("5.0x")
oav.zoom_controller.frst.set("7.0x")
oav.zoom_controller.fvst.set("9.0x")

mock_parameters.zoom = zoom

RE = RunEngine()
RE(pre_centring_setup_oav(oav, mock_parameters))
assert oav.mxsc.input_plugin.get() == expected_plugin
assert oav.snapshot.input_plugin.get() == "OAV.MXSC"

0 comments on commit 1f5755f

Please sign in to comment.