csaxs_bec.scans.omny_fermat_scan.OMNYFermatScan#
- class OMNYFermatScan(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:
SyncFlyScanBaseAn OMNY 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
frames_per_trigger – int: Number of burst frames per trigger, defaults to 1.
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.omny_fermat_scan(fovx=20, fovy=25, cenx=10, ceny=0, zshift=0, angle=0, step=2, exp_time=0.01)
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 positions for a Fermat spiral 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
omny_rotationopen 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
Reverse the trajectory.
run the scan.
perform a reading of all baseline devices
run pre scan macros if any
scanperform the scan core procedure
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_omny_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#
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.
- 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
- 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
- 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.