diff --git a/ess/lib_tw.py b/ess/lib_tw.py index 857b41414e65601afd4f08f906bcabf847783d6e..681ea38c7718dab89f9684a6ae07f113ea452758 100644 --- a/ess/lib_tw.py +++ b/ess/lib_tw.py @@ -95,6 +95,26 @@ class LATTICE: # Assign idx, idx_elem, s, freq, apt self.update_idx() + def get_correctors_idx(self,i): + ''' + Get correctors associated to corrector index i + ''' + import logging + + found=False + correctors=[] + for element in self.lst: + if found: + #WARNING I worry that there could be an inactive comment/element between the ADJUST and actual corrector + logging.debug("Found element {} for corrector family {}".format(element.typ,i)) + correctors.append(element) + found=False + if isinstance(element,COMM): + if element.typ in ['ADJUST','ADJUST_STEERER']: + if int(element.para[0])==i: # next element is the corrector + found=True + return correctors + def get_elem_idx(self,i): ''' Get a TraceWin index number