Skip to content

New bba method - #343

Merged
JeanLucPons merged 11 commits into
mainfrom
new-bba-method
Aug 5, 2026
Merged

New bba method#343
JeanLucPons merged 11 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.

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([200e-6,-150e-6])

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

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

outputs:

05 Aug 2026, 10:09:38 | DEBUG | Live tune: [0.18828126 0.29998199]
05 Aug 2026, 10:09:38 | DEBUG | Model tune: [0.15999673 0.33999769]
05 Aug 2026, 10:09:38 | DEBUG | Model tune: [0.1882723  0.30000498]
05 Aug 2026, 10:09:39 | DEBUG | Initial H corrector SF2E-C02-H value: -1.148263442271475e-06 rad
05 Aug 2026, 10:09:39 | DEBUG | Initial V corrector SD1A-C26-V value: 4.806631781109404e-07 rad
05 Aug 2026, 10:09:39 | DEBUG | Initial quad QF6B-C04 value: 1.7791567842073646 m-1
05 Aug 2026, 10:09:39 | DEBUG | Moving in the negative direction: 0,0 -> -1e-05,-1e-05
step 0 H bpmpos = 267.136 um
step 0 V bpmpos = -55.227 um
05 Aug 2026, 10:09:53 | DEBUG | Moving in the positive direction: -1e-05,-1e-05 -> 1e-05,1e-05
step 1 H bpmpos = 183.985 um
step 1 V bpmpos = -125.827 um
05 Aug 2026, 10:10:05 | DEBUG | Moving to the best guess: 1e-05,1e-05 -> 5.133722417791682e-06,1.54955301198363e-05
step 2 H bpmpos = 204.682 um
step 2 V bpmpos = -144.845 um
05 Aug 2026, 10:10:17 | DEBUG | Moving in the negative direction: 5.133722417791682e-06,1.54955301198363e-05 -> -4.866277582208319e-06,5.495530119836299e-06
step 3 H bpmpos = 246.572 um
step 3 V bpmpos = -109.680 um
05 Aug 2026, 10:10:29 | DEBUG | Moving in the positive direction: -4.866277582208319e-06,5.495530119836299e-06 -> 1.5133722417791684e-05,2.54955301198363e-05
step 4 H bpmpos = 162.140 um
step 4 V bpmpos = -179.759 um
05 Aug 2026, 10:10:41 | DEBUG | Moving to the best guess: 1.5133722417791684e-05,2.54955301198363e-05 -> 5.25937164894216e-06,1.6099071601694425e-05
step 5 H bpmpos = 204.154 um
step 5 V bpmpos = -146.950 um
05 Aug 2026, 10:10:53 | DEBUG | Moving to the optimum: 5.296833925808419e-06,1.6022345818579813e-05
HOffset: 203.995 um 6.339051095924152e-08
VOffset: -146.684 um 7.109888338174723e-08

@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.

@kparasch

kparasch commented Aug 4, 2026

Copy link
Copy Markdown
Member

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

I would for sure like to have this also in pySC! Unfortunately I have very little time these days, but I will try to find some and port it.

@JeanLucPons
JeanLucPons marked this pull request as ready for review August 5, 2026 14:02
@JeanLucPons
JeanLucPons merged commit 82e2c6b into main Aug 5, 2026
3 of 4 checks passed
@JeanLucPons
JeanLucPons deleted the new-bba-method branch August 5, 2026 14:04
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