diff --git a/ess/lib_tw_elem.py b/ess/lib_tw_elem.py index 26b10b05c6651b04b2f1ecef34e45904090a64b5..f5713754448fd1638cdd6fd85c69418533bf5f14 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: