Allow update of quads defined in the matching script.
This commit is contained in:
@@ -15,6 +15,7 @@ class MatchMaker:
|
||||
self.scriptdir = None
|
||||
self.signal=signal
|
||||
self.matchresult=[]
|
||||
self.filter={}
|
||||
|
||||
def initScripts(self,target):
|
||||
self.scriptdir = self.matchlist[target]
|
||||
@@ -31,6 +32,11 @@ class MatchMaker:
|
||||
file = self.scriptdir+'/initTwiss.madx'
|
||||
self.referencePoints.clear()
|
||||
self.variables.clear()
|
||||
self.filter.clear()
|
||||
# default values
|
||||
self.filter['injector']='s[i1].*k[12]|s20cb.*k1|s20sy01.*k1'
|
||||
self.filter['athos']='sat.*mqua.*k1|sat.*msex.*k2|s20sy02.*m[kq]'
|
||||
self.filter['aramis'] = 's[3a][0r].*k[12]|s20sy03.*k1'
|
||||
with open(file,'r') as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
@@ -52,6 +58,12 @@ class MatchMaker:
|
||||
val = float(flds[1].split(';')[0].strip())
|
||||
self.variables[name] = {'Value':val,'Description':description}
|
||||
print('Found Variable',name,'with value',val)
|
||||
if 'filter:' in line:
|
||||
tag = line.split('filter:')
|
||||
location = tag[1].strip()
|
||||
filterexo = tag[0].split('=')[1].split(';')[0].replace("'","").strip()
|
||||
self.filter[location.lower()]=filterexo
|
||||
print('Found Filter', filterexo, 'for location', location)
|
||||
print('##### Reference Twiss values parsed')
|
||||
|
||||
|
||||
@@ -77,13 +89,13 @@ class MatchMaker:
|
||||
if Injector:
|
||||
print('Matching Injector ...')
|
||||
madx.madx.call('matchInjector.madx')
|
||||
self.updateOnlineModel(om,madx.madx, 's[i1].*k[12]|s20cb.*k1|s20sy01.*k1')
|
||||
self.updateOnlineModel(om,madx.madx, self.filter['injector'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'),'Injector')
|
||||
if Athos:
|
||||
f.truncate(0)
|
||||
print('Matching Athos ...')
|
||||
madx.madx.call('matchAthos.madx')
|
||||
self.updateOnlineModel(om, madx.madx, 'sat.*mqua.*k1|sat.*msex.*k2|s20sy02.*m[kq]')
|
||||
self.updateOnlineModel(om, madx.madx, self.filter['athos'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Athos')
|
||||
if Aramis:
|
||||
f.truncate(0)
|
||||
@@ -95,7 +107,7 @@ class MatchMaker:
|
||||
madx.commonHeader('SwissFEL', '#s/#e', None) # sets header
|
||||
madx.madx.call('initTwiss.madx')
|
||||
madx.madx.call('matchAramis.madx')
|
||||
self.updateOnlineModel(om, madx.madx, 's[3a][0r].*k[12]|s20sy03.*k1')
|
||||
self.updateOnlineModel(om, madx.madx, self.filter['aramis'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Aramis')
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user