DAQ: add some logic to automation parameters for raster.
This commit is contained in:
+41
-5
@@ -1200,6 +1200,42 @@ class AareDAQ:
|
||||
sample.s = list(filter(lambda x: x.user == pgroup, sample.s))
|
||||
return sample
|
||||
|
||||
def get_auto_raster_params(self) -> SimpleScanParameters:
|
||||
|
||||
if self.status.sample is None:
|
||||
return SimpleScanParameters(dtz=150, exp_time_s=0.04, transmission=1.0)
|
||||
|
||||
aaredb_params = self.status.sample.aaredb_params if hasattr(self.status.sample, "aaredb_params") else None
|
||||
|
||||
if aaredb_params is None:
|
||||
return SimpleScanParameters(dtz=150, exp_time_s=0.04, transmission=1.0)
|
||||
|
||||
params = SimpleScanParameters()
|
||||
|
||||
if (exp := getattr(aaredb_params, 'exposure', 0.04)) is not None:
|
||||
params.exp_time_s = exp
|
||||
|
||||
if (trans := getattr(aaredb_params, 'transmission', 100)) is not None:
|
||||
logger.debug(f"transmission: {trans}")
|
||||
params.transmission = trans / 100.0 if trans > 1.0 else trans
|
||||
|
||||
if (res := getattr(aaredb_params, 'targetresolution', 1.42)) is not None:
|
||||
logger.debug(f"resolution: {res}")
|
||||
logger.debug(f"dtz: {self.diffraction_geometry.calc_dtz_mm(res)}")
|
||||
params.dtz = self.diffraction_geometry.calc_dtz_mm(res)
|
||||
|
||||
if res <= 1.5:
|
||||
params.exp_time_s = 0.02
|
||||
elif 1.5 < res <= 3.0:
|
||||
params.exp_time_s = 0.04
|
||||
else:
|
||||
params.exp_time_s = 0.08
|
||||
|
||||
logger.debug(f"res expected {res} using {params.exp_time_s} exp time")
|
||||
|
||||
return params
|
||||
|
||||
|
||||
def get_collection_params(self, prefer_smart: bool = False) -> tuple[SimpleScanParameters, str]:
|
||||
spreadsheet_params = self.spreadsheet_params()
|
||||
logger.debug(f"spreadsheet_params: {spreadsheet_params}")
|
||||
@@ -1255,17 +1291,17 @@ 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")
|
||||
|
||||
raster_params = self.get_auto_raster_params()
|
||||
if self.__auto_center(RasterGridRequest(
|
||||
exp_time_s=0.04,
|
||||
exp_time_s=raster_params.exp_time_s,
|
||||
file_prefix=sample_prefix + f"_{hex_string}",
|
||||
smargon= SmargonCoordinate(),
|
||||
n_x=1,
|
||||
n_y=1,
|
||||
dtz=150,
|
||||
dtz=raster_params.dtz,
|
||||
grid_size_mm=Coordinate(x=geom.beam_size_mm.x * 0.5, y=geom.beam_size_mm.y * 0.5),
|
||||
omega_deg=0,
|
||||
transmission = 1.0,
|
||||
omega_deg=self.omega,
|
||||
transmission = raster_params.transmission,
|
||||
)):
|
||||
logger.info(f"raster scans done at {time.perf_counter() - start}")
|
||||
params, source = self.get_collection_params(prefer_smart=False)
|
||||
|
||||
Reference in New Issue
Block a user