From f0a81fd5b9c84ef24f2b5878209b2ea052f3f21d Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sat, 30 Jan 2021 16:24:08 +0100 Subject: [PATCH] added warning if Ks are not all close to each other --- devices/undulator.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/devices/undulator.py b/devices/undulator.py index cc412bd..227cdc4 100644 --- a/devices/undulator.py +++ b/devices/undulator.py @@ -147,6 +147,15 @@ class Undulators(Adjustable): a = self.adjs[und_name_cal] k = a.get_current_value() energy = self.K_to_eV(k) + + all_ks = [a.get_current_value() for a in self.adjs.values()] + checks = np.isclose(all_ks, k, rtol=0, atol=0.001) + if not all(checks): + print("Warning: Ks are not all close:") + for name, k, chk in zip(self.adjs.keys(), all_ks, checks): + if not chk: + print(name, k) + return float(energy) * 1000 # keV -> eV