Apply suggestions from code review of branch fast-stack

Co-authored-by: Beth Probert <beth_probert@outlook.com>
This commit is contained in:
Julian Stirling 2025-06-27 10:41:53 +00:00
parent 73e54b802b
commit fc6c13f40e
5 changed files with 16 additions and 14 deletions

View file

@ -357,7 +357,7 @@ class SmartSpiral(ScanPlanner):
for this location. This overrides the default behaviour of ScanPlanner
to take the lowest value of nearest neighbours as this works best for smart stack
Note z-position may be None! This indicates that the current z, position
Note z-position may be None! This indicates that the current z position
should be used.
"""
if self.scan_complete:
@ -365,7 +365,7 @@ class SmartSpiral(ScanPlanner):
next_location = self._remaining_locations[0]
# If focussed locations exist, return the neighbour with the lowest z position
# If focused locations exist, return the neighbour with the lowest z position
closest_pos = self.select_nearby_focus_site(next_location)
if closest_pos is None:
z = None
@ -381,7 +381,7 @@ class SmartSpiral(ScanPlanner):
autofocus and restart. Starting too low just requires extra movements in +z.
Nearby is defined as within NEIGHBOUR_CUTOFF times the distance to the closest neighbour.
Returns None if there if no focussed locations are present
Returns None if there if no focused locations are present
"""
if not self._focused_locations:
return None
@ -390,7 +390,7 @@ class SmartSpiral(ScanPlanner):
current_pos = np.array(xy_pos, dtype="float64")
path_pos = np.array(self._focused_locations, dtype="float64")[:, :2]
# Use linalg.norm to calculate the direct distance bweween the points
# Use linalg.norm to calculate the direct distance between the points
# Note linalg.norm always uses float64
dists = np.linalg.norm((path_pos - current_pos), axis=1)

View file

@ -37,7 +37,7 @@ class StackParams:
:param min_images_to_test: The minimum number of images in the stack before, the
stack is evaluated for focus. As more images are captured evaluation of the focus
is always evaluated with the same number of images. i.e. if min_images_to_test=9,
then 9 images are captured, if the stack is not well focussed, a 10th image is
then 9 images are captured, if the stack is not well focused, a 10th image is
captured and images 2 to 10 are evaluated for focus
:param autofocus_dz: The number of steps in a full autofocus (when required)
:param images_dir: The directory to save images to disk
@ -582,7 +582,7 @@ class AutofocusThing(Thing):
# If the sharpest image isn't found within the maximum number of images
# end the loop and return "restart"
while len(captures) <= stack_parameters.max_images_to_test:
while len(captures) < stack_parameters.max_images_to_test:
time.sleep(stack_parameters.settling_time)
# Append a new image to the stack

View file

@ -69,7 +69,7 @@ class CameraMemoryBuffer:
def add_image(
self, image: Any, metadata: Optional[dict] = None, buffer_max: int = 1
) -> None:
) -> int:
"""
Add an image to the Memory buffer