From a6869885905cd4e5d9d0ba27b28b6b7bb5d1b7d3 Mon Sep 17 00:00:00 2001
From: Yngve Levinsen <yngve.levinsen@ess.eu>
Date: Tue, 11 Feb 2020 14:37:16 +0100
Subject: [PATCH] allow to not provide field map files fix minor issue in
 DTL_CEL class

---
 ess/lib_tw_elem.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ess/lib_tw_elem.py b/ess/lib_tw_elem.py
index 26b10b0..f571375 100644
--- a/ess/lib_tw_elem.py
+++ b/ess/lib_tw_elem.py
@@ -92,7 +92,6 @@
 # ---- Libs
 
 import numpy
-import sys
 
 # ---- Constants
 
@@ -245,14 +244,17 @@ class FIELD_MAP(ELEM):
         self.flag_apt = str(para[7])
 
         # Option instances
-        self.data = dic_fmap[self.name_fmap]
+        self.data = None
+        if self.name_fmap in dic_fmap:
+            self.data = dic_fmap[self.name_fmap]
 
     def update_gamma(self):
 
         # Temp error message for field map types
         if self.typ_fmap != "100":
-            print("Gamma calc only supported for 1D, exiting ...")
-            sys.exit()
+            raise TypeError("Gamma calc only supported for 1D, exiting ...")
+        if self.data is None:
+            raise AttributeError("A field map file is needed to update gamma calculation")
 
         # Update gamma (simple ver, closer to TW)
         dL = self.data.dL
@@ -696,7 +698,7 @@ class DTL_CEL(ELEM):
         self.E0T0L = float(para[6]) * 1e-6  # V => MV
         self.phs_rf = float(para[7]) * numpy.pi / 180.0  # deg => rad
         self.apt = float(para[8])
-        self.phs_rf_typ = int(para[9])
+        self.phs_rf_typ = int(float(para[9]))
 
         # TW option instances
         try:
-- 
GitLab