csaxs_bec.scans.sgalil_grid.SgalilGrid#
- class SgalilGrid(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.1, **kwargs)[source]#
Bases:
AsyncFlyScanBaseSGalil-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 the quality of a path by looking at the distribution of step sizes.
call the cleanup procedure
close the scan
device_msg_metadatafinalize the scan
Calculate the total length of a path defined by a sequence of positions.
Calculate the radial distance from the origin for each position
initializereturn to the start position
open the scan
Optimize positions using a corridor-based approach.
Optimize path by always moving to the nearest unvisited point.
Optimize a path through a set of positions by sorting them in concentric shells.
pre scan procedure.
prepare the positions for the scan
read the scan motors
run the scan.
perform a reading of all baseline devices
run pre scan macros if any
scanThis is the main event loop.
Timeout of the progress bar.
scan_report_instructionscall the stage procedure
call the unstage procedure
update the readout priority for this request.
Scan motors are automatically elevated to readout priority monitored and read out in the beginning of the scan.
Attributes
arg_bundle_sizearg_inputgui_argsmonitor_sync is the flyer that will be used to synchronize the monitor readings in the scan bundler.
pre_moverequired_kwargsreturn_to_start_after_abortscan_namedevices to be included in the scan report
scan_report_hintscan_typeuse_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
- finalize()#
finalize the scan
- 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 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()#
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_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
- 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.