Added ROI parameters
This commit is contained in:
1 parent
3b0017ca99
commit
200c2cdfdb
2 files changed
+29
-13
No files matched your search
@@ -280,8 +280,8 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
redis_connector=self.device_manager.connector,
|
||||
)
|
||||
self._pixel_map = None
|
||||
self._troistep = 1
|
||||
self._troin = 5000
|
||||
self._troistep = 1 # Will be changed if timepix scan is used, see on_stage call
|
||||
self._troin = 5000 # Will be changed if timepix scan is used, see on_stage call
|
||||
|
||||
self._poll_thread = threading.Thread(
|
||||
target=self._poll_array_data, daemon=True, name=f"{self.name}_poll_thread"
|
||||
@@ -441,16 +441,6 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
idx_off_stop = self.scan_parameters.additional_scan_parameters["idx_off_stop"]
|
||||
idx_on_start = self.scan_parameters.additional_scan_parameters["idx_on_start"]
|
||||
idx_on_stop = self.scan_parameters.additional_scan_parameters["idx_on_stop"]
|
||||
for name, idx in (
|
||||
("idx_off_start", idx_off_start),
|
||||
("idx_off_stop", idx_off_stop),
|
||||
("idx_on_start", idx_on_start),
|
||||
("idx_on_stop", idx_on_stop),
|
||||
):
|
||||
if idx > len(data_1):
|
||||
raise ValueError(
|
||||
f"{name} with value {idx} exceeds length of data array of {len(data_1)}"
|
||||
)
|
||||
level_1_off = np.mean(data_1[idx_off_start:idx_off_stop])
|
||||
level_1_on = np.mean(data_1[idx_on_start:idx_on_stop])
|
||||
level_2_off = np.mean(data_2[idx_off_start:idx_off_stop])
|
||||
@@ -662,6 +652,12 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
"""Called while staging the device."""
|
||||
self.scan_parameters = fetch_scan_info(self.scan_info)
|
||||
|
||||
if self.scan_parameters.scan_name == "timepix_scan":
|
||||
self._troistep = self.scan_parameters.additional_scan_parameters["time_roi_step"]
|
||||
self._troin = self.scan_parameters.additional_scan_parameters["time_roi_n"]
|
||||
self.hdf.enable.put(0)
|
||||
self.set_enable_xes(True)
|
||||
|
||||
self.accumulated_data_e1 = None
|
||||
self.accumulated_data_e2 = None
|
||||
scan_msg: ScanStatusMessage = self.scan_info.msg # type: ignore
|
||||
@@ -726,6 +722,9 @@ class Timepix(PSIDeviceBase, TimePixControl):
|
||||
self.cam.acquire.put(0)
|
||||
status_camera = CompareStatus(self.cam.acquire_busy, ACQUIRESTATUS.DONE)
|
||||
status_camera.wait(timeout=self._pv_timeout)
|
||||
if self.scan_parameters.scan_name == "timepix_scan":
|
||||
self.hdf.enable.put(1)
|
||||
self.set_enable_xes(False)
|
||||
|
||||
def on_pre_scan(self) -> StatusBase:
|
||||
"""Called right before the scan starts on all devices automatically."""
|
||||
|
||||
@@ -33,7 +33,8 @@ class TimepixScan(LineScan):
|
||||
gui_config = {
|
||||
"Movement Parameters": ["steps", "relative"],
|
||||
"Acquisition Parameters": ["exp_time", "burst_at_each_point"],
|
||||
"Timepix Parameters": ["idx_off_start", "idx_off_stop", "idx_on_start", "idx_on_stop"],
|
||||
"Binning Parameters": ["time_roi_step", "time_roi_n"],
|
||||
"Laser On/Off Parameters": ["idx_off_start", "idx_off_stop", "idx_on_start", "idx_on_stop"],
|
||||
}
|
||||
|
||||
def __init__(
|
||||
@@ -44,6 +45,8 @@ class TimepixScan(LineScan):
|
||||
exp_time: DefaultArgType.ExposureTime = 0,
|
||||
burst_at_each_point: DefaultArgType.BurstAtEachPoint = 1,
|
||||
# fmt: off
|
||||
time_roi_step: Annotated[int, ScanArgument(display_name="Time ROI step", description="Bin size", gt=0)],
|
||||
time_roi_n: Annotated[int, ScanArgument(display_name="Time ROI n", description="Number of time points", gt=0)],
|
||||
idx_off_start: Annotated[int, ScanArgument(display_name="Index Off Start", description="Start Index for Off Level", ge=0)],
|
||||
idx_off_stop: Annotated[int, ScanArgument(display_name="Index Off Stop", description="Stop Index for Off Level", ge=0)],
|
||||
idx_on_start: Annotated[int, ScanArgument(display_name="Index On Start", description="Start Index for On Level", ge=0)],
|
||||
@@ -59,6 +62,16 @@ class TimepixScan(LineScan):
|
||||
raise ValueError(
|
||||
f"idx_on_start ({idx_on_start}) cannot be bigger than idx_on_stop ({idx_on_stop})!"
|
||||
)
|
||||
for name, idx in (
|
||||
("idx_off_start", idx_off_start),
|
||||
("idx_off_stop", idx_off_stop),
|
||||
("idx_on_start", idx_on_start),
|
||||
("idx_on_stop", idx_on_stop),
|
||||
):
|
||||
if idx > time_roi_n:
|
||||
raise ValueError(
|
||||
f"{name} with value {idx} exceeds length of data array of time_roi_n of {time_roi_n}"
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
*args,
|
||||
@@ -69,12 +82,16 @@ class TimepixScan(LineScan):
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
self.time_roi_step = time_roi_step
|
||||
self.time_roi_n = time_roi_n
|
||||
self.idx_off_start = idx_off_start
|
||||
self.idx_off_stop = idx_off_stop
|
||||
self.idx_on_start = idx_on_start
|
||||
self.idx_on_stop = idx_on_stop
|
||||
|
||||
self.update_scan_info(
|
||||
time_roi_step=time_roi_step,
|
||||
time_roi_n=time_roi_n,
|
||||
idx_off_start=idx_off_start,
|
||||
idx_off_stop=idx_off_stop,
|
||||
idx_on_start=idx_on_start,
|
||||
|
||||
Reference in new issue
Block a user