DAQ: added a function to set parameters during automation between smart parameters, spreadsheeta dn defaults

This commit is contained in:
martinappleby
2025-11-05 14:34:08 +01:00
parent 98d7e0bac3
commit 9e4e6a3180
+27 -13
View File
@@ -469,6 +469,7 @@ class AareDAQ:
self.__devs.aerotech.move(grid.omega_deg, wait=True)
grid.n_x = 1
#TODO generate y scan rather than had code for 1x50
grid.n_y = 50
grid.file_prefix = f"{old_prefix}_{grid.omega_deg}deg"
grid.grid_size_mm = Coordinate(x=geom.beam_size_mm.x, y=geom.beam_size_mm.y * 0.5)
@@ -1194,6 +1195,23 @@ class AareDAQ:
sample.s = list(filter(lambda x: x.user == pgroup, sample.s))
return sample
def get_collection_params(self, prefer_smart: bool = False) -> tuple[SimpleScanParameters, str]:
if prefer_smart:
# Smart params priority
if self.smart_params:
return self.smart_params, "smart_params"
if self.spreadsheet_params():
return self.spreadsheet_params(), "spreadsheet_params"
else:
# Spreadsheet params priority (current default)
if self.spreadsheet_params():
return self.spreadsheet_params(), "spreadsheet_params"
if self.smart_params:
return self.smart_params, "smart_params"
# Fallback to defaults
return SimpleScanParameters(exp_time_s=0.04, dtz=110, incr_omega_deg=0.2), "defaults"
def measure(self, sample: SampleShortInfo) -> float:
start = time.perf_counter()
formatted_date = datetime.now().strftime('%Y%m%d')
@@ -1230,11 +1248,6 @@ class AareDAQ:
hex_string = secrets.token_hex(3) # 3 bytes = 6 hex characters
print(hex_string.upper())
#self.__ml_bounding_box(sample.db_id, f"ml_{geom.omega_deg:.2f}deg")
low_resolution_flag=False #False for high resolution
if low_resolution_flag:
det_dist = 300.0
else:
det_dist = 110.0
if self.__auto_center(RasterGridRequest(
exp_time_s=0.02,
@@ -1242,21 +1255,22 @@ class AareDAQ:
smargon= SmargonCoordinate(),
n_x=1,
n_y=1,
dtz=det_dist,
dtz=110,
grid_size_mm=Coordinate(x=geom.beam_size_mm.x * 0.5, y=geom.beam_size_mm.y * 0.5),
omega_deg=0
)):
logger.info(f"raster scans done at {time.perf_counter() - start}")
params = self.smart_params
logger.info(f"data collection stratergy params: {params}")
params, source = self.get_collection_params(prefer_smart=False)
logger.info(f"Using {source} for data collection: {params}")
self.__cfg.zoom_mode = ZoomModeEnum.User
self.__devs.samcam_settings = self.__cfg.zoom_settings.get_camera_settings(self.zoom)
self.__rotation( RotationScanRequest(start_omega_deg=0,
dtz=det_dist,
self.__rotation( RotationScanRequest(start_omega_deg=params.start_omega_deg,
dtz=params.dtz,
file_prefix=sample_prefix + f"_{hex_string}",
exp_time_s=0.04,
incr_omega_deg=0.2,
steps=900,))
exp_time_s=params.exp_time_s,
incr_omega_deg=params.incr_omega_deg,
steps=params.steps,))
logger.info(f"rotation done at {time.perf_counter() - start}")
else:
print("auto center failed")