Skip to content

Commit

Permalink
Merge pull request #64 from DiamondLightSource/test20231128
Browse files Browse the repository at this point in the history
I24 serial test fixes
  • Loading branch information
noemifrisina authored Nov 30, 2023
2 parents afb603e + 1933917 commit 20a40ac
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"matplotlib",
"requests",
"opencv-python",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@511ec01ea017a53a95b9c9ab85a0d922bfff3061",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@c089ecb6e86bafd766a427c9d64e9bf1e3935681",
]
dynamic = ["version"]
license.file = "LICENSE"
Expand Down
4 changes: 2 additions & 2 deletions src/mx_bluesky/I24/serial/dcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ def get_beamsize() -> tuple[float | None, float | None]:
"focus5010d": ("50x10", 50, 10),
"focus3010d": ("30x10", 30, 10),
}
v_mode = caget("BL24I-OP-PSU-02:GROUP0:TARGETC")
h_mode = caget("BL24I-OP-PSU-02:GROUP1:TARGETC")
v_mode = caget("BL24I-OP-MFM-01:G0:TARGETAPPLY")
h_mode = caget("BL24I-OP-MFM-01:G1:TARGETAPPLY")
# Validate these and note an error otherwise
if not v_mode.startswith("VMFM") or v_mode[4:] not in focus_modes:
logger.error("Unrecognised vertical beam mode %s", v_mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def copy_files_to_data_location(
dest_dir = Path(dest_dir)
dest_dir.mkdir(parents=True, exist_ok=True)
shutil.copy2(param_path / "parameters.txt", dest_dir / "parameters.txt")
if map_type == "1":
if map_type == MappingType.Lite:
shutil.copy2(map_file / "currentchip.map", dest_dir / "currentchip.map")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from mx_bluesky.I24.serial import log
from mx_bluesky.I24.serial.fixed_target import i24ssx_Chip_Mapping_py3v1 as mapping
from mx_bluesky.I24.serial.fixed_target import i24ssx_Chip_StartUp_py3v1 as startup
from mx_bluesky.I24.serial.fixed_target.ft_utils import ChipType
from mx_bluesky.I24.serial.fixed_target.ft_utils import ChipType, MappingType
from mx_bluesky.I24.serial.parameters.constants import (
CS_FILES_PATH,
FULLMAP_PATH,
Expand Down Expand Up @@ -157,7 +157,7 @@ def write_parameter_file(param_path: Path | str = PARAM_FILE_PATH_FT):
f.write("prepumpexptime \t%s\n" % prepumpexptime)
f.write("exptime \t%s\n" % exptime)
f.write("dcdetdist \t%s\n" % dcdetdist)
f.write("det_type \t%s\n" % det_type)
f.write("det_type \t%s\n" % str(det_type))

logger.info("Information written to file")
logger.info("visit: %s" % visit)
Expand All @@ -170,9 +170,8 @@ def write_parameter_file(param_path: Path | str = PARAM_FILE_PATH_FT):
logger.info("pumpexptime: %s" % pumpexptime)
logger.info("pumpdelay: %s" % pumpdelay)
logger.info("prepumpexptime: %s" % prepumpexptime)
logger.info("detector type: %s" % det_type)

if map_type == "2":
logger.info("detector type: %s" % str(det_type))
if map_type == MappingType.Full:
# This step creates some header files (.addr, .spec), containing the parameters,
# that are only needed when full mapping is in use.
logger.debug("Running start up now.")
Expand Down Expand Up @@ -757,6 +756,7 @@ def fiducial(point: int = 1, param_path: Path | str = CS_FILES_PATH):
f.write("MTR1\t%1.4f\t%i\t%i\t%1.4f\n" % (rbv_1, raw_1, mtr1_dir, f_x))
f.write("MTR2\t%1.4f\t%i\t%i\t%1.4f\n" % (rbv_2, raw_2, mtr2_dir, f_y))
f.write("MTR3\t%1.4f\t%i\t%i\t%1.4f" % (rbv_3, raw_3, mtr3_dir, f_z))
logger.info(f"Fiducial {point} set.")


def scrape_mtr_fiducials(point: int, param_path: Path | str = CS_FILES_PATH):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def scrape_parameter_file(param_path: Path | str = PARAM_FILE_PATH_FT):
if "dcdetdist" in entry[0].lower():
dcdetdist = float(entry[1])
if "prepumpexptime" in entry[0].lower():
prepumpexptime = int(entry[1])
prepumpexptime = float(entry[1])
if "pumpdelay" in entry[0].lower():
pumpdelay = int(entry[1])
pumpdelay = float(entry[1])
if "det_type" in entry[0].lower():
det_type = entry[1]
return (
Expand Down
13 changes: 8 additions & 5 deletions src/mx_bluesky/I24/serial/fixed_target/i24ssx_moveonclick.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging

import cv2 as cv
from bluesky.run_engine import RunEngine
from dodal.beamlines import i24
from dodal.devices.oav.oav_detector import OAV

Expand All @@ -26,7 +25,12 @@ def _get_beam_centre(oav: OAV):
Args:
oav (OAV): the OAV device.
"""
return oav.parameters.beam_centre_i, oav.parameters.beam_centre_j
beamX, beamY = oav.parameters.beam_centre_i, oav.parameters.beam_centre_j
# Re-scale beam position to an image of 1024x768 to get the correct values
# See https://github.com/DiamondLightSource/dodal/issues/249
beamX *= 1292 / 1024
beamY *= 964 / 768
return int(beamX), int(beamY)


# TODO In the future, this should be done automatically in the OAV device
Expand All @@ -35,8 +39,7 @@ def get_beam_centre():
# Get I24 oav device from dodal
oav = i24.oav()

RE = RunEngine(call_returns_result=True)
beamX, beamY = RE(_get_beam_centre(oav)).plan_result
beamX, beamY = _get_beam_centre(oav)
return beamX, beamY


Expand All @@ -46,7 +49,7 @@ def onMouse(event, x, y, flags, param):
if event == cv.EVENT_LBUTTONUP:
logger.info("Clicked X and Y %s %s" % (x, y))
xmove = -1 * (beamX - x) * zoomcalibrator
ymove = 1 * (beamY - y) * zoomcalibrator
ymove = -1 * (beamY - y) * zoomcalibrator
logger.info("Moving X and Y %s %s" % (xmove, ymove))
xmovepmacstring = "#1J:" + str(xmove)
ymovepmacstring = "#2J:" + str(ymove)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"scalex": 10011.85,
"scaley": 10011.9,
"scalex": 10002.4,
"scaley": 9997.5,
"scalez": 10000.0,
"skew": 0.0275,
"Sx_dir": 1,
"skew": -0.163,
"Sx_dir": -1,
"Sy_dir": 1,
"Sz_dir": 1
"Sz_dir": -1
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MTR RBV RAW Corr f_value
MTR1 25.3946 254246 1 25.3946
MTR2 -0.3833 3838 -1 -0.3833
MTR1 25.3964 254025 1 25.3964
MTR2 -0.5533 -5532 1 -0.5533
MTR3 0.0000 0 -1 0.0000
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MTR RBV RAW Corr f_value
MTR1 0.3941 3946 1 0.3941
MTR2 25.3958 -254261 -1 25.3958
MTR1 0.4709 4710 1 0.4709
MTR2 25.4079 254014 1 25.4079
MTR3 0.0000 0 -1 0.0000
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# motor number * (dir) = positive chip direction

mtr1_dir=1
mtr2_dir=-1
mtr2_dir=1
mtr3_dir=-1
18 changes: 9 additions & 9 deletions src/mx_bluesky/I24/serial/parameters/fixed_target/parameters.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
visit /dls/i24/data/2023/cm33852-4/
chip_name albion
protein_name test_20230919/eigertest3
n_exposures 1
visit /dls/i24/data/2023/cm33852-5/
chip_name gamma
protein_name test_20231128/test2
n_exposures 2
chip_type 0
map_type 1
pump_repeat 0
pumpexptime 0
pumpdelay 0
pumpexptime 0.025
pumpdelay 0.00
prepumpexptime 0
exptime 0.01
dcdetdist 1480
det_type eiger
exptime 0.025
dcdetdist 1450
det_type pilatus
6 changes: 6 additions & 0 deletions src/mx_bluesky/I24/serial/setup_beamline/pv_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class pv:
beamx = pv.pilat_beamx
beamy = pv.pilat_beamy

def __str__(self) -> str:
return self.name


class Eiger:
id = 94
Expand All @@ -62,5 +65,8 @@ class pv:
beamx = pv.eiger_beamx
beamy = pv.eiger_beamy

def __str__(self) -> str:
return self.name


Detector = Union[Pilatus, Eiger]
8 changes: 4 additions & 4 deletions tests/I24/serial/fixed_target/test_moveonclick.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
@pytest.mark.parametrize(
"beam_position, expected_1J, expected_2J",
[
((15, 10), "#1J:-90", "#2J:60"),
((100, 150), "#1J:-600", "#2J:900"),
((475, 309), "#1J:-2850", "#2J:1854"),
((638, 392), "#1J:-3828", "#2J:2352"),
((15, 10), "#1J:-90", "#2J:-60"),
((100, 150), "#1J:-600", "#2J:-900"),
((475, 309), "#1J:-2850", "#2J:-1854"),
((638, 392), "#1J:-3828", "#2J:-2352"),
],
)
@patch("mx_bluesky.I24.serial.fixed_target.i24ssx_moveonclick.caput")
Expand Down

0 comments on commit 20a40ac

Please sign in to comment.