From 855dc31490fb60df11a175bd36faa9808cca9005 Mon Sep 17 00:00:00 2001 From: vshekar1 Date: Wed, 3 May 2023 16:44:50 -0400 Subject: [PATCH 1/2] Fixes: - trigger mode set before num_images in flyer and raster_flyer - Moved file_write_images_per_file from configure_detector to detector_arm similar to raster_flyer to fix issue where standard does not update this value after a raster collection --- mxtools/flyer.py | 13 ++++++++++--- mxtools/raster_flyer.py | 7 +++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mxtools/flyer.py b/mxtools/flyer.py index 4161cb8..70511cf 100644 --- a/mxtools/flyer.py +++ b/mxtools/flyer.py @@ -170,6 +170,9 @@ def unstage(self): self.detector.unstage() def update_parameters(self, *args, **kwargs): + if self.detector.cam.armed.get() == 1: + raise RuntimeError("Detector must be unarmed in order to begin collection.") + self.detector_arm(**kwargs) self.configure_detector(**kwargs) self.configure_vector(**kwargs) self.configure_zebra(**kwargs) @@ -179,7 +182,6 @@ def configure_detector(self, **kwargs): data_directory_name = kwargs["data_directory_name"] self.detector.file.external_name.put(file_prefix) self.detector.file.write_path_template = data_directory_name - self.detector.file.file_write_images_per_file.put(500) def configure_vector(self, *args, **kwargs): angle_start = kwargs["angle_start"] @@ -263,6 +265,7 @@ def detector_arm(self, **kwargs): self.detector.cam.acquire_time.put(exposure_per_image) self.detector.cam.acquire_period.put(exposure_per_image) + self.detector.cam.trigger_mode.put(eiger.EXTERNAL_SERIES) # Trigger mode set before num_images due to updates in Eiger REST API self.detector.cam.num_images.put(num_images) self.detector.cam.num_triggers.put(1) self.detector.cam.file_path.put(data_directory_name) @@ -277,7 +280,10 @@ def detector_arm(self, **kwargs): self.detector.cam.omega_start.put(start) self.detector.cam.wavelength.put(wavelength) self.detector.cam.det_distance.put(det_distance_m) - self.detector.cam.trigger_mode.put(eiger.EXTERNAL_SERIES) + + self.detector.file.file_write_images_per_file.put(500) + + start_arm = ttime.time() def armed_callback(value, old_value, **kwargs): if old_value == 0 and value == 1: @@ -288,7 +294,8 @@ def armed_callback(value, old_value, **kwargs): self.detector.cam.acquire.put(1) - return status + status.wait() + logger.info(f"arm time = {ttime.time() - start_arm}") def setup_vector_program( self, num_images, angle_start, angle_end, x_um, y_um, z_um, exposure_period_per_image diff --git a/mxtools/raster_flyer.py b/mxtools/raster_flyer.py index 183b592..dcec332 100644 --- a/mxtools/raster_flyer.py +++ b/mxtools/raster_flyer.py @@ -130,6 +130,7 @@ def detector_arm(self, **kwargs): self.detector.cam.acquire_time.put(exposure_per_image) self.detector.cam.acquire_period.put(exposure_per_image) + self.detector.cam.trigger_mode.put(eiger.EXTERNAL_ENABLE) # Setting trigger mode before num_triggers due to change in Eiger REST API change self.detector.cam.num_triggers.put(total_num_images) self.detector.cam.file_path.put(data_directory_name) self.detector.cam.fw_name_pattern.put(f"{file_prefix_minus_directory}_$id") @@ -143,10 +144,11 @@ def detector_arm(self, **kwargs): self.detector.cam.omega_start.put(start) self.detector.cam.wavelength.put(wavelength) self.detector.cam.det_distance.put(det_distance_m) - self.detector.cam.trigger_mode.put(eiger.EXTERNAL_ENABLE) self.detector.file.file_write_images_per_file.put(num_images_per_file) + start_arm = ttime.time() + def armed_callback(value, old_value, **kwargs): if old_value == 0 and value == 1: return True @@ -156,7 +158,8 @@ def armed_callback(value, old_value, **kwargs): self.detector.cam.acquire.put(1) - return status + status.wait() + logger.info(f"arm time = {ttime.time() - start_arm}") def describe_collect(self): return {"stream_name": {}} From 8e6188145a3a5356960f8137fc2e3cc374ec5a38 Mon Sep 17 00:00:00 2001 From: Shekar V Date: Thu, 4 May 2023 10:11:42 -0400 Subject: [PATCH 2/2] Removed lines that were added again, added black formatting --- mxtools/flyer.py | 11 +++-------- mxtools/raster_flyer.py | 8 +++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/mxtools/flyer.py b/mxtools/flyer.py index 70511cf..8a7f478 100644 --- a/mxtools/flyer.py +++ b/mxtools/flyer.py @@ -170,9 +170,6 @@ def unstage(self): self.detector.unstage() def update_parameters(self, *args, **kwargs): - if self.detector.cam.armed.get() == 1: - raise RuntimeError("Detector must be unarmed in order to begin collection.") - self.detector_arm(**kwargs) self.configure_detector(**kwargs) self.configure_vector(**kwargs) self.configure_zebra(**kwargs) @@ -265,7 +262,8 @@ def detector_arm(self, **kwargs): self.detector.cam.acquire_time.put(exposure_per_image) self.detector.cam.acquire_period.put(exposure_per_image) - self.detector.cam.trigger_mode.put(eiger.EXTERNAL_SERIES) # Trigger mode set before num_images due to updates in Eiger REST API + # Trigger mode set before num_images due to updates in Eiger REST API + self.detector.cam.trigger_mode.put(eiger.EXTERNAL_SERIES) self.detector.cam.num_images.put(num_images) self.detector.cam.num_triggers.put(1) self.detector.cam.file_path.put(data_directory_name) @@ -282,8 +280,6 @@ def detector_arm(self, **kwargs): self.detector.cam.det_distance.put(det_distance_m) self.detector.file.file_write_images_per_file.put(500) - - start_arm = ttime.time() def armed_callback(value, old_value, **kwargs): if old_value == 0 and value == 1: @@ -294,8 +290,7 @@ def armed_callback(value, old_value, **kwargs): self.detector.cam.acquire.put(1) - status.wait() - logger.info(f"arm time = {ttime.time() - start_arm}") + return status def setup_vector_program( self, num_images, angle_start, angle_end, x_um, y_um, z_um, exposure_period_per_image diff --git a/mxtools/raster_flyer.py b/mxtools/raster_flyer.py index dcec332..4d81cb0 100644 --- a/mxtools/raster_flyer.py +++ b/mxtools/raster_flyer.py @@ -130,7 +130,8 @@ def detector_arm(self, **kwargs): self.detector.cam.acquire_time.put(exposure_per_image) self.detector.cam.acquire_period.put(exposure_per_image) - self.detector.cam.trigger_mode.put(eiger.EXTERNAL_ENABLE) # Setting trigger mode before num_triggers due to change in Eiger REST API change + # Setting trigger mode before num_triggers due to change in Eiger REST API change + self.detector.cam.trigger_mode.put(eiger.EXTERNAL_ENABLE) self.detector.cam.num_triggers.put(total_num_images) self.detector.cam.file_path.put(data_directory_name) self.detector.cam.fw_name_pattern.put(f"{file_prefix_minus_directory}_$id") @@ -147,8 +148,6 @@ def detector_arm(self, **kwargs): self.detector.file.file_write_images_per_file.put(num_images_per_file) - start_arm = ttime.time() - def armed_callback(value, old_value, **kwargs): if old_value == 0 and value == 1: return True @@ -158,8 +157,7 @@ def armed_callback(value, old_value, **kwargs): self.detector.cam.acquire.put(1) - status.wait() - logger.info(f"arm time = {ttime.time() - start_arm}") + return status def describe_collect(self): return {"stream_name": {}}