DAQ: COM added debug statement, crystal_size logs crystal size and quality condition filter now uses max low res spots to create a threshold of 30% - currently hardcoded
This commit is contained in:
@@ -141,12 +141,14 @@ def create_quality_filtered_array(scan_results: List,
|
||||
Create array with comprehensive quality filtering
|
||||
"""
|
||||
|
||||
def quality_condition(result, min_bkg, min_spots, min_efficiency, min_res_spots = 10.0):
|
||||
def quality_condition(result, max_spots_low_res, min_background, min_spots, min_efficiency, min_res_spots = 10.0):
|
||||
if exclude_ice and (result.spots_ice / max(result.spots_low_res, 1.0)) == 1.0:
|
||||
# print(f"all ice for {result.number}")
|
||||
return False
|
||||
if result.spots_low_res < min_res_spots:
|
||||
return False
|
||||
if result.spots_low_res < (max_spots_low_res * (30/100)):
|
||||
return False
|
||||
if exclude_ice and result.spots_ice > result.spots * 0.8: # More than 50% ice
|
||||
# print(f"more than 80% ice for {result.number}")
|
||||
return False
|
||||
@@ -173,10 +175,11 @@ def create_quality_filtered_array(scan_results: List,
|
||||
min_background = min((result.bkg for result in scan_results if result.bkg is not None), default=1)
|
||||
if min_efficiency is None:
|
||||
min_efficiency = 1.0
|
||||
max_spots_low_res = max((result.spots_low_res for result in scan_results if result.spots is not None), default=1)
|
||||
|
||||
for result in scan_results:
|
||||
if result.nx is not None and result.ny is not None:
|
||||
if quality_condition(result, min_bkg=min_background, min_spots=min_spots,
|
||||
if quality_condition(result, max_spots_low_res=max_spots_low_res, min_background=min_background, min_spots=min_spots,
|
||||
min_efficiency=min_efficiency, min_res_spots=min_low_res_spots):
|
||||
filtered_results.append(result)
|
||||
else:
|
||||
@@ -211,12 +214,14 @@ def get_xtal_size(crystal_size, result_array, r:RasterGridRequest):
|
||||
logger.debug("calculating z")
|
||||
crystal_size = CrystalSize(x=crystal_size.x, y=crystal_size.y,
|
||||
z=(col_max - col_min) * r.grid_size_mm.y * 1000)
|
||||
logger.info(f"Crystal Size: x={crystal_size.x}, y={crystal_size.y}, z={crystal_size.z}")
|
||||
|
||||
else:
|
||||
logger.debug("calculating x and y")
|
||||
crystal_size = CrystalSize(x=(row_max - row_min) * r.grid_size_mm.x * 1000,
|
||||
y=(col_max - col_min) * r.grid_size_mm.y * 1000,
|
||||
z=crystal_size.z)
|
||||
logger.info(f"Crystal Size: x={crystal_size.x}, y={crystal_size.y}, z={crystal_size.z}")
|
||||
except ValueError as e:
|
||||
logger.error(f"error calculating xtal size: {e}")
|
||||
crystal_size = CrystalSize(x=0,y=0,z=0)
|
||||
@@ -280,9 +285,9 @@ def get_grid_mm_from_com(com, r:RasterGridRequest):
|
||||
|
||||
|
||||
def raster_centre_of_mass(result_array, r:RasterGridRequest):
|
||||
logger.debug('horizontal scan')
|
||||
com = ndimage.center_of_mass(result_array)
|
||||
logger.info(f"Center of mass: {com}")
|
||||
grid_mm_x, grid_mm_y = get_grid_mm_from_com(com, r)
|
||||
logger.debug("using spot count instead of COM")
|
||||
return grid_mm_x, grid_mm_y, com
|
||||
|
||||
|
||||
Reference in New Issue
Block a user