Skip to content

Update bba callback - #342

Merged
JeanLucPons merged 2 commits into
mainfrom
update-bba-callback
Jul 30, 2026
Merged

Update bba callback#342
JeanLucPons merged 2 commits into
mainfrom
update-bba-callback

Conversation

@JeanLucPons

Copy link
Copy Markdown
Member

This PR improve BBA callback using new pySC (1.5.3).

Example:

from pyaml.accelerator import Accelerator
from pyaml.common.constants import Action
import numpy as np

ios_x = {"H":[],"V":[]}
ios_y = {"H":[],"V":[]}

def bba_callback(action: int, cdata):

    # Action.MEASURE is triggered at each new IOS measurement
    if action == Action.MEASURE:
        plane = cdata["plane"]
        step = cdata["step"]
        ios_x[plane].append(cdata["bpm_pos"])
        ios_y[plane].append(cdata["ios"])
        if len(ios_x[plane])>=2:
            # Get slopes
            fit = np.polynomial.polynomial.polyfit(ios_x[plane], ios_y[plane], 1)
            # Extract small slopes
            std = np.std(fit[1])
            cfit = fit[:,np.where(np.fabs(fit[1])>=std)[0]]
            # Get average intersection point (-> offset)
            x = np.mean(-cfit[0] / cfit[1])
            print(f"step={step} plane={cdata["plane"]} pos={cdata["bpm_pos"]*1e6:7.3f} um offset={x*1e6:.3f} um")
    return True

sr = Accelerator.load("tests/config/EBSOrbit.yaml")
SR = sr.design
bba = SR.get_bba("BBA-BPM_C04-04")

# Add a misalignement
SR.get_bpm("BPM_C04-04").offset.set([20e-6,-15e-6])

bba.measure(callback=bba_callback)

print(f"HOffset: {bba.h_offset()}")
print(f"VOffset: {bba.v_offset()}")

outputs:

step=1 plane=H pos= 52.151 um offset=19.750 um
step=2 plane=H pos= 36.095 um offset=19.864 um
step=3 plane=H pos= 19.995 um offset=19.959 um
step=4 plane=H pos=  3.854 um offset=20.036 um
step=5 plane=H pos=-12.324 um offset=20.097 um
step=6 plane=H pos=-28.534 um offset=20.141 um
step=1 plane=V pos=  6.527 um offset=-15.002 um
step=2 plane=V pos= -4.236 um offset=-15.001 um
step=3 plane=V pos=-15.000 um offset=-15.000 um
step=4 plane=V pos=-25.764 um offset=-15.000 um
step=5 plane=V pos=-36.527 um offset=-15.000 um
step=6 plane=V pos=-47.290 um offset=-15.000 um
HOffset: 2.0149059939587564e-05
VOffset: -1.5000000000143988e-05

@JeanLucPons

Copy link
Copy Markdown
Member Author

@gupichon-soleil why dtaacc is failing now ?

@gubaidulinvadim

gubaidulinvadim commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@gupichon-soleil why dtaacc is failing now ?

@JeanLucPons Guillaume is on vacation now. It's a bit strange if it fails. Normally, everything was tested before he went on vacation. @patrickmadela could you maybe check the reason of failure?
@JeanLucPons is your branch based on the latest pipeline version? #306 It looks like the path to apptainer image is different now

@kparasch
kparasch self-requested a review July 30, 2026 08:58
@JeanLucPons

Copy link
Copy Markdown
Member Author

@gubaidulinvadim
My branch is based on main with 2 more commits.
No change in workflows.

[ubuntu20acu.pons] > git log
commit d6ea9a6ab8fb8f9541981a9a27c5771c7fc2668e (HEAD -> update-bba-callback, origin/update-bba-callback)
Author: PONS <pons@esrf.fr>
Date:   Thu Jul 30 10:06:41 2026 +0200

    Updated pySC release number

commit 8afb54277a1a0b240eac22524320a761d8dbab8d
Author: PONS <pons@esrf.fr>
Date:   Wed Jul 29 09:43:20 2026 +0200

    Update bba callback

commit ac22eaf8a75a1d3dc7cfcc22678f0359b8b72afc (origin/main, origin/HEAD, main)
Merge: ed3f6b52 4e08e56f
Author: Jean-Luc PONS <pons@esrf.fr>
Date:   Fri Jul 24 15:09:18 2026 +0200

    Merge pull request #279 from python-accelerator-middle-layer/schema-registry-rf
    
    Adding schema registry, validator and generator for RF

@kparasch kparasch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be tempted to just merge since the changes are very small and the test that is failing does so for reasons irrelevant to this PR.

@JeanLucPons
JeanLucPons merged commit d9f4d9c into main Jul 30, 2026
3 of 4 checks passed
@JeanLucPons
JeanLucPons deleted the update-bba-callback branch July 30, 2026 09:29
@patrickmadela

Copy link
Copy Markdown

@gupichon-soleil why dtaacc is failing now ?

@JeanLucPons Guillaume is on vacation now. It's a bit strange if it fails. Normally, everything was tested before he went on vacation. @patrickmadela could you maybe check the reason of failure? @JeanLucPons is your branch based on the latest pipeline version? #306 It looks like the path to apptainer image is different now

I checked the logs, but the error doesn't look familiar to me. It is probably related to the changes and improvements @gupichon-soleil made, but it will take some time to determine the root cause for me.

@gubaidulinvadim

gubaidulinvadim commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

I would still suspect this commit 07f529d that is in Guillaume #306 but not in the main. But if there's no easy solution, I think it's best to wait for his return.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants