class documentation

A base class for a scan planner.

This should never be used directly for a scan, it should be subclassed.

Each subclass should implement at least the methods with NotImplementedError set:

  • _parse() - to parse the planner_settings dictionary, saving values to class
    variables
  • _initial_location_list() - Sets the list of locations for the scan to follow

For a simple scan pattern this should be sufficient. For more complex ones that dynamically adjust the path it is suggested to override mark_location_visited() calling super().mark_location_visited() at the start of the method so that all locations are adjusted.

When subclassing be sure to use enforce_xy_tuple and enforce_xyz_tuple on any user data before running.

Method __init__ Set up lists for the path planning, and scan history.
Method get_next_location_and_z_estimate Return the next location to scan and its estimated z-position.
Method get_visited_location Return the scan location from the history that matches the input position.
Method mark_location_visited Mark the location as visited.
Method position_planned Return True if input scan position position is planned.
Method position_visited Return True if input scan position has been visited before.
Method select_nearby_focus_site Return the focused site near xy_pos according to the tiebreak.
Property completion_reason A human readable explanation of why the scan has (or hasn't) finished.
Property focused_locations Property to access a copy of the focused_locations.
Property focused_locations_xyz Property to access a copy of the focused_locations.
Property imaged_locations Property to access a copy of the imaged_locations.
Property path_history Property to access a copy of the path_history.
Property remaining_locations Property to access a copy of the remaining_locations.
Property scan_complete Return True if there are no locations left to scan.
Method _grid_to_future_locations Flatten a 2D grid of coordinates into flat list of FutureScanLocation objects.
Method _initial_location_list Set the initial list of locations for this scan planner.
Method _parse Parse any settings sent to this planner and store them if needed.
Instance Variable _initial_position Undocumented
Instance Variable _path_history Undocumented
Instance Variable _remaining_locations Undocumented
def __init__(self, initial_position: XYPos, planner_settings: dict | None = None): (source)

Set up lists for the path planning, and scan history.

def get_next_location_and_z_estimate(self) -> tuple[XYPos, int | None]: (source)

Return the next location to scan and its estimated z-position.

Note z-position may be None! This indicates that the current z, position should be used.

def get_visited_location(self, position: XYPos | XYZPos | FutureScanLocation) -> VisitedScanLocation: (source)

Return the scan location from the history that matches the input position.

def mark_location_visited(self, xyz_pos: XYZPos, imaged: bool, focused: bool): (source)

Mark the location as visited.

Parameters
xyz_pos:XYZPosthe x_y_z position
imaged:booltrue if an image was taken, false if not (due to background detect)
focused:booltrue if autofocus completed successfully
def position_planned(self, position: XYPos | FutureScanLocation) -> bool: (source)

Return True if input scan position position is planned.

def position_visited(self, position: XYPos | FutureScanLocation) -> bool: (source)

Return True if input scan position has been visited before.

def select_nearby_focus_site(self, next_location: XYPos) -> XYZPos | None: (source)

Return the focused site near xy_pos according to the tiebreak.

@property
completion_reason: str = (source)

A human readable explanation of why the scan has (or hasn't) finished.

The base implementation only distinguishes "still going" from "ran out of planned locations". Subclasses that can stop for more than one reason (for example, hitting a range limit vs. running out of sample to follow) should override this to give a more specific explanation, as this is used for end-of-scan logging.

@property
focused_locations: list[VisitedScanLocation] = (source)

Property to access a copy of the focused_locations.

@property
focused_locations_xyz: XYZPosList = (source)

Property to access a copy of the focused_locations.

@property
imaged_locations: XYZPosList = (source)

Property to access a copy of the imaged_locations.

@property
path_history: XYPosList = (source)

Property to access a copy of the path_history.

@property
remaining_locations: XYPosList = (source)

Property to access a copy of the remaining_locations.

@property
scan_complete: bool = (source)

Return True if there are no locations left to scan.

def _grid_to_future_locations(self, grid: list[list[XYPos]]) -> list[FutureScanLocation]: (source)

Flatten a 2D grid of coordinates into flat list of FutureScanLocation objects.

Parameters
grid:list[list[XYPos]]A 2D nested list of XY coordinates
Returns
list[FutureScanLocation]A flattened list of FutureScanLocations
def _initial_location_list(self) -> list[FutureScanLocation]: (source)

Set the initial list of locations for this scan planner.

This is called on initialisation.

For a simple grid scan/snake scan this would be all locations to move to.

Returns
list[FutureScanLocation]A list of FutureScanLocation objects with all planned locations.
def _parse(self, planner_settings: dict | None = None): (source)

Parse any settings sent to this planner and store them if needed.

_initial_position = (source)

Undocumented

_path_history: list[VisitedScanLocation] = (source)

Undocumented

_remaining_locations: list[FutureScanLocation] = (source)

Undocumented