Indication of magnet strengths and matching results in GUI

This commit is contained in:
2026-01-20 15:12:12 +01:00
parent 906890da98
commit 60b9643568
9 changed files with 192 additions and 38 deletions

View File

@@ -2,9 +2,10 @@ import json
import copy
import numpy as np
from PyQt5 import QtWidgets,QtGui
from onlinemodel.core import Facility
from onlinemodel.madx import CMadX
#from sipbuild.generator.outputs.formatters import variable
converttwiss= {'betx':'betx','bety':'bety','alfx':'alfx','alfy':'alfy',
'etax':'dx','etay':'dy','etapx':'dpx','etapy':'dpy','mux':'mux','muy':'muy',
@@ -309,6 +310,7 @@ class Model:
########################################3
def checkMagnetLimit(self):
# using magnet calibration
self.parent.UIReportMagnetResult.clear()
self.updateEnergy(140.)
quad={}
quad['QFA'] = [0.15, 0.173, 150.0, 91.1, 0.0, 0.74521, -0.00813, -0.03542,
@@ -347,7 +349,16 @@ class Model:
if bg in k1brho.keys():
k1max=k1brho[bg]/brho
rat=np.abs(ele.k1/k1max)*100.
print('%s: %5.1f (percent)' % (ele.Name.replace('.','-'),rat))
label = '%s: %5.1f %%' % (ele.Name.replace('.','-'),rat)
print(label)
listitem = QtWidgets.QListWidgetItem(label)
color = QtGui.QColor(255,255,255) # white
if rat>95:
color = QtGui.QColor(255,255,0)
if rat>100:
color = QtGui.QColor(255,0,0)
listitem.setBackground(color)
self.parent.UIReportMagnetResult.addItem(listitem)
else:
print('%s: Unsupported type %s' % (ele.Name.replace('.','-'),bg))