Skip to content

New bba method - #343

Draft
JeanLucPons wants to merge 4 commits into
mainfrom
new-bba-method
Draft

New bba method#343
JeanLucPons wants to merge 4 commits into
mainfrom
new-bba-method

Conversation

@JeanLucPons

@JeanLucPons JeanLucPons commented Jul 31, 2026

Copy link
Copy Markdown
Member

This PR adds a new BBA method (model dependent) that we use at ESRF.
Unfortunately it cannot be tested on design as the algorithm uses design so it needs a VA to be tested.

Example on ESRF VA:

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

def bba_callback(action: int, cdata):

    if action == Action.MEASURE:
        plane = cdata["plane"]
        step = cdata["step"]
        print(f"step {step} {plane} bpmpos = {cdata["bpm_pos"]*1e6:.3f} um")
    return True

logging.getLogger("pyaml.tuning_tools.bba2").setLevel(logging.DEBUG)

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

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

bba.measure(sleep_between_step=6,callback=bba_callback)

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

outputs:

31 Jul 2026, 16:31:12 | DEBUG | Initial H corrector value: -9.66335494367311e-41 rad
31 Jul 2026, 16:31:12 | DEBUG | Initial V corrector value: 3.631830979621812e-43 rad
31 Jul 2026, 16:31:12 | DEBUG | Initial quad value: 1.779156783615382 m-1
31 Jul 2026, 16:31:12 | DEBUG | Moving in the negative direction: 0,0 -> -1e-05,-1e-05
step 0 H bpmpos = 68.273 um
step 0 V bpmpos = 17.329 um
31 Jul 2026, 16:31:26 | DEBUG | Moving in the positive direction: -1e-05,-1e-05 -> 1e-05,1e-05
step 1 H bpmpos = -28.900 um
step 1 V bpmpos = -47.134 um
31 Jul 2026, 16:31:38 | DEBUG | Moving to the best guess: 1e-05,1e-05 -> -1.194652000820969e-07,2.0562047474807868e-07
step 2 H bpmpos = 20.575 um
step 2 V bpmpos = -15.663 um
Moving to the optimum: -8.008225249053031e-08,1.3728543395643385e-07
HOffset: 2.038413409167885e-05
VOffset: -1.5442473918032936e-05

@JeanLucPons
JeanLucPons marked this pull request as draft July 31, 2026 14:34
@gubaidulinvadim

Copy link
Copy Markdown
Contributor

@kparasch maybe you'd like to have this kind of method directly in pySC? Model-dependent BBA is sometimes the only option.

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.

2 participants