csaxs_bec.scans.owis_grid.OwisGrid#

class OwisGrid(start_y: float, end_y: float, interval_y: int, start_x: float, end_x: float, interval_x: int, *args, exp_time: float = 0.1, readout_time: float = 0.003, **kwargs)[source]#

Bases: AsyncFlyScanBase

Owis-based grid scan.

Owis-based grid scan.

Parameters:
  • start_y (float) – start position of y axis (fast axis)

  • end_y (float) – end position of y axis (fast axis)

  • interval_y (int) – number of points in y axis

  • start_x (float) – start position of x axis (slow axis)

  • end_x (float) – end position of x axis (slow axis)

  • interval_x (int) – number of points in x axis

  • exp_time (float) – exposure time in seconds. Default is 0.1s

  • readout_time (float) – readout time in seconds, minimum of 3e-3s (3ms)

Exp:

scans.sgalil_grid(start_y = val1, end_y= val1, interval_y = val1, start_x = val1, end_x = val1, interval_x = val1, exp_time = 0.02, readout_time = 3e-3)

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

compute_scan_params

Compute scan parameters.

device_msg_metadata

finalize

Finalize scan, set motor speed and acceleration to initial values

get_initial_motor_properties

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 instructions, move to start position

prepare_positions

prepare the positions for the scan

read_scan_motors

read the scan motors

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

This is the main event loop.

scan_progress

Timeout of the progress bar.

scan_report_instructions

Scan report instructions for the progress bar, yields from mcs card

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_report_hint

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()#

call the cleanup procedure

close_scan()#

close the scan

compute_scan_params()[source]#

Compute scan parameters. This includes the velocity, acceleration and premove distance.

finalize()[source]#

Finalize scan, set motor speed and acceleration to initial values

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#

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()#

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()[source]#

Pre scan instructions, move to start position

prepare_positions()#

prepare the positions for the scan

read_scan_motors()#

read the scan motors

run()#

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]#

This is the main event loop.

scan_progress() int[source]#

Timeout of the progress bar. This gets updated in the frequency of scan segments

property scan_report_devices#

devices to be included in the scan report

scan_report_instructions()[source]#

Scan report instructions for the progress bar, yields from mcs card

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.