wip
This commit is contained in:
16
geometry.py
16
geometry.py
@@ -49,9 +49,21 @@ class VLSgrating:
|
||||
geo=(r1,r2,np.rad2deg(alpha), np.rad2deg(beta), np.rad2deg(gamma))
|
||||
return geo
|
||||
|
||||
def geometry2raw(self, meas, debug=False):
|
||||
def geometry2raw(self, geo):
|
||||
r1,r2,alpha,beta,gamma=geo
|
||||
|
||||
# returns raw motor positions
|
||||
pass
|
||||
mt=gtz=gty1=gty2=grx=gtx=dtz=dty1=dty2=drx=None
|
||||
aa=np.deg2rad(90-alpha)
|
||||
bb=np.deg2rad(90-beta)
|
||||
gg=np.deg2rad(90-beta)
|
||||
gtz=r1
|
||||
grx=90-alpha
|
||||
dtz=np.cos(aa+bb)*r2
|
||||
dty1=dty2=np.sin(aa+bb)*r2
|
||||
drx=gamma
|
||||
raw=(mt,gtz,gty1,gty2,grx,gtx,dtz,dty1,dty2,drx)
|
||||
return raw
|
||||
|
||||
# ---------- eugenio calculation functions ----------
|
||||
#def bring_to_focus(self, eV):
|
||||
|
||||
117
graphExample.py
117
graphExample.py
@@ -130,10 +130,10 @@ class RIXSgrating(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self._param={'ctr':(400,400), # location of vlsg
|
||||
self._param={'ctr':(500,500), # location of vlsg
|
||||
'r1':314,#distance probe grating
|
||||
'r2':447,#distance grating detector
|
||||
'aa':22, #grating angle
|
||||
'aa':18, #grating angle
|
||||
'cc':58, #detector angle
|
||||
'szG':(200,5), #size VLS grating
|
||||
'szD':(150,5), #size detector
|
||||
@@ -159,14 +159,14 @@ class RIXSgrating(QWidget):
|
||||
lv.addWidget(w)
|
||||
lg=QtGui.QGridLayout(w)
|
||||
|
||||
for i,t in enumerate(('Energy',)):
|
||||
w=QLabel(t)
|
||||
lg.addWidget(w, i,0)
|
||||
w=QtGui.QLineEdit(t,objectName=t)
|
||||
lg.addWidget(w, i,1)
|
||||
|
||||
w=QtGui.QPushButton('calc geometry')
|
||||
i+=1;lg.addWidget(w, i, 1)
|
||||
i=0;t='Energy'
|
||||
w=QLabel(t); lg.addWidget(w, i,0)
|
||||
w=QtGui.QLineEdit(t,objectName=t); lg.addWidget(w, i,1)
|
||||
i+=1;t='Grating'
|
||||
w=QLabel(t); lg.addWidget(w, i,0)
|
||||
w=QtGui.QComboBox(objectName=t); lg.addWidget(w, i,1)
|
||||
for i,t in enumerate(('80meV','grating 1','grating 2')):
|
||||
w.insertItem(i,t)
|
||||
|
||||
sld={}
|
||||
for key,rng,tk,pos in (('energy',(200,1500),50,60),):
|
||||
@@ -180,7 +180,7 @@ class RIXSgrating(QWidget):
|
||||
|
||||
|
||||
self._wdGrpGeometry=w=QtGui.QGroupBox("Geometry",self)
|
||||
w.move(250,10)
|
||||
w.move(10,160)
|
||||
#w.setFixedSize(200,42+32*4)
|
||||
l=QtGui.QGridLayout(w)
|
||||
lut={'aa':'\u03B1', 'bb':'\u03B2', 'cc':'\u03B3'}
|
||||
@@ -190,13 +190,38 @@ class RIXSgrating(QWidget):
|
||||
l.addWidget(w, i,0)
|
||||
w=QtGui.QLineEdit(tl,objectName=t)
|
||||
l.addWidget(w, i,1)
|
||||
w=QtGui.QPushButton('calc raw motors')
|
||||
|
||||
self._wdGrpRaw=w=QtGui.QGroupBox("Motors",self)
|
||||
w.move(250,10)
|
||||
#w.setFixedSize(200,42+32*4)
|
||||
l=QtGui.QGridLayout(w)
|
||||
|
||||
motors=(
|
||||
('MT', 'Mask translation'),
|
||||
('GTZ', 'Grating translation along Z-axis (along beam)'),
|
||||
('GTY1', 'Grating translation along Y-axis (height) Wedge leveller 1'),
|
||||
('GTY2', 'Grating translation along Y-axis (height) Wedge leveller 2'),
|
||||
('GRX', 'Grating rotation around X-axis'),
|
||||
('GTX', 'Grating translation along X-axis'),
|
||||
('DTZ', 'Detector Translation along Z-axis'),
|
||||
('DTY1', 'Detector Translation along Y-axis'),
|
||||
('DTY2', 'Detector Translation along Y-axis'),
|
||||
('DRX', 'Detector Rotation around X-axis (ɣ) '),
|
||||
)
|
||||
|
||||
for i,m in enumerate(motors):
|
||||
t,inf=m
|
||||
w=QLabel(t)
|
||||
l.addWidget(w, i,0)
|
||||
w=QtGui.QLineEdit(t,objectName=t)
|
||||
w.setToolTip(inf)
|
||||
l.addWidget(w, i,1)
|
||||
w=QtGui.QPushButton('move all motors')
|
||||
l.addWidget(w, i+1, 1)
|
||||
|
||||
|
||||
|
||||
w=QtGui.QGroupBox("Drawing",self)
|
||||
w.move(10,160)
|
||||
w.move(470,10)
|
||||
l=QtGui.QVBoxLayout(w)
|
||||
|
||||
sld={}
|
||||
@@ -211,33 +236,39 @@ class RIXSgrating(QWidget):
|
||||
|
||||
self.show()
|
||||
|
||||
def setEnergy(self,val):
|
||||
app=QApplication.instance()
|
||||
p=self._param
|
||||
wEnergy=self._wdGrpEnergy.findChild(QtGui.QLineEdit, 'Energy')
|
||||
wEnergy.setText(f'{val:.4g}')
|
||||
vlsg=app._vlsg
|
||||
p['geo']=geo=vlsg.energy2geometry(val)
|
||||
r1, r2, aa, bb, cc=geo
|
||||
p['r1']=r1/8
|
||||
p['r2']=r2/8
|
||||
p['aa']=(90-aa)*8
|
||||
p['bb']=(90-bb)*8
|
||||
p['cc']=(90-cc)
|
||||
|
||||
wGeo=self._wdGrpGeometry
|
||||
for i,k in enumerate(('R1','R2','aa','bb','cc',)):
|
||||
w=wGeo.findChild(QtGui.QLineEdit, k)
|
||||
w.setText(f'{geo[i]:.6g}')
|
||||
|
||||
raw=vlsg.geometry2raw(geo)
|
||||
wRaw=self._wdGrpRaw
|
||||
for i,k in enumerate(('MT','GTZ','GTY1','GTY2','GRX','GTX','DTZ','DTY1','DTY2','DRX',)):
|
||||
w=wRaw.findChild(QtGui.QLineEdit, k)
|
||||
if raw[i] is None:
|
||||
w.setText('(null)')
|
||||
else:
|
||||
w.setText(f'{raw[i]:.6g}')
|
||||
|
||||
def sldChanged(self,key,val,*args,**kwargs):
|
||||
print(key,val)
|
||||
p=self._param
|
||||
if key=='energy':
|
||||
app=QApplication.instance()
|
||||
wEnergy=self._wdGrpEnergy.findChild(QtGui.QLineEdit,'Energy')
|
||||
wGeo=self._wdGrpGeometry
|
||||
wR1=wGeo.findChild(QtGui.QLineEdit,'R1')
|
||||
wR2=wGeo.findChild(QtGui.QLineEdit,'R2')
|
||||
wAA=wGeo.findChild(QtGui.QLineEdit,'aa')
|
||||
wBB=wGeo.findChild(QtGui.QLineEdit,'bb')
|
||||
wCC=wGeo.findChild(QtGui.QLineEdit,'cc')
|
||||
|
||||
wEnergy.setText(f'{val:.4g}')
|
||||
vlsg=app._vlsg
|
||||
(r1,r2,aa,bb,cc)=p['geo']=vlsg.energy2geometry(val)
|
||||
wR1.setText(f'{r1:.6g}')
|
||||
wR2.setText(f'{r2:.6g}')
|
||||
wAA.setText(f'{aa:.6g}')
|
||||
wBB.setText(f'{bb:.6g}')
|
||||
wCC.setText(f'{cc:.6g}')
|
||||
|
||||
p['r1']=r1/8
|
||||
p['r2']=r2/8
|
||||
p['aa']=(90-aa)*5
|
||||
p['bb']=(90-bb)*5
|
||||
p['cc']=(90-cc)
|
||||
self.setEnergy(val)
|
||||
else:
|
||||
p[key]=val
|
||||
if 'geo' in p:
|
||||
@@ -348,6 +379,7 @@ class RIXSgrating(QWidget):
|
||||
(vr1, vr2, vaa, vbb, vcc)=p['geo']
|
||||
vaa=90-vaa
|
||||
vbb=90-vbb
|
||||
vcc=90-vcc
|
||||
except KeyError:
|
||||
vr1=r1; vr2=r2; vaa=aa; vbb=bb; vcc=cc
|
||||
|
||||
@@ -376,7 +408,7 @@ class RIXSgrating(QWidget):
|
||||
s1=s*np.cos(aa*np.pi/180); s2=s*np.sin(aa*np.pi/180)
|
||||
qp.drawArc(int(p2.x())-s, int(p2.y())-s, 2*s, 2*s, int(aa*16), int(bb*16))
|
||||
|
||||
qp.drawArc(int(p6.x())-s, int(p6.y())-s, 2*s, 2*s, int(180+aa+bb*16), int(cc*16))
|
||||
qp.drawArc(int(p6.x())-s, int(p6.y())-s, 2*s, 2*s, int((aa+bb)*16), int(cc*16))
|
||||
p10=QtCore.QPointF(*tf2.map(r2+20, 0)) #text pos
|
||||
|
||||
qp.setPen(penTxt)
|
||||
@@ -385,9 +417,12 @@ class RIXSgrating(QWidget):
|
||||
qp.translate(p8); qp.rotate(-aa-bb)
|
||||
qp.drawText(-40,-10,f'R2={vr2:.5g}mm')
|
||||
qp.setTransform(QtGui.QTransform())
|
||||
qp.drawText(p2+QtCore.QPointF(-s1,s2+20),f'aa={vaa:.5g}°')
|
||||
qp.drawText(p2+QtCore.QPointF(s1,-s2+20),f'bb={vbb:.5g}°')
|
||||
qp.drawText(p10,f'cc={vcc:.5g}°')
|
||||
qp.translate(p2); qp.rotate(-aa)
|
||||
qp.drawText(20-int(szG[0]/2),20,f'aa={vaa:.5g}°')
|
||||
qp.drawText(20,20,f'bb={vbb:.5g}°')
|
||||
qp.setTransform(QtGui.QTransform())
|
||||
qp.translate(p10); qp.rotate(-aa-bb)
|
||||
qp.drawText(0,20,f'cc={vcc:.5g}°')
|
||||
|
||||
#for i,p in enumerate((p0,p1,p2,p3,p4,p5,p6,p7,p8,p9)):
|
||||
# qp.drawText(p,f'P{i}')
|
||||
|
||||
Reference in New Issue
Block a user