This commit is contained in:
@@ -283,13 +283,16 @@ def get_com_image_number(com, images):
|
||||
|
||||
|
||||
|
||||
def raster_centre_of_mass(result_array, r:RasterGridRequest) -> CenterOfMassModel | None:
|
||||
def raster_centre_of_mass(result_array, images) -> CenterOfMassModel | None:
|
||||
# grid_mm_x and grid_mm_y are relative to the top left corner of raster grid
|
||||
com = ndimage.center_of_mass(result_array)
|
||||
if com or not np.isnan(com[0]) or not np.isnan(com[1]):
|
||||
if com and not np.isnan(com[0]) and not np.isnan(com[1]):
|
||||
logger.info(f"Center of mass: {com}")
|
||||
max_image = get_com_image_number(com, result_array.images)
|
||||
max_image = get_com_image_number(com, images)
|
||||
return CenterOfMassModel(n_x=com[0], n_y=com[1], max_image=max_image)
|
||||
elif com and np.isnan(com[0]) and np.isnan(com[1]):
|
||||
logger.warning(f"Center of mass is nan: {com[0]}, {com[1]}")
|
||||
return None
|
||||
else:
|
||||
logger.warning("No valid center of mass found")
|
||||
return None
|
||||
|
||||
@@ -553,7 +553,7 @@ class AareDAQ:
|
||||
result_array = create_quality_filtered_array(images, 'spots_low_res', min_spots=None,
|
||||
min_efficiency=1.0, min_background=None, min_low_res_spots=None)
|
||||
self.__cfg.crystal_size = get_xtal_size(self.__cfg.crystal_size, result_array, r)
|
||||
com = raster_centre_of_mass(result_array, r)
|
||||
com = raster_centre_of_mass(result_array, images)
|
||||
if com is None:
|
||||
logger.debug(f"using old method as COM is disabled")
|
||||
com = identify_crystal_raster(result, r)
|
||||
@@ -589,7 +589,7 @@ class AareDAQ:
|
||||
phi_deg=new_target.phi_deg,
|
||||
chi_deg=new_target.chi_deg)
|
||||
else:
|
||||
logger.error("Auto finding optimal image failed due to no images found. Using previous position.")
|
||||
logger.error("Auto finding optimal image failed. Using previous position.")
|
||||
self.__devs.smargon.target = save_smargon_position
|
||||
|
||||
if self.sample is not None and self.sample.db_id is not None and result is not None:
|
||||
|
||||
Reference in New Issue
Block a user