daq: changes to get background. now save background for zoom and exposure settings. fixed bug where background would be taken at default sam cam settings.

This commit is contained in:
2025-09-05 17:21:22 +02:00
parent e94ba0a084
commit 1e5166ffba
+9 -6
View File
@@ -262,6 +262,8 @@ class AareDAQ:
if target is not None and target.db_id is not None:
self.save_screenshot_db(target.db_id, f"sample_mounted")
# TODO: Need to know if dry needs to happen
@sample.setter
def sample(self, target: SampleShortInfo | None):
# This will set internally state to SampleExchange, but will return to SampleAlignment
@@ -321,9 +323,6 @@ class AareDAQ:
img.spots_ice / img.spots_low_res) < 5.0
and (img.spots_ice / img.spots_low_res) != 1]
if filtered_images:
images = filtered_images
if indexed_images:
print(f"Find image by maximum number of spots indexed")
max_image = max(images, key=lambda img: img.spots_indexed)
@@ -426,6 +425,10 @@ class AareDAQ:
self.__devs.aerotech.reset()
self.__devs.abr_pos = self.__cfg.abr_meas_pos
result = self.__jfjoch.wait_till_done(60)
#if self.sample is not None and self.sample.db_id is not None:
# self.__aare.ingest_gridscan(self.sample, result, r)
new_delta_mm = self.identify_crystal_raster(result, r)
if new_delta_mm is not None:
self.__devs.smargon.target = SmargonCoordinate(sh_mm=r.smargon.sh_mm + new_delta_mm,
@@ -537,13 +540,13 @@ class AareDAQ:
for s in self.__cfg.alc_zoom_settings.z:
self.__devs.samcam_settings = SampleCameraSettings(exposure=s.sam_cam_exp, gain=s.sam_cam_gain)
self.zoom = s.zoom_value
self.__devs.zoom_sync(s.zoom_value)
time.sleep(5.0) # Wait for settings to stabilize
image = self.__devs.sample_cam.get_image(gray=False)
self.__cfg.put_alc_bkg(s.zoom_value, image)
self.__cfg.put_alc_bkg(s.zoom_value, s.sam_cam_exp, s.sam_cam_gain, image)
bgr_array = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
cv2.imwrite(f"bkg{s.zoom_value:.0f}.jpg", bgr_array)
cv2.imwrite(f"bkg{s.zoom_value:.0f}_{s.sam_cam_exp*1000:.0f}_{s.sam_cam_gain:.0f}.jpg", bgr_array)
self.__cfg.state_busy = False
self.__devs.sample_cam.set_auto()
except Exception as e: