*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 05f3f679 authored by Schabbauer, Johannes's avatar Schabbauer, Johannes
Browse files

DCAM: Added using bright pic for calculating occupation matrix.

parent 2249b9e9
No related branches found
No related tags found
1 merge request!6Added: waits with the ADwin, calculate Tweezers occupation from the OrcaQuest mid-shot, reprogram AWG mid-shot
......@@ -213,7 +213,7 @@ class DCAM_Camera(object):
return image
def grab_multiple(self, n_images, images, tweezer_socket=None, tweezer_img_no=None, get_occupation=None):
def grab_multiple(self, n_images, images, tweezer_socket=None, tweezer_img_no=None, bright_img_no=None, get_occupation=None):
"""Grab n_images into images array during buffered acquistion.
Grab method involves a continuous loop with fast timeout in order to
......@@ -233,7 +233,10 @@ class DCAM_Camera(object):
images.append(self.grab(bufferNo=i))
# Send image to occupation receiver
if tweezer_socket and tweezer_img_no==i:
occupation = get_occupation(images[-1])
if bright_img_no is not None:
occupation = get_occupation(images[-1]-images[bright_img_no])
else:
occupation = get_occupation(images[-1]-200)
metadata = dict(dtype=str(occupation.dtype), shape=occupation.shape)
tweezer_socket.send_json(metadata, zmq.SNDMORE)
tweezer_socket.send(occupation, copy=False)
......@@ -319,10 +322,10 @@ class DCAMCameraWorker(IMAQdxCameraWorker):
self.images = []
if properties["occupation_receiver_image_index"] is not None:
tweezers_centers = f["globals"].attrs["tweezers_centers"]
thresholds = f["globals"].attrs["thresholds"]
ROI_size = f["globals"].attrs["ROI_size"]
thresholds = f["globals"].attrs["tweezers_thresholds"]
ROI_size = f["globals"].attrs["tweezers_ROI"]
get_occupation = lambda image: self.get_occupation(image,tweezers_centers,thresholds, ROI_size)
args = (self.n_images, self.images,self.tweezer_socket, properties["occupation_receiver_image_index"], get_occupation)
args = (self.n_images, self.images,self.tweezer_socket, properties["occupation_receiver_image_index"], properties.get("occupation_receiver_bright_index",None), get_occupation)
else:
# Standard args from IMAQdxCameraWorker
args = (self.n_images, self.images)
......
......@@ -30,17 +30,26 @@ class DCAMCamera(IMAQdxCamera):
self.exposure_times = []
super().__init__(name, parent_device, connection, serial_number, orientation, pixel_size, magnification, trigger_edge_type, trigger_duration, minimum_recovery_time, camera_attributes, manual_mode_camera_attributes, stop_acquisition_timeout, exception_on_failed_shot, saved_attribute_visibility_level, mock, **kwargs)
def expose(self, t, name, frametype='frame', trigger_duration=None, send_image_to_occupation_receiver=False):
def expose(self, t, name, frametype='frame', trigger_duration=None, occupation_receiver=False):
self.exposure_times.append(t)
if send_image_to_occupation_receiver:
if getattr(self,"occupation_receiver_time",None) is not None:
raise LabscriptError(f"{self.name}: In the current implementation only a single image can be sent to the 'occupation receiver'")
self.occupation_receiver_time = t
if occupation_receiver:
if getattr(self,"occupation_receiver_time_"+occupation_receiver,None) is not None:
raise LabscriptError(f"{self.name}: In the current implementation only a single image and bright pic can be sent to the 'occupation receiver'")
if occupation_receiver not in ["atoms","bright"]:
raise LabscriptError(f"'occupation_receiver' can only be 'atoms' or 'bright'.")
setattr(self,"occupation_receiver_time_"+occupation_receiver, t)
return super().expose(t, name, frametype, trigger_duration)
def generate_code(self, hdf5_file):
super().generate_code(hdf5_file)
if getattr(self,"occupation_receiver_time",None) is not None:
self.occupation_receiver_image_index = self.exposure_times.index(self.occupation_receiver_time)
if getattr(self,"occupation_receiver_time_atoms",None) is not None:
self.occupation_receiver_image_index = self.exposure_times.index(self.occupation_receiver_time_atoms)
hdf5_file[f"devices/{self.name}"].attrs["occupation_receiver_image_index"] = self.occupation_receiver_image_index
if getattr(self,"occupation_receiver_time_bright",None) is not None:
self.occupation_receiver_bright_index = self.exposure_times.index(self.occupation_receiver_time_bright)
hdf5_file[f"devices/{self.name}"].attrs["occupation_receiver_bright_index"] = self.occupation_receiver_bright_index
# Error check: bright pic must be taken before atoms pic if we want to calculate occupoation matrix mid-shot
if self.occupation_receiver_image_index < self.occupation_receiver_bright_index:
raise LabscriptError("When calculation the occupation mid-shot, the bright pic must be taken before the atom pic!")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment