From 8a401ff15eb7e906126ca10913bc79fe26dedcf0 Mon Sep 17 00:00:00 2001 From: perl_d Date: Thu, 10 Sep 2026 16:09:39 +0200 Subject: [PATCH] feat: add pxiii flux from lookup table --- src/aare/beamline_dispatch/protocols.py | 2 +- .../x06da/beamline_dispatch.py | 48 ++++++++++++++++++- .../x10sa/beamline_dispatch.py | 2 +- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/aare/beamline_dispatch/protocols.py b/src/aare/beamline_dispatch/protocols.py index fbd1f111..e3bc438d 100644 --- a/src/aare/beamline_dispatch/protocols.py +++ b/src/aare/beamline_dispatch/protocols.py @@ -24,7 +24,7 @@ class BecMacros(ABC): def bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True): ... @staticmethod @abstractmethod - def get_current_energy(): ... + def get_current_energy() -> float: ... @staticmethod @abstractmethod def mono_pitch_scan(plot=True): ... diff --git a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py index e88448d7..dfa564fc 100644 --- a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py @@ -1,10 +1,50 @@ from typing import Any +import numpy as np from aarecommon.config.beamline import MXBeamline from aare.beamline_dispatch.default.beamline_dispatch import DefaultDispatch, DefaultGeometry from aare.beamline_dispatch.protocols import BecMacros +# fmt: off +FLUX_ENERGY_KEV = np.asarray([ + 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, + 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, + 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, + 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, + 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, + 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, + 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, + 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, + 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, + 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, + 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, + 15.0, +], dtype=np.float64) + +FLUX_PH_S = np.asarray([ + 9.6319e+09, 1.2625e+10, 1.6152e+10, 2.0210e+10, 2.4794e+10, 2.9898e+10, + 3.5492e+10, 4.1577e+10, 4.8186e+10, 5.5296e+10, 6.2874e+10, 7.0892e+10, + 7.9292e+10, 8.8026e+10, 9.7061e+10, 1.0637e+11, 1.1587e+11, 1.2552e+11, + 1.3528e+11, 1.4509e+11, 1.5000e+11, 1.5959e+11, 1.6925e+11, 1.7890e+11, + 1.8852e+11, 1.9807e+11, 2.0754e+11, 2.1689e+11, 2.2610e+11, 2.3520e+11, + 2.4416e+11, 2.5294e+11, 2.6151e+11, 2.6986e+11, 2.7799e+11, 2.8587e+11, + 2.9352e+11, 3.0091e+11, 3.0810e+11, 3.1506e+11, 3.2177e+11, 3.2830e+11, + 3.3458e+11, 3.4061e+11, 3.4640e+11, 3.5196e+11, 3.5730e+11, 3.6243e+11, + 3.6743e+11, 3.7225e+11, 3.7690e+11, 3.8139e+11, 3.8574e+11, 3.8994e+11, + 3.9402e+11, 3.9798e+11, 4.0182e+11, 4.0554e+11, 4.0914e+11, 4.1265e+11, + 4.1598e+11, 4.1920e+11, 4.2220e+11, 4.2496e+11, 4.2743e+11, 4.2962e+11, + 4.3149e+11, 4.3304e+11, 4.3427e+11, 4.3518e+11, 4.3579e+11, 4.3613e+11, + 4.3620e+11, 4.3598e+11, 4.3551e+11, 4.3478e+11, 4.3381e+11, 4.3260e+11, + 4.3116e+11, 4.2949e+11, 4.2760e+11, 4.2549e+11, 4.2315e+11, 4.2058e+11, + 4.1780e+11, 4.1477e+11, 4.1150e+11, 4.0795e+11, 4.0413e+11, 4.0000e+11, + 3.9555e+11, 3.9075e+11, 3.8557e+11, 3.7995e+11, 3.7386e+11, 3.6722e+11, + 3.5995e+11, 3.5196e+11, 3.4312e+11, 3.3325e+11, 3.2213e+11, 3.0944e+11, + 2.9474e+11, 2.7742e+11, 2.5658e+11, 2.3096e+11, 1.9893e+11, 1.5947e+11, + 1.1576e+11, 7.7492e+10, 5.0923e+10, +], dtype=np.float64) +# fmt: on + class X06daBecMacros(BecMacros): def __init__(self) -> None: @@ -37,7 +77,11 @@ class X06daBecMacros(BecMacros): self.auto_exposure = auto_exposure def full_flux_ph_per_s(): - return 400_000_000_000 + current_energy_kev = get_current_energy() / 1000 + idx = (np.abs(FLUX_ENERGY_KEV - current_energy_kev)).argmin() + if idx < len(FLUX_PH_S): + return float(FLUX_PH_S[idx]) + return 0 self.full_flux_ph_per_s = full_flux_ph_per_s @@ -50,7 +94,7 @@ class X06daBecMacros(BecMacros): @staticmethod def bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True): ... @staticmethod - def get_current_energy(): ... + def get_current_energy() -> float: ... @staticmethod def mono_pitch_scan(plot=True): ... @staticmethod diff --git a/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py b/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py index fea4fe19..e3059480 100644 --- a/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py @@ -70,7 +70,7 @@ class X10SaBecMacros(BecMacros): @staticmethod def bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True): ... @staticmethod - def get_current_energy(): ... + def get_current_energy() -> float: ... @staticmethod def mono_pitch_scan(plot=True): ... @staticmethod