From 53592c05a329e25cb30bab0c9a717beb86b727f6 Mon Sep 17 00:00:00 2001 From: Thierry Zamofing Date: Fri, 23 Nov 2018 08:15:43 +0100 Subject: [PATCH] wip --- python/PBMotionAnalyzer/PBMotionAnalyzer.py | 10 ++++++---- python/shapepath.py | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/python/PBMotionAnalyzer/PBMotionAnalyzer.py b/python/PBMotionAnalyzer/PBMotionAnalyzer.py index 521c6a4..102c04c 100755 --- a/python/PBMotionAnalyzer/PBMotionAnalyzer.py +++ b/python/PBMotionAnalyzer/PBMotionAnalyzer.py @@ -147,15 +147,17 @@ class MAMainFrame(wx.Frame): for i in range(lenPts): l=rec[idx:idx+rng,(3,2)]-pts[i,:] l2=l[:,0]**2+l[:,1]**2 - ofs=l2.argmin() - #print(l2[ofs]) + try: + ofs=l2.argmin() + except ValueError: + break#print(l2[ofs]) idx+=ofs idxInPos.append(idx) idx+=rng/2 doc.idxInPos=idxInPos=np.array(idxInPos) - - self.SetStatusText('scaling of DesTimeBase: %f'%(float(idxInPos[-1])/idxTrigger[idxInPos.shape[0]-1])) + idx=min(idxInPos.shape[0],idxTrigger.shape[0])-1 + self.SetStatusText('scaling of DesTimeBase: %f'%(float(idxInPos[idx])/idxTrigger[idx])) #self.PlotJitter() self.wxTimeCtrl.slider.SetRange(0,lenRec-1) diff --git a/python/shapepath.py b/python/shapepath.py index 9b75b3c..9d30cf3 100755 --- a/python/shapepath.py +++ b/python/shapepath.py @@ -459,24 +459,24 @@ class ShapePath(MotionBase): for i in range(lenPts): l=rec[idx:idx+rng,(3,2)]-pts[i,:] l2=l[:,0]**2+l[:,1]**2 - ofs=l2.argmin() - #print(l2[ofs]) + try: + ofs=l2.argmin() + except ValueError as e: + break idx+=ofs idxInPos.append(idx) idx+= rng/2 idxInPos = np.array(idxInPos) - jitter=idxTrigger[:idxInPos.shape[0]]-idxInPos + num = min(idxInPos.shape[0], idxTrigger.shape[0]) + jitter=idxTrigger[:num]-idxInPos[:num] fig = plt.figure('trigger jitter') ax = fig.add_subplot(1, 1, 1) hl = [] hl += ax.plot(jitter*ts, 'b-',label='jitter') ax.xaxis.set_label_text('position idx') ax.yaxis.set_label_text('jitter motion (ms)') - print('scaling of DesTimeBase: %f'%(float(idxInPos[-1])/idxTrigger[idxInPos.shape[0]-1])) - - - + print('scaling of DesTimeBase: %f'%(float(idxInPos[num-1])/idxTrigger[num-1])) plt.show() def bode_plot(self,xy=(0,1),mode=25,db=True): @@ -639,9 +639,9 @@ if __name__=='__main__': #sp.setup_gather(acq_per=1) #Gather.MaxLines=116508 580pts sp.setup_gather(acq_per=2) #setup_sync(self, crdId=1, prgId=2, plcId=2, mode=0, **kwargs): - #sp.setup_sync() #no sync at all + sp.setup_sync() #no sync at all #sp.setup_sync(mode=1) #sync with timing system (PROG) - sp.setup_sync(mode=2) #sync with timing system and PLC to sync speed (PROG) + #sp.setup_sync(mode=2) #sync with timing system and PLC to sync speed (PROG) #sp.gen_grid_points(w=2,h=2,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1) #sp.gen_swissmx_points(width=1000,ofs=(-500,0));sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40,acq_per=1) @@ -651,7 +651,7 @@ if __name__=='__main__': #sp.gen_grid_points(w=2,h=20,pitch=50,rnd=0);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1) #sp.gen_rand_points(n=500, scale=1000);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1) #sp.gen_grid_points(w=30,h=30,pitch=50,rnd=0.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40) - sp.gen_rand_points(n=400, scale=1000);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=40) + sp.gen_rand_points(n=400, scale=1000);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10) #>>>setup gather and sync<<<