From 06bcf6df5e839af3f3bf1908ed1201155167b41f Mon Sep 17 00:00:00 2001 From: x10sa Date: Tue, 25 Aug 2026 09:50:44 +0200 Subject: [PATCH] updated pxii_parameters with new calibration values --- pxii_bec/macros/pxii_energy.py | 16 ++++++++++---- pxii_bec/macros/pxii_parameters.py | 34 +++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/pxii_bec/macros/pxii_energy.py b/pxii_bec/macros/pxii_energy.py index adc90e6..1ef07cd 100755 --- a/pxii_bec/macros/pxii_energy.py +++ b/pxii_bec/macros/pxii_energy.py @@ -78,7 +78,7 @@ def set_mirror_stripe(energy_ev): print(f"Selected mirror stripe: {selected_stripe}") -def mono_pitch_scan(plot=True, window_name="Fitting"): +def mono_pitch_scan(plot=True, window_name="Fitting", plot_widget=None): """Scan the monochromator pitch and move to the peak.""" # Move to the calculated pitch value for the current energy print("Starting Mono Pitch Scan.") @@ -104,7 +104,8 @@ def mono_pitch_scan(plot=True, window_name="Fitting"): settle=0.01, plot=True, confirm=False, - window_name=window_name + window_name=window_name, + plot_widget=plot_widget ) else: print("Scanning monochromator pitch and moving to peak, without plotting.") @@ -215,7 +216,12 @@ def move_dcm_motors(energy_ev): ) -def bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True, window_name="Fitting"): +def bl_energy(energy_ev, + move_gap=True, + mono_scan=True, + plot=True, + window_name="Fitting", + plot_widget=None): """ Adjusts the beamline's energy to the specified energy in electron volts (eV). The function validates the target energy, checks the current energy, and makes @@ -254,7 +260,9 @@ def bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True, window_name=" # Step 4: Perform DCM pitch scan and move to peak. if mono_scan: if plot: - result = mono_pitch_scan(plot=True,window_name=window_name) + result = mono_pitch_scan(plot=True, + window_name=window_name, + plot_widget=plot_widget) return result else: mono_pitch_scan(plot=False) diff --git a/pxii_bec/macros/pxii_parameters.py b/pxii_bec/macros/pxii_parameters.py index 1b8b5f9..44b6b92 100755 --- a/pxii_bec/macros/pxii_parameters.py +++ b/pxii_bec/macros/pxii_parameters.py @@ -2,7 +2,7 @@ from dataclasses import dataclass import numpy as np - +from enum import Enum @dataclass(frozen=True) class EnergyDefaults: @@ -192,8 +192,40 @@ class BPM_Y_Calibration: crosshair_signal = -0.01383 crosshair_bpm_position = -1.540 +# @dataclass(frozen=True) +class Beamstop: + x_offset = -0.5 +class CameraZoom(Enum): + X1 = ("1x", 1) + X2 = ("2x", 280) + X3 = ("3x", 500) + X5_8 = ("5.8x", 700) + X7_5 = ("7.5x", 800) + X12_5 = ("12.5x", 1000) + + def __init__(self, label, position): + self.label= label + self.position = position + + @classmethod + def from_position(cls, position, tolerance=2): + """Return zoom level according to motor position""" + for zoom in cls: + if abs(position - zoom.position) <= tolerance: + return zoom + raise ValueError( + f"No camera zoom levle found near motor position {position}" + ) + + @classmethod + def from_label(cls, label): + """Return zoom level corresponding to zoom label""" + for zoom in cls: + if zoom.label.lower() == label.lower(): + return zoom + raise ValueError(f"Unknown camera zoom: {label}")