csaxs_bec.scans.scan_customization.scan_modifier.CsaxsBecScanModifier#
- class CsaxsBecScanModifier(**kwargs)[source]#
Bases:
ScanModifierScan modifier for csaxs_bec.
By inheriting from the ScanModifier base class, you get access to currently running scan (self.scan), the devices (self.dev), the scan info (self.scan_info), the scan components (self.components) and the scan actions (self.actions).
Initialize the scan modifier.
Methods
Check if the specified device(s) are available.
Define GUI configuration overrides for the scan modifier.
Define scan signature overrides for the scan modifier.
- device_is_available(device: list[str] | str, check_enabled: bool = True) bool#
Check if the specified device(s) are available. This can be used to conditionally enable or disable the scan modifier based on the availability of certain devices. The device(s) can be specified as a string (for a single device) or a list of strings (for multiple devices).
- Parameters:
device (str or list of str) – The name(s) of the device(s) to check for availability.
check_enabled (bool) – If True, also check if the device is enabled.
- Returns:
True if all specified devices are available, False otherwise.
- Return type:
bool
- static gui_config_overrides(scan_name: str, gui_config: dict[str, list[str]]) dict[str, list[str]]#
Define GUI configuration overrides for the scan modifier. This allows the scan modifier to modify the GUI configuration for specific scans. The method receives the original GUI configuration and should return the modified configuration as a dictionary. The scan_name can be used to specify different GUI configuration overrides for different scans.
- Parameters:
scan_name (str) – The name of the scan for which the GUI configuration should be overridden.
gui_config (dict) – The original GUI configuration as a dictionary mapping section names to lists of argument names.
- Returns:
The modified GUI configuration as a dictionary mapping section names to lists of argument names.
- Return type:
dict
Examples
>>> # Add the integ_time argument to the "Scan Parameters" section for all scans >>> def gui_config_overrides(scan_name, gui_config): >>> if "Scan Parameters" in gui_config: >>> gui_config["Scan Parameters"].append("integ_time") >>> else: >>> gui_config["Scan Parameters"] = ["integ_time"] >>> return gui_config
>>> # Remove the exp_time argument from the "Scan Parameters" section for the line_scan >>> def gui_config_overrides(scan_name, gui_config): >>> if scan_name == "line_scan": >>> for section, args in gui_config.items(): >>> if "exp_time" in args: >>> args.remove("exp_time") >>> return gui_config
- static scan_signature_overrides(scan_name: str, arguments: dict[str, Annotated[Any, ScanArgument] | None], defaults: dict[str, Any]) tuple[dict, dict]#
Define scan signature overrides for the scan modifier. This allows the scan modifier to modify the scan arguments for specific scans. The method receives the original scan signature (arguments and defaults) and should return the modified signature as a tuple (arguments, defaults). The scan_name can be used to specify different signature overrides for different scans.
- Parameters:
scan_name (str) – The name of the scan for which the signature should be overridden.
arguments (dict) – The original scan arguments as a dictionary mapping argument names to their types and ScanArgument metadata.
defaults (dict) – The original scan argument defaults as a dictionary mapping argument names to their default values.
- Returns:
A tuple containing the modified arguments and defaults dictionaries.
- Return type:
tuple
Examples
>>> # Set the default exposure time to 1 second for all scans that have an exp_time argument >>> def scan_signature_overrides(scan_name, arguments, defaults): >>> if "exp_time" in arguments: >>> defaults["exp_time"] = 1.0 >>> return arguments, defaults
>>> # Add a new argument called integ_time to all scans and set its default value to 0.5 seconds >>> # Note that additional args are automatically added to additional_scan_parameters >>> def scan_signature_overrides(scan_name, arguments, defaults): >>> arguments["integ_time"] = Annotated[ >>> float, >>> ScanArgument(description="Integration time for the scan", units=Units.s, ge=0), >>> ] >>> defaults["integ_time"] = 0.5 >>> return arguments, defaults