From f214062e36df51737193ed4d9c5e685ef6ea1a6d Mon Sep 17 00:00:00 2001 From: x01da Date: Mon, 10 Aug 2026 21:19:57 +0200 Subject: [PATCH] wip widget --- .../scan_control_xas/scan_control_xas.py | 61 +++++++------------ 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/debye_bec/bec_widgets/widgets/scan_control_xas/scan_control_xas.py b/debye_bec/bec_widgets/widgets/scan_control_xas/scan_control_xas.py index c58202b..45ad514 100644 --- a/debye_bec/bec_widgets/widgets/scan_control_xas/scan_control_xas.py +++ b/debye_bec/bec_widgets/widgets/scan_control_xas/scan_control_xas.py @@ -7,7 +7,6 @@ from typing import Literal, Optional import numpy as np import pyqtgraph as pg -import xraydb from bec_lib import bec_logger from bec_lib.endpoints import MessageEndpoints from bec_widgets.utils.bec_dispatcher import BECDispatcher @@ -34,7 +33,6 @@ from qtpy.QtWidgets import ( # pylint: disable=E0402 from ....devices.mo1_bragg.mo1_bragg_utils import compute_spline from ..edge_selector import EdgeSelector -from .qt_widgets import Button, ComboBox, ElementSelector, TextIndicator logger = bec_logger.logger @@ -45,6 +43,16 @@ ALLOWED_SCANS = [ "xas_advanced_scan_with_xrd", ] +PLOT_RESOLUTION = 100 +H = 6.62606957e-34 +E = 1.602176634e-19 +C = 299792458 + +X01DA_E_MIN = 4500 +X01DA_E_MAX = 60000 +X10DA_E_MIN = 4500 +X10DA_E_MAX = 35000 + class ScanControlXAS(ScanControl): """ @@ -111,9 +119,7 @@ class ScanControlXAS(ScanControl): @SafeSlot() def _scan_parameter_changed(self, *_): - # logger.info(f"Fe K edge: {xraydb.xray_edge("Fe", "K", energy_only=True)}") params = self.get_scan_parameters()[1] - # logger.info(f"Scan parameters: {params}") self.motion_profile_widget.update_plot( scan_name=self._selected_scan, scan_parameters=params ) @@ -128,12 +134,6 @@ class ScanControlXAS(ScanControl): self.motion_profile_widget.apply_theme(theme) -PLOT_RESOLUTION = 100 -H = 6.62606957e-34 -E = 1.602176634e-19 -C = 299792458 - - class MotionProfileWidget(QWidget): """ Additional widget specifically for XAS scans @@ -142,13 +142,15 @@ class MotionProfileWidget(QWidget): def __init__(self, parent): super().__init__() self._parent_widget = parent + hostname = self.parent.client._hostname + start = hostname.find("x") + self.beamline = "" + if start != -1: + self.beamline = hostname[start : start + 5] + outer_layout = QVBoxLayout(self) outer_layout.setContentsMargins(0, 0, 0, 0) - # self.element = ElementSelector() - # self.edge = ComboBox("Edge", "Edge", ["K", "L1", "L2", "L3"]) - # self.edge_text = TextIndicator("", "Selected Edge", "No edge selected") - edge_selector_layout = QHBoxLayout(self) edge_selector_label = QLabel("Absorption edge:") self.edge_selector_button = QPushButton("Choose") @@ -190,9 +192,6 @@ class MotionProfileWidget(QWidget): scroll.setWidget(plot_container) self.edge_selection = QHBoxLayout() - # self.edge_selection.addWidget(self.element) - # self.edge_selection.addWidget(self.edge) - # self.edge_selection.addWidget(self.edge_text) self.edge_selection.addLayout(edge_selector_layout) self.edge_selection.addStretch(1) outer_layout.addLayout(self.edge_selection) @@ -205,8 +204,6 @@ class MotionProfileWidget(QWidget): self.edge_selector_button.clicked.connect(self._update_edge) self.scan_rng_ckbox.stateChanged.connect(self._update_auto_scan_rng) - # self.element.dialogClosed.connect(self._update_edge_selection) - # self.edge.activated_connect(self._update_edge_selection) self.apply_theme() @@ -249,7 +246,13 @@ class MotionProfileWidget(QWidget): @SafeSlot() def _update_edge(self, *_): - dlg = EdgeSelector(self, llim=4500, hlim=60000) + match self.beamline: + case "x01da": + dlg = EdgeSelector(self, llim=X01DA_E_MIN, hlim=X01DA_E_MAX) + case "x10da": + dlg = EdgeSelector(self, llim=X10DA_E_MIN, hlim=X10DA_E_MAX) + case _: + dlg = EdgeSelector(self) if dlg.exec_(): self.edge_energy = dlg.active_energy self.edge_label.setText( @@ -269,23 +272,6 @@ class MotionProfileWidget(QWidget): } ) - # @SafeSlot() - # def _update_edge_selection(self, *_, **__): - # if self.element.currentElement() == "": - # return - # if self.edge.currentText() == "": - # return - # self.edge_energy = xraydb.xray_edge( - # self.element.currentElement(), self.edge.currentText(), True - # ) - # if self.edge_energy is not None: - # self.edge_text.setText( - # f"{self.element.currentElement()}, {self.edge.currentText()}-edge, {self.edge_energy:0.1f} eV" - # ) - # else: - # self.edge_text.setText("No valid edge selected!") - # self.update_plot() - @SafeSlot() def update_plot(self, *_, scan_name=None, scan_parameters=None, d_spacing=None, **__): """Update the plots. Parameters which are not defined will default to None, @@ -397,7 +383,6 @@ class MotionProfileWidget(QWidget): for curve, color in zip(curves, colors): if not isinstance(curve, pg.ScatterPlotItem): curve.setPen(pg.mkPen(color=color, width=2)) - # self.element.apply_theme(theme) def _energy_to_angle(self, energy: int | float): if self.d_spacing is None: