csaxs_bec.scans.flomni_fermat_scan.FlomniFermatScan#

class FlomniFermatScan(fovx: float, fovy: float, cenx: float, ceny: float, exp_time: float, step: float, zshift: float, angle: float = None, corridor_size: float = 3, parameter: dict = None, frames_per_trigger: int = 1, **kwargs)[source]#

Bases: AsyncFlyScanBase

A flomni scan following Fermat’s spiral.

Parameters:
  • fovx (float) – Fov in the piezo plane (i.e. piezo range). Max 200 um

  • fovy (float) – Fov in the piezo plane (i.e. piezo range). Max 100 um

  • cenx (float) – center position in x.

  • ceny (float) – center position in y.

  • exp_time (float) – exposure time per burst frame

  • frames_per_trigger (int) – Number of burst frames per point

  • step (float) – stepsize

  • zshift (float) – shift in z

  • angle (float) – rotation angle (will rotate first)

  • corridor_size (float) – corridor size for the corridor optimization. Default 3 um

Returns:

Examples

>>> scans.flomni_fermat_scan(fovx=20, fovy=25, cenx=0.02, ceny=0, zshift=0, angle=0, step=0.5, exp_time=0.01, frames_per_trigger=1)

Methods

analyze_path_quality

Analyze the quality of a path by looking at the distribution of step sizes.

cleanup

call the cleanup procedure

close_scan

close the scan

device_msg_metadata

finalize

finalize the scan

flomni_rotation

get_flomni_fermat_spiral_pos

Calculate positions for a Fermat spiral scan.

get_path_length

Calculate the total length of a path defined by a sequence of positions.

get_radius

Calculate the radial distance from the origin for each position

initialize

move_to_start

return to the start position

open_scan

open the scan

optimize_corridor

Optimize positions using a corridor-based approach.

optimize_nearest_neighbor

Optimize path by always moving to the nearest unvisited point.

optimize_shell

Optimize a path through a set of positions by sorting them in concentric shells.

pre_scan

pre scan procedure.

prepare_positions

prepare the positions for the scan

read_scan_motors

read the scan motors

reverse_trajectory

Reverse the trajectory.

run

run the scan.

run_baseline_reading

perform a reading of all baseline devices

run_pre_scan_macros

run pre scan macros if any

scan

scan_core

perform the scan core procedure

scan_report_instructions

Scan report instructions for the progress bar

stage

call the stage procedure

unstage

call the unstage procedure

update_readout_priority

update the readout priority for this request.

update_scan_motors

Scan motors are automatically elevated to readout priority monitored and read out in the beginning of the scan.

Attributes

arg_bundle_size

arg_input

gui_args

monitor_sync

monitor_sync is the flyer that will be used to synchronize the monitor readings in the scan bundler.

pre_move

required_kwargs

return_to_start_after_abort

scan_name

scan_report_devices

devices to be included in the scan report

scan_type

use_scan_progress_report

analyze_path_quality(pos: ndarray) PathQualityStats#

Analyze the quality of a path by looking at the distribution of step sizes.

Parameters:

pos (np.ndarray) – Array of positions

Returns:

Dictionary with statistics about the path quality

Return type:

dict

cleanup()[source]#

call the cleanup procedure

close_scan()#

close the scan

finalize()#

finalize the scan

get_flomni_fermat_spiral_pos(m1_start, m1_stop, m2_start, m2_stop, step=1, spiral_type=0, center=False)[source]#

Calculate positions for a Fermat spiral scan.

Parameters:
  • m1_start (float) – start position in m1

  • m1_stop (float) – stop position in m1

  • m2_start (float) – start position in m2

  • m2_stop (float) – stop position in m2

  • step (float) – stepsize

  • spiral_type (int) – 0 for traditional Fermat spiral

  • center (bool) – whether to include the center position

Returns:

positions

Return type:

positions(array)

get_path_length(pos: ndarray) float#

Calculate the total length of a path defined by a sequence of positions. :param pos: Array of positions :type pos: np.ndarray

Returns:

Total path length

Return type:

float

get_radius(pos: ndarray) ndarray#

Calculate the radial distance from the origin for each position

Parameters:

pos (np.ndarray) – Array of positions

Returns:

Radial distances

Return type:

np.ndarray

property monitor_sync: str#

monitor_sync is the flyer that will be used to synchronize the monitor readings in the scan bundler. The return value should be the name of the flyer device.

move_to_start()[source]#

return to the start position

open_scan()#

open the scan

optimize_corridor(positions: ndarray, corridor_size: float | None = None, sort_axis: int = 1, num_iterations: int = 1, preferred_direction: int | None = None, corridor_estimation: Literal['density', 'median_distance'] = 'median_distance')#

Optimize positions using a corridor-based approach.

Note: This method is designed for 2D positions. If higher dimensions are provided, the positions are returned unmodified.

Parameters:
  • positions (np.ndarray) – Array of positions

  • corridor_size (float, optional) – Width of each corridor. Defaults to None (auto-estimated).

  • sort_axis (int, optional) – Axis along which to create corridors (0 or 1). Defaults to 1.

  • num_iterations (int, optional) – Number of corridor sizes to try. Defaults to 1.

  • preferred_direction (int | None, optional) – Preferred direction for the primary axis (1 or -1). If None, alternates direction for each corridor.

  • corridor_estimation (str, optional) – Method for estimating corridor size if not provided. Options are “density” or “median_distance”. Defaults to “density”.

Returns:

Optimized positions

Return type:

np.ndarray

optimize_nearest_neighbor(positions: ndarray, start_index: int | None = None) ndarray#

Optimize path by always moving to the nearest unvisited point.

This is a greedy algorithm that provides good results for many scenarios with relatively low computational complexity.

Parameters:
  • positions (np.ndarray) – Array of positions

  • start_index (int | None, optional) – Index of the starting point. If None, the algorithm will start from the point closest to the origin.

Returns:

Optimized positions

Return type:

np.ndarray

optimize_shell(pos: ndarray, offset: float | None = None, dr: float | None = None, num_iterations: int = 3)#

Optimize a path through a set of positions by sorting them in concentric shells.

Parameters:
  • pos (np.ndarray) – Array of positions

  • offset (float, optional) – Offset for the first shell. Defaults to None (auto-estimated).

  • dr (float, optional) – Width of each shell. Defaults to None (auto-estimated).

  • num_iterations (int, optional) – Number of parameter variations to try. Defaults to 3.

Returns:

Optimized positions

Return type:

np.ndarray

pre_scan()#

pre scan procedure. This method is called before the scan_core method and can be used to perform additional tasks before the scan is started. This

prepare_positions()[source]#

prepare the positions for the scan

read_scan_motors()#

read the scan motors

reverse_trajectory()[source]#

Reverse the trajectory. Every other scan should be reversed to shorten the movement time. In order to keep the last state, even if the server is restarted, the state is stored in a global variable in redis.

run()[source]#

run the scan. This method is called by the scan server and is the main entry point for the scan.

run_baseline_reading()#

perform a reading of all baseline devices

run_pre_scan_macros()#

run pre scan macros if any

scan_core()[source]#

perform the scan core procedure

property scan_report_devices#

devices to be included in the scan report

scan_report_instructions()[source]#

Scan report instructions for the progress bar

stage()#

call the stage procedure

unstage()#

call the unstage procedure

update_readout_priority()#

update the readout priority for this request. Typically the monitored devices should also include the scan motors.

update_scan_motors() None#

Scan motors are automatically elevated to readout priority monitored and read out in the beginning of the scan.