From 5cc1a61466d9015445b13f00e14a552457a95f3c Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 6 Aug 2026 08:50:29 +0200 Subject: [PATCH 1/2] Minor fix for error propagation --- pyaml/tuning_tools/bba2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyaml/tuning_tools/bba2.py b/pyaml/tuning_tools/bba2.py index eca8c86a..afb8d5b9 100644 --- a/pyaml/tuning_tools/bba2.py +++ b/pyaml/tuning_tools/bba2.py @@ -99,12 +99,12 @@ def _x_intercept(x, k, n): xx = np.polynomial.polynomial.polyfit(x[-n:], k[-n:], 1) err = 0 if n > 2: - # Compute error on the ratio -xx[0] / xx[1] + # Compute error of the ratio r = -xx[0] / xx[1] X = np.polynomial.polynomial.polyvander(x[-n:], 1) R = k[-n:] - X @ xx S2 = np.sum(R**2) / float(n - 2) COV = S2 * np.linalg.inv(X.T @ X) - J = [1 / xx[1], -xx[0] / xx[1] ** 2] + J = [-1 / xx[1], xx[0] / xx[1] ** 2] # Jacobian [dr/d(xx[0]) , dr/d(xx[1])] err = np.sqrt(J @ COV @ J) # return x @y=0 From f175f8624ad4db8f6737d07bf5229198ee825f34 Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 6 Aug 2026 09:05:46 +0200 Subject: [PATCH 2/2] Fix for quad with zero strength (i.e. quadrupole corrector) that produces silent scan --- pyaml/tuning_tools/bba2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaml/tuning_tools/bba2.py b/pyaml/tuning_tools/bba2.py index afb8d5b9..88093967 100644 --- a/pyaml/tuning_tools/bba2.py +++ b/pyaml/tuning_tools/bba2.py @@ -346,7 +346,7 @@ def measure( # Initial values self._initial_k0 = [self._h_steer.strength.get(), self._v_steer.strength.get()] self._initial_k1 = self._quad.strength.get() - self._quad_polarity = np.sign(self._initial_k1) + self._quad_polarity = np.sign(self._initial_k1) if self._initial_k1 != 0 else 1 self._ref_ios, fx, fy = self._init_responses( self._cfg.tune_correction_name,