update gui and triggering: speed sync works!
This commit is contained in:
@@ -148,21 +148,22 @@ class MAMainFrame(wx.Frame):
|
||||
l=rec[idx:idx+rng,(3,2)]-pts[i,:]
|
||||
l2=l[:,0]**2+l[:,1]**2
|
||||
ofs=l2.argmin()
|
||||
print(l2[ofs])
|
||||
#print(l2[ofs])
|
||||
idx+=ofs
|
||||
idxInPos.append(idx)
|
||||
idx+=rng/2
|
||||
|
||||
doc.idxInPos=idxInPos=np.array(idxInPos)
|
||||
#jitter=idxInPos-idxTrigger[:idxInPos.shape[0]]
|
||||
|
||||
self.SetStatusText('scaling of DesTimeBase: %f'%(float(idxInPos[-1])/idxTrigger[idxInPos.shape[0]-1]))
|
||||
#self.PlotJitter()
|
||||
|
||||
self.wxTimeCtrl.slider.SetRange(0,lenRec-1)
|
||||
|
||||
ts=fh['meta'].item()['timebase']
|
||||
page=idxInPos[1]-idxInPos[0]
|
||||
self.wxTimeCtrl.slider.SetPageSize(page)
|
||||
|
||||
self.wxTimeCtrl.slider.SetPageSize(idxInPos[1]-idxInPos[0])
|
||||
self.wxPosCtrl.slider.SetRange(0,lenPts-1)
|
||||
self.wxPosCtrl.slider.SetPageSize(10)
|
||||
self.wxTrigCtrl.slider.SetRange(0,idxTrigger.shape[0]-1)
|
||||
self.wxTrigCtrl.slider.SetPageSize(10)
|
||||
|
||||
def CloseFile(self):
|
||||
#http://docs.wxwidgets.org/2.8/wx_windowdeletionoverview.html#windowdeletionoverview
|
||||
@@ -173,6 +174,26 @@ class MAMainFrame(wx.Frame):
|
||||
except AttributeError as e:
|
||||
pass
|
||||
|
||||
def PlotJitter(self):
|
||||
doc=self.doc
|
||||
fh=doc.fh
|
||||
idxInPos=doc.idxInPos
|
||||
idxTrigger=doc.idxTrigger
|
||||
#display the jitter of inPos->trigger
|
||||
ts=fh['meta'].item()['timebase']
|
||||
jitter=idxTrigger[:idxInPos.shape[0]]-idxInPos
|
||||
import matplotlib.pyplot as plt # used for the colormaps
|
||||
plt.figure('jitter inPos -> trigger: scaling of DesTimeBase: %f'%(float(idxInPos[-1])/idxTrigger[idxInPos.shape[0]-1]))
|
||||
plt.plot(jitter*ts)
|
||||
plt.ylabel('jitter in ms')
|
||||
plt.ylabel('point idx')
|
||||
plt.show()
|
||||
|
||||
def DispJitter(self,idxInPos,idxTrigger):
|
||||
doc=self.doc
|
||||
ts=doc.fh['meta'].item()['timebase']
|
||||
self.SetStatusText("Jitter: %.2gms scaling: %.6g"%((idxTrigger-idxInPos)*ts,float(idxInPos)/idxTrigger))
|
||||
|
||||
def OnOpen(self, event):
|
||||
dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), '','numpy files (*.npz;*.npy)|*.npz;*.npy|all (*.*)|*.*', wx.OPEN|wx.FD_CHANGE_DIR)
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
@@ -287,40 +308,43 @@ rec
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def OnSetTime(usrData, value, msg):
|
||||
def OnSetTime(usrData, idxRec, msg):
|
||||
'called when the time slider has been changed'
|
||||
#print('OnSetTime', usrData, value, msg)
|
||||
view=usrData.slider.Parent
|
||||
doc=view.doc
|
||||
idx=np.argmin(abs(doc.idxInPos-value))
|
||||
view.wxPosCtrl.SetValue(idx)
|
||||
idx=np.argmin(abs(doc.idxTrigger-value))
|
||||
view.wxTrigCtrl.SetValue(idx)
|
||||
doc.Update(view,0,value)
|
||||
idxInPos=np.argmin(abs(doc.idxInPos-idxRec))
|
||||
view.wxPosCtrl.SetValue(idxInPos)
|
||||
idxTrigger=np.argmin(abs(doc.idxTrigger-idxRec))
|
||||
view.wxTrigCtrl.SetValue(idxTrigger)
|
||||
view.DispJitter(doc.idxInPos[idxInPos],doc.idxTrigger[idxTrigger])
|
||||
doc.Update(view,0,idxRec)
|
||||
|
||||
@staticmethod
|
||||
def OnSetIdxInPos(usrData, value, msg):
|
||||
def OnSetIdxInPos(usrData, idxInPos, msg):
|
||||
'called when the idxInPos slider has been changed'
|
||||
#print('OnSetPosIdx', usrData, value, msg)
|
||||
view = usrData.slider.Parent
|
||||
doc = view.doc
|
||||
value=doc.idxInPos[value]
|
||||
view.wxTimeCtrl.SetValue(value)
|
||||
idx=np.argmin(abs(doc.idxTrigger-value))
|
||||
view.wxTrigCtrl.SetValue(idx)
|
||||
doc.Update(view, 0, value)
|
||||
idxRec=doc.idxInPos[idxInPos]
|
||||
view.wxTimeCtrl.SetValue(idxRec)
|
||||
idxTrigger=np.argmin(abs(doc.idxTrigger-idxRec))
|
||||
view.wxTrigCtrl.SetValue(idxTrigger)
|
||||
view.DispJitter(doc.idxInPos[idxInPos],doc.idxTrigger[idxTrigger])
|
||||
doc.Update(view, 0, idxRec)
|
||||
|
||||
@staticmethod
|
||||
def OnSetIdxTrigger(usrData, value, msg):
|
||||
def OnSetIdxTrigger(usrData, idxTrigger, msg):
|
||||
'called when the idxTrigger slider has been changed'
|
||||
#print('OnSetIdxTrigger', usrData, value, msg)
|
||||
view = usrData.slider.Parent
|
||||
doc = view.doc
|
||||
value=doc.idxTrigger[value]
|
||||
view.wxTimeCtrl.SetValue(value)
|
||||
idx=np.argmin(abs(doc.idxInPos-value))
|
||||
view.wxPosCtrl.SetValue(idx)
|
||||
doc.Update(view, 0, value)
|
||||
idxRec=doc.idxTrigger[idxTrigger]
|
||||
view.wxTimeCtrl.SetValue(idxRec)
|
||||
idxInPos=np.argmin(abs(doc.idxInPos-idxRec))
|
||||
view.wxPosCtrl.SetValue(idxInPos)
|
||||
view.DispJitter(doc.idxInPos[idxInPos],doc.idxTrigger[idxTrigger])
|
||||
doc.Update(view, 0, idxRec)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user