From f240073a58ffbd497f37dcdde4d53290ba759873 Mon Sep 17 00:00:00 2001
From: Gamelin Alexis <gamelin@synchrotron-soleil.fr>
Date: Tue, 29 Sep 2020 11:34:51 +0200
Subject: [PATCH] Fix WakePotential

Remove mean of tau array during wake function interpolation to avoid wrong interpolation if tau is not centered on zero
---
 tracking/wakepotential.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tracking/wakepotential.py b/tracking/wakepotential.py
index 02dee03..9ecc677 100644
--- a/tracking/wakepotential.py
+++ b/tracking/wakepotential.py
@@ -162,7 +162,7 @@ class WakePotential(Element):
         W0 = getattr(self.wakefield, wake_type).data["real"]
         interp_func_W0 = interp1d(tau0, W0, fill_value=0, 
                                      bounds_error=False)
-        W = interp_func_W0(self.tau)
+        W = interp_func_W0(self.tau - np.mean(self.tau))
         if wake_type == "Wlong" or wake_type == "Wxquad" or wake_type == "Wyquad":
             Wp = signal.convolve(self.rho, W*-1, mode='same')*self.dtau
         elif wake_type == "Wxdip":
-- 
GitLab