Commit a11357e4 authored by Jerome Carnis's avatar Jerome Carnis 🦊
Browse files

deviceEigerP11.py: use constant Quantity for the max repetition rate

parent f4e5c007
Pipeline #28479 passed with stages
in 10 minutes and 12 seconds
......@@ -21,6 +21,7 @@ from kamzik3.constants import (
STATUS_BUSY,
STATUS_CONFIGURED,
STATUS_IDLE,
UNIT,
VALUE,
)
from kamzik3.devices.device import Device
......@@ -35,6 +36,8 @@ from kamzik3.snippets.snippetsDecorators import expose_method
FRAMES_PER_FILE_SCAN = 1000
FRAMES_PER_FILE_LIVE = 1000000
# any large number is ok, images are not saved in the live-view mode
MAX_ACQUISITION_rate = units.Quantity(100, "Hz")
# according to Jan Meyer, 10ms is the lowest frame time
class InterfaceStatus(IntEnum):
......@@ -167,13 +170,17 @@ class DeviceTangoEigerDetector(DeviceTango):
saving_directory="shotDir", prefix=Name, nb_frames=nb_frames
)
exposure = float(self.to_device_unit("FrameTime", Exposure).m)
# According to Jan 10ms is lowest frame time
frame_time = 10e-3 if exposure < 10e-3 else exposure
converted_exposure = self.detector.to_device_unit("FrameTime", Exposure)
frame_time = (
10e-3
if converted_exposure
< (1 / MAX_ACQUISITION_rate).to(self.get_value("FrameTime", key=UNIT))
else float(converted_exposure.m)
)
self.set_attribute(["TriggerMode", VALUE], TriggerMode.INTS.value)
self.set_attribute(["FrameTime", VALUE], frame_time)
self.set_attribute(["CountTime", VALUE], exposure)
self.set_attribute(["CountTime", VALUE], float(converted_exposure.m))
self.set_attribute(["Ntrigger", VALUE], 1)
self.set_attribute(["Nimages", VALUE], nb_frames)
self.Arm()
......@@ -204,12 +211,17 @@ class DeviceTangoEigerDetector(DeviceTango):
self.set_attribute(
["EigerStream", "Mode", VALUE], InterfaceStatus.DISABLED.value
)
exposure = float(self.to_device_unit("FrameTime", Exposure).m)
# According to Jan Meyer 10ms is the lowest frame time
frame_time = 10e-3 if exposure < 10e-3 else exposure
converted_exposure = self.detector.to_device_unit("FrameTime", Exposure)
frame_time = (
10e-3
if converted_exposure
< (1 / MAX_ACQUISITION_rate).to(self.get_value("FrameTime", key=UNIT))
else float(converted_exposure.m)
)
self.set_attribute(["FrameTime", VALUE], frame_time)
self.set_attribute(["CountTime", VALUE], exposure)
self.set_attribute(["CountTime", VALUE], float(converted_exposure.m))
self.set_attribute(["Ntrigger", VALUE], 1)
self.set_attribute(["Nimages", VALUE], FRAMES_PER_FILE_LIVE)
self.Arm()
......@@ -395,10 +407,25 @@ class EigerScanner(DeviceScanner):
scan_dir_name = "{}_{}".format(scan_prefix, scan_count - 1)
params = scanner_input.method_parameters
exposure_time = float(units.Quantity(params["Exposure"]).to("s").m)
frame_time = 10e-3 if exposure_time < 10e-3 else exposure_time
if any(val not in params for val in ["Exposure", "Frames"]):
raise DeviceError(
"The input parameters 'Exposure' and 'Frames' are required in"
f"scanner_input, got {params.keys()}"
)
converted_exposure = units.Quantity(params["Exposure"]).to(
self.detector.get_value("FrameTime", key=UNIT)
)
frame_time = (
10e-3
if converted_exposure
< (1 / MAX_ACQUISITION_rate).to(
self.detector.get_value("FrameTime", key=UNIT)
)
else float(converted_exposure.m)
)
self.detector.set_attribute(["FrameTime", VALUE], frame_time)
self.detector.set_attribute(["CountTime", VALUE], exposure_time)
self.detector.set_attribute(["CountTime", VALUE], float(converted_exposure.m))
frames_count = int(float(params["Frames"]))
total_frames = self._recount_steps(parent_macro, scanner_input) * frames_count
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment