Initial test of matching

This commit is contained in:
2025-05-15 17:49:45 +02:00
parent f67d4ec349
commit c50448113a
8 changed files with 247 additions and 476 deletions

View File

@@ -41,6 +41,9 @@ class ReferenceManager:
for i,ele in enumerate(self.settings['Order']):
self.parent.UIMatchOrder.addItem(ele['MatchID'])
self.parent.UIMatchOrder.item(i).setBackground(CBeige)
if self.parent.UIMatchOrder.count() > 0:
self.parent.UIMatchOrder.setCurrentRow(0)
self.displayMatchingPoint()
def loadReference(self, filename):
with open(filename) as f:
@@ -84,9 +87,18 @@ class ReferenceManager:
con = {key:{'Val':par['Twiss'][key],'Condition':0} for key in par['Twiss'].keys()}
target[loc]=con
ncon += len(con.keys())
elif 'Script' in tar.keys():
loc = tar['Script']['Location']
file = tar['Script']['Script']
target[loc] = {'File':file} # all condition are in the script
ncon += 100
elif 'Fixed' in tar.keys():
loc=tar['Fixed']['Location']
con = {key: {'Val': tar['Fixed']['Twiss'][key], 'Condition': 0} for key in tar['Fixed']['Twiss'].keys()}
if 'Limit' in tar['Fixed'].keys():
condi = tar['Fixed']['Limit']
else:
condi = 0
con = {key: {'Val': tar['Fixed']['Twiss'][key], 'Condition': condi} for key in tar['Fixed']['Twiss'].keys()}
target[loc]=con
ncon += len(con.keys())
elif 'Save' in tar.keys():
@@ -121,6 +133,11 @@ class ReferenceManager:
else:
color = CRed
self.parent.UIMatchOrder.item(idx).setBackground(color)
if val<1:
idx = self.parent.UIMatchOrder.currentRow()+1
if idx < self.parent.UIMatchOrder.count():
self.parent.UIMatchOrder.setCurrentRow(idx)
self.displayMatchingPoint()
def getDependence(self,ele):
@@ -153,10 +170,14 @@ class ReferenceManager:
info = order['Target'][key0]
for key in info.keys():
self.parent.UIMatchTargets.insertRow(irow)
self.parent.UIMatchTargets.setItem(irow, 0, QtWidgets.QTableWidgetItem(key0))
val = '%7.3f' % info[key]['Val']
txt = key + sym[info[key]['Condition']] + val.strip()
self.parent.UIMatchTargets.setItem(irow, 1, QtWidgets.QTableWidgetItem(txt))
if key == 'File':
self.parent.UIMatchTargets.setItem(irow, 0, QtWidgets.QTableWidgetItem('Script'))
self.parent.UIMatchTargets.setItem(irow, 1, QtWidgets.QTableWidgetItem(info['File']))
else:
self.parent.UIMatchTargets.setItem(irow, 0, QtWidgets.QTableWidgetItem(key0))
val = '%7.3f' % info[key]['Val']
txt = key + sym[info[key]['Condition']] + val.strip()
self.parent.UIMatchTargets.setItem(irow, 1, QtWidgets.QTableWidgetItem(txt))
irow+=1
if irow == 0:
self.parent.UIMatchTargets.insertRow(irow)