avoid blocking with matplotlib, parameter save stuff

This commit is contained in:
2022-09-09 10:05:44 +02:00
parent 0a15899ee6
commit f70421d2f3
3 changed files with 101 additions and 68 deletions

View File

@@ -47,6 +47,9 @@ import sys, os, time
import json, re
import random, signal,threading
import matplotlib as mpl
mpl.use('Qt5Agg') # needed to avoid blocking of ui !
#import Wigis #ZAC: orig. code
#import jungfrau_widget #ZAC: orig. code
#import bernina_pulse_picker #ZAC: orig. code
@@ -1413,19 +1416,18 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
_log.warning(f'no scan parameters for object->skipped:{go}')
continue
p=param['points']
trf=np.asmatrix(param['trf']*1000) #fix shear/rotation um->um
trf=np.asmatrix(param['trf']*1000) #fix shear/rotation mm->um
pos=np.array(param['grid']['pos']) #in um
pitch=np.array(param['grid']['pitch']) #in um
#t=np.matrix((0,0,1)).T
#for i in range(p.shape[0]):
# t.A[:2,0]=pos+p[i,:]*pitch
# p[i,:]=(trf*t).A.ravel()
# Same but much faster !
m=np.hstack((p*pitch+pos,np.ones((p.shape[0],1))))
#p=(trf*np.asmatrix(m).T).T.A
p=(np.asmatrix(m)*trf).A
param['points']=p
# add up to 100 test fiducial
vb=self.vb
@@ -1564,19 +1566,19 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
self._testCode=tc={'idx':0}
step=tc['idx']
def testMatplotlib():
import matplotlib.pyplot as plt
x=np.linspace(0.1, 2*np.pi, 41)
y=np.exp(np.sin(x))
plt.stem(x, y)
plt.show(block=False)
step=1
if step==0:
vb=self.vb
vb.autoRange(items=(self._goImg,))
elif step==1:
import matplotlib.pyplot as plt
import numpy as np
x=np.linspace(0.1, 2*np.pi, 41)
y=np.exp(np.sin(x))
plt.stem(x, y)
plt.show()
testMatplotlib()
if step==3:
grp=pg.ItemGroup()
vb.addItem(grp)
@@ -1597,7 +1599,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
0, 0, 1)
grp.setTransform(tr)
print(vb.childGroup.childItems())
#print(vb.childGroup.childItems())
pass
def prepare_left_tabs(self):
@@ -2002,6 +2004,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
app._jungfrau=jf=detector.Jungfrau()
sp=dt._shapepath
sp.verbose=dt_misc['verbose']
sp.points=kwargs['points']
#sp.gen_grid_points(w=15, h=15, pitch=3, rnd=0, ofs=(0, +2000))
#sp.gen_grid_points(w=5, h=10, pitch=1, rnd=0, ofs=(0, 0));sp.sort_points(False, 10);sp.points