From 92a88d846306a042df754bc59a247db7d4d45568 Mon Sep 17 00:00:00 2001 From: Thierry Zamofing Date: Thu, 24 Jan 2019 10:59:36 +0000 Subject: [PATCH] part2 --- python/MXMotion.py | 118 ++++++++++++++------- python/shapepath.py | 247 +++++++++++++++++--------------------------- 2 files changed, 175 insertions(+), 190 deletions(-) diff --git a/python/MXMotion.py b/python/MXMotion.py index e8ef979..89a3e68 100644 --- a/python/MXMotion.py +++ b/python/MXMotion.py @@ -23,7 +23,7 @@ Gather.Enable : 1: after .setup_gather() called Gather.Samples : number af gathered data samples ''' -import os, sys +import os,sys,time sys.path.insert(0,os.path.expanduser('~/Documents/prj/SwissFEL/PBTools/')) #import pbtools.misc.pp_comm as pp_comm -> pp_comm.PPComm from pbtools.misc.pp_comm import PPComm @@ -31,86 +31,114 @@ from pbtools.misc.gather import Gather class MotionBase: - def __init__(self, comm, gather, verbose): + def __init__(self, comm, gather, verbose,**kwargs): self.comm=comm self.gather=gather self.verbose=verbose + #ServoPeriod=0.2 #ms, Sys.ServoPeriod is dependent of !common() macro + ServoPeriod=comm.gpascii.servo_period*1000 - def setup_sync(self, crdId=1, prgId=2, plcId=2, encId=8, mode=0, **kwargs): + self.meta={'srv_per':ServoPeriod,'pt2pt_time':40,'sync_flag':0,'sync_mode':2} + self.meta.update(kwargs) + + def setup_sync(self, crdId=1, prgId=2,verbose=False): '''setup the timing synchronization for the motion program - mode=0 : no sync at all - mode=1 : synchronize start - mode=2 : synchronize start and adapt motion speed - this function generates the code blocks: - self.sync_wait and self.sync_run - sync_wait can be put in the program to force a timing sync - sync_run are the commands to run the whole program - flag=0 : real start and frame trigger - flag=1 : simulated start and real frame trigger - flag=2 : real start and simulated frame trigger - flag=3 : simulated start and frame trigger + kwargs: + sync_mode : default=2 + 0 : no sync at all + 1 : synchronize start + 2 : synchronize start and adapt motion speed + this function generates the code blocks: + self.sync_wait and self.sync_run + sync_wait can be put in the program to force a timing sync + sync_run are the commands to run the whole program + + sync_flag : default=0 + bit 0=1 : simulated start trigger + bit 1=2 : simulated frame trigger + 0 : real start and frame trigger + 1 : simulated start and real frame trigger + 2 : real start and simulated frame trigger + 3 : simulated start and frame trigger pt2pt_time : time point to point (needed sor sync code) ''' - if mode==0: + sync_mode=self.meta['sync_mode'] + sync_flag=self.meta['sync_flag'] + pt2pt_time=self.meta['pt2pt_time'] + + print({0:'no sync at all',1:'sync at start only',2:'sync on each shot'}[sync_mode]) + if sync_mode!=0: + print({0: 'real start trigger', 1: 'simulated start trigger'}[sync_flag&1]) + print({0: 'real frame trigger', 2: 'simulated frame trigger'}[sync_flag&2]) + if sync_mode==0: try: del self.sync_prg except AttributeError: pass self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId) - elif mode in(1,2): + elif sync_mode in(1,2): #frequence jitter 50Hz Swissgrid: #https://www.swissgrid.ch/de/home/operation/grid-data/current-data.html# - flag=kwargs.get('flag',0); - pt2pt_time=kwargs.get('pt2pt_time',40); - flag0='Coord[1].Q[10]' if flag&1 else 'Gate3[1].Chan[0].UserFlag' - flag1='Coord[1].Q[11]' if flag&2 else 'Gate3[1].Chan[1].UserFlag' - if mode==1: + flag0='Coord[1].Q[10]' if sync_flag&1 else 'Gate3[1].Chan[0].UserFlag' + flag1='Coord[1].Q[11]' if sync_flag&2 else 'Gate3[1].Chan[1].UserFlag' + if sync_mode==1: prg = ''' Coord[1].Q[1]=-2 - Coord[1].TimeBaseSlew=1 //1E-4 is default + Coord[1].TimeBaseSlew=1 //1E-4 is default Coord[1].DesTimeBase=0 while({flag0}==0){{}} Coord[1].Q[1]=-1 Gather.Enable=2 while({flag1}==0){{}} Coord[1].DesTimeBase=Sys.ServoPeriod - '''.format(plcId=plcId, crdId=crdId, flag0=flag0, flag1=flag1) + '''.format(crdId=crdId, flag0=flag0, flag1=flag1) else: prg = ''' //Gather.Enable=2 is done in the sync program Coord[1].TimeBaseSlew=1 //1E-4 is default Coord[1].DesTimeBase=0 Coord[1].Q[1]=-1 - '''.format(plcId=plcId, crdId=crdId, flag0=flag0, flag1=flag1) + '''.format(crdId=crdId, flag0=flag0, flag1=flag1) self.sync_prg = prg - self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, plcId=plcId, crdId=crdId) + self.sync_run = '&{crdId}b{prgId}r'''.format(prgId=prgId, crdId=crdId) #download and start triggerSync code comm=self.comm - trigMode=0; - if mode==2:trigMode+=1 #synchronize - trigMode+=flag*2 #simulated or real triggers - trigMode+=8 # verbose - if mode==2 or trigMode&4: + arg=0 #argument to pass to triggerSync program + if sync_mode==2:arg+=1 #synchronize + arg+=sync_flag*2 #simulated or real triggers + if verbose: arg+=8 + if sync_mode==2 or arg&4: sftp = comm.sftp dst = '/tmp/triggerSync' src = os.path.abspath(os.path.join(os.path.dirname(__file__), '../src/triggerSync/triggerSync')) sftp.put(src, dst) sftp.chmod(dst, 0o755) cmd = 'LD_LIBRARY_PATH=/opt/ppmac/libppmac/ ' + dst - cmd+=' %g %d'%(pt2pt_time,trigMode) + cmd+=' %g %d'%(pt2pt_time,arg) self.cmdSync = cmd print ('starting '+cmd) self.syncShell=comm.shell_channel(cmd) - #self.syncChan=sc=comm._client.exec_command(cmd) - #ch=sc[1].channel - #ch.settimeout(1) - #sc[1].channel.setblocking(False) - #sc[1].read(100) - if flag&1: - print('set Coord[1].Q[10]=1 to start motion') + #syncChan=sc=comm._client.exec_command(cmd) #this is less simple to communicate with + + def homing(self): + if self.comm is None: return + comm = self.comm + gpascii = comm.gpascii + #Motor[1].HomeComplete + if gpascii.get_variable('Motor[1].HomeComplete', int)==0: + gpascii.send_block('enable plc 1') + while(True): + sys.stdout.write('.');sys.stdout.flush() + time.sleep(1) + if gpascii.get_variable('Motor[1].HomeComplete', int)==1: + break + print('homing done') + + + def run(self): 'runs the code sync_run which has been generated with setup_sync()' @@ -122,4 +150,18 @@ class MotionBase: raise 'Need to call setup sync before' gpascii.send_block(cmd) + def trigger(self,wait=.5): + if self.meta['sync_mode']==0: + return # no trigger at all + + time.sleep(wait) + if self.meta['sync_flag']&1: + comm = self.comm + gpascii = comm.gpascii + gpascii.send_block('Coord[1].Q[10]=1') + else: + import CaChannel + pvTrigger = CaChannel.CaChannel('SAR-CVME-TIFALL5-EVG0:SoftEvt-EvtCode-SP.VAL') + pvTrigger.searchw() + pvTrigger.putw(254) diff --git a/python/shapepath.py b/python/shapepath.py index f12700c..2f8146f 100755 --- a/python/shapepath.py +++ b/python/shapepath.py @@ -15,6 +15,7 @@ verbose bits: 4 upload progress 8 plot gather path 16 plot pvt trajectory (before motion) + 32 print sync details Gather motor order @@ -40,7 +41,7 @@ Enc 7: Interferometer X ''' from __future__ import print_function -import os, sys, time +import os, sys import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt @@ -62,9 +63,9 @@ def gen_pvt(p,v, p2pt, ts): !!! it is assumed, that the time intervals are constant !!! ''' n=int(p2pt/ts) - pvt=np.ndarray((p.shape[0]-1)*n)*0 + pvt=np.ndarray((p.shape[0]-1)*n) - tt=np.arange(0,p2pt,ts) + tt=np.arange(0,p2pt,ts)[:n] for i in range(p.shape[0]-1): d=p[i] c=v[i] @@ -75,21 +76,20 @@ def gen_pvt(p,v, p2pt, ts): return pvt class DebugPlot: - def __init__(self,spObj=None,fn=None): - if spObj is not None: - self.set_data(spObj) - elif fn is not None: - self.load_npz(fn) - else: + def __init__(self,obj=None): + if obj is None: self.load_npz() + elif type(obj)==str: + self.load_npz(obj) + else: + self.set_data(obj) - @staticmethod def plot_gen_pvt(self,pv): # pv is an array of posx posy velx vely #pv=pv[5:10,:] #pv=pv[5:-4,:] p2pt=self.meta['pt2pt_time'] # ms step between samples - ts=self.meta['timebase'] # sampling time in ms + ts=self.meta['srv_per'] # sampling time in ms n=int(p2pt/ts) # servo cycle between samples k=pv.shape[0] # number of unique samples t=np.arange(0, p2pt*k, p2pt) # time array of trajectory @@ -183,24 +183,27 @@ class DebugPlot: l2=l[:,0]**2+l[:,1]**2 try: ofs=l2.argmin() - except ValueError: - break#print(l2[ofs]) + except ValueError as e: + raise e #should never happen + break idx+=ofs idxInPos.append(idx) idxInPos = np.array(idxInPos) #select only triggers on a target point - i=np.abs(idxTrigger - idxInPos[1]).argmin() - j=np.abs(idxTrigger - idxInPos[-2]).argmin()+1 - self.idxTrigger=idxTrigger[i:j] - self.idxInPos=idxInPos[1:-1] + i=max(0,np.abs(idxTrigger-idxInPos[1]).argmin()-1) + j=i+idxInPos.shape[0] + idxTrigger=idxTrigger[i:j] + self.idxInPos=idxInPos + self.idxTrigger=idxTrigger def plot_trigger_jitter(self): self.analyze_trigger() - ts=self.meta['timebase'] + ts=self.meta['srv_per']*self.meta['acq_per'] idxTrigger=self.idxTrigger idxInPos=self.idxInPos - jitter = idxTrigger-idxInPos + n=min(idxTrigger.shape[0],idxInPos.shape[0])-1 + jitter = idxTrigger[1:n]-idxInPos[1:n] pts=self.pts # X,Y array rec=self.rec # yA,xA,yD,xD,trig @@ -213,14 +216,15 @@ class DebugPlot: rec = self.rec # yA,xA,yD,xD,trig - ts=self.meta['timebase'] + ts=self.meta['srv_per']*self.meta['acq_per'] fig = plt.figure('shot position error') ax = fig.add_subplot(1, 1, 1) #errx = rec[idxTrigger, 1] - rec[idxInPos, 3] #erry = rec[idxTrigger, 0] - rec[idxInPos, 2] - errx = rec[idxTrigger, 1] - pts[1:-1, 0] - erry = rec[idxTrigger, 0] - pts[1:-1, 1] + n=idxTrigger.shape[0] + errx = rec[idxTrigger, 1] - pts[:n, 0] + erry = rec[idxTrigger, 0] - pts[:n, 1] err = np.sqrt(errx ** 2 + erry ** 2) hl = [] @@ -239,7 +243,7 @@ class DebugPlot: def plot_pos_error(self): rec = self.rec # yA,xA,yD,xD,trig - ts=self.meta['timebase'] + ts=self.meta['srv_per']*self.meta['acq_per'] fig = plt.figure('position error') ax = fig.add_subplot(1, 1, 1) @@ -340,7 +344,7 @@ class DebugPlot: pts=self.pts # X,Y array rec = self.rec # yA,xA,yD,xD,trig strMot=('FY.act','FX.act','FY.des','FX.des') - ts=meta['timebase']*1E-3 #0.2ms + ts=self.meta['srv_per']*self.meta['acq_per']*1E-3 #0.2ms num=rec.shape[0] #rngMin=int(.01/ts);rngMax=int(num-1.001/ts) #0.01s from start 1.01 sec before end rngMin=int(.01/ts);rngMax=rngMin+int((pts.shape[0]-2)*.01/ts) @@ -417,14 +421,15 @@ class DebugPlot: def set_data(self,spObj): self.meta=spObj.meta self.pts=spObj.points - self.rec=spObj.rec - try: pvt=self.pvt + try: self.rec=spObj.rec + except AttributeError: pass + try: self.pvt=spObj.pvt except AttributeError: pass class ShapePath(MotionBase): - def __init__(self,comm, gather, verbose): - MotionBase.__init__(self,comm, gather, verbose) + def __init__(self,comm, gather, verbose,**kwargs): + MotionBase.__init__(self,comm, gather, verbose, **kwargs) def gen_swissmx_points(self,flipx=False,flipy=False,ofs=(0,0),width=1000): 'generathe a path that writes swissfel' @@ -607,7 +612,7 @@ class ShapePath(MotionBase): self.ptsCorr=ptsCorr print(ptsCorr) - def setup_gather(self,acq_per=1,sim=False): + def setup_gather(self,acq_per=1): ''' setup the channels to gather kwargs: @@ -617,16 +622,14 @@ class ShapePath(MotionBase): comm=self.comm gt=self.gather gt.set_phasemode(False) - if sim: + if self.meta['sync_flag']&2: address=("Motor[1].ActPos","Motor[2].ActPos","Motor[1].DesPos","Motor[2].DesPos","Coord[1].Q[11]") else: address=("Motor[1].ActPos","Motor[2].ActPos","Motor[1].DesPos","Motor[2].DesPos","Gate3[1].Chan[1].UserFlag") gt.set_address(*address) gt.set_property(MaxSamples=1000000, Period=acq_per) - ServoPeriod= .2 #0.2ms #Sys.ServoPeriod is dependent of !common() macro - #ServoPeriod=comm.gpascii.servo_period - self.meta = {'timebase': ServoPeriod*acq_per,'address':address} + self.meta.update({'acq_per':acq_per,'address':address}) def setup_coord_trf(self): if self.comm is None: return @@ -666,9 +669,9 @@ class ShapePath(MotionBase): if comm is not None: gpascii=comm.gpascii # this uses Coord[1].Tm and limits with MaxSpeed - elif mode in (1,3): #### pvt motion + if mode in (1,3): #### pvt motion pt2pt_time=self.meta['pt2pt_time'] - ts=self.meta['timebase'] + ts=self.meta['srv_per'] scale=kwargs.get('scale', 1.) cnt=kwargs.get('cnt', 1) # move path multiple times dwell=kwargs.get('dwell', 100) # synchronization mark all n points @@ -707,7 +710,7 @@ class ShapePath(MotionBase): pv[ 1:-1,(2,3)] = v[:n]*scale verb=self.verbose if verb&16: - self.pvt=DebugPlot(self).plot_gen_pvt(pv) + dp=DebugPlot(self);self.pvt=dp.plot_gen_pvt(pv) plt.show() pv[1:-1, (2, 3)]*=CoordFeedTime #scaling for Deltatau @@ -784,23 +787,47 @@ if __name__=='__main__': # '%(levelname)-8s %(message)s'), # datefmt='%m-%d %H:%M', # ) - def trigger(wait=.5): - import CaChannel - time.sleep(wait) - pvTrigger = CaChannel.CaChannel('SAR-CVME-TIFALL5-EVG0:SoftEvt-EvtCode-SP.VAL') - pvTrigger.searchw() - pvTrigger.putw(254) + + def unique_filename(fnBase): + i = 0; + while (True): + fn=fnBase+('%0.3d'%i) + i+=1 + if not os.path.exists(fn+'.npz'): + print('save to '+fn+'.*') + break + return fn def run_test(args): - dp=DebugPlot();dp.plot_gather();return + #dp=DebugPlot();dp.plot_gather();return #args.host=None if args.host is None: comm=gather=None else: comm = PPComm(host=args.host) gather = Gather(comm) - sp = ShapePath(comm, gather, args.verbose) + #real start and frame trigger with sync + #sp = ShapePath(comm, gather, args.verbose) + + # direct start + #sp = ShapePath(comm, gather, args.verbose,sync_mode=0) + + #simulated start and frame trigger no sync + #sp = ShapePath(comm, gather, args.verbose,sync_mode=1,sync_flag=3) + + #simulated start and frame trigger with sync + #sp = ShapePath(comm, gather, args.verbose,sync_mode=2,sync_flag=3) + + #simulated start real frame trigger no sync + #sp = ShapePath(comm, gather, args.verbose,sync_mode=1,sync_flag=1) + + #simulated start real frame trigger with sync + sp = ShapePath(comm, gather, args.verbose,sync_mode=2,sync_flag=1) + + fn='/tmp/shapepath' + #fn =unique_filename('ShapePathAnalyser/records/19_01_24/spiral') + # Gather.MaxLines=116508 # ts=0.2ms # max_num_points=(MaxLines*ts-1000ms)/(+acq_per*pt2pt_time*ts) @@ -814,128 +841,44 @@ if __name__=='__main__': # 10ms 3 6860 # 10ms 4 9180 - #sp.gen_swissmx_points(width=1000,ofs=(-500,0)) - #sp.gen_swissfel_points(width=1000,ofs=(-500,0)) - #fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/PBMotionAnalyzer/records/mode1' - #fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/record/grid_delay_0002' - # /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/record/chip000_sortedXXXX_9x9' - #fn='/sf/bernina/data/p17592/res/20181203/imprints/chip000_preloc_min10um_sortedX_refs_goaround/chip000_sortedY_9x9.npz' - #fn='PBMotionAnalyzer/records/rand50um_25Hz' - #sp.setup_coord_trf() - - #sp.points=np.zeros((2,2)) - sp.meta={'timebase':.2,'pt2pt_time':40} - #sp.gather_upload(fnRec=fn+'.npz') - #Tools.plot_gather(sp) - #return - xy=False - #sp.gen_rand_points(n=14, scale=1000);sp.sort_points(xy=xy) - #print(sp.points[:,0]) - #sp.gen_swissmx_points(width=1000, ofs=(-500, 0)); - - #sp.gen_spiral_points(rStart=100,rInc=10,numSeg=4,numCir=60, ofs=(0, 0)) - sp.gen_spiral_points(rStart=100,rInc=130,numSeg=4,numCir=2, ofs=(0, 0)) - #sp.gen_spiral_points(rStart=100,rInc=20,numSeg=8,numCir=32, ofs=(0, 0)) - - #sp.gen_closed_shifted() - #sp.gen_grid_points(w=10,h=10,pitch=100,rnd=0,ofs=(0,0));sp.sort_points(False); - #sp.gen_grid_points(w=1,h=10,pitch=100,rnd=0,ofs=(0,0)) - #sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=0) - #sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=1) - - #works: direct start - #sp.setup_gather(acq_per=1) - #sp.setup_sync(mode=0) - - #works: simulated start and frame trigger no sync - #sp.setup_gather(acq_per=1,sim=True) - #sp.setup_sync(mode=1,flag=3) - - #works: simulated start and frame trigger with sync - #sp.setup_gather(acq_per=1,sim=True) - #sp.setup_sync(mode=2,flag=3) - - #works: simulated start real frame trigger no sync - #sp.setup_gather(acq_per=1) - #sp.setup_sync(mode=1,flag=1) - - #works: simulated start real frame trigger with sync - sp.setup_gather(acq_per=1) - sp.setup_sync(mode=2,flag=1) - - sp.setup_coord_trf() # reset to shape path system - sp.setup_motion(fnPrg=fn + '.prg', mode=3, scale=1,dwell=10) - #sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=0,dwell=10) - sp.run() - sp.gather_upload(fnRec=fn+'.npz') - dp=DebugPlot(obj=sp);dp.plot_gather(mode=11) - exit(0) - - # fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/'+time.strftime('%y-%m-%d-%H_%M_%S') - - #>>>point source and sorting<<< - #sp.points = np.array([[100,523],[635,632],[756,213]]) - #sp.points = np.array([[0, 0],[100, 0],[200, 0],[300, 0],[400, 0],[400, 100],[300, 100],[200, 100],[100, 100],[0, 100],[10, 200],[100, 200],[200, 200],[300, 200],[400, 200],[410, 300],[300, 300],[200, 300],[100, 300],[0, 300],[0, 400],[100, 400],[200, 400],[300, 400],[400, 400]]) - #sp.gen_rand_points(n=107, scale=1000);sp.sort_points(xy=xy) - #sp.gen_rand_points(n=107, scale=1000);sp.sort_points(xy=xy) - #fh=np.load('/sf/bernina/data/p17592/res/20181203/imprints/chip000_preloc_min10um_sortedX_refs_goaround/chip000_preloc_min10um_sortedX_refs_goaround_0529.npz') - #sp.points=fh['pts'] - sp.gen_grid_points(w=6,h=6,pitch=100,rnd=0,ofs=(0,0));sp.sort_points(False); - sp.gen_closed_shifted() - sp.points=sp.points-+sp.points[0,:]+(-967,1446) - #1412.33 -2862.37 - #1446.62 -967.7128125 - - #sp.plot_points(sp.points);plt.show() - + #xy=False + #sp.gen_grid_points(w=6,h=6,pitch=100,rnd=0,ofs=(0,0));sp.sort_points(False); #sp.gen_grid_points(w=100,h=100,pitch=10,rnd=.2) #sp.gen_swissfel_points(width=1000,ofs=(-500,0));sp.sort_points(xy=xy) #sp.gen_grid_points(w=10,h=10,pitch=50,rnd=.2) #sp.gen_grid_points(w=100,h=100,pitch=50,rnd=.2) + #sp.gen_closed_shifted() + #sp.gen_swissmx_points(width=1000,ofs=(-500,0)) + #sp.gen_swissfel_points(width=1000,ofs=(-500,0)) + #sp.gen_rand_points(n=14, scale=1000);sp.sort_points(xy=xy) + #sp.gen_swissmx_points(width=1000, ofs=(-500, 0)); + #sp.gen_spiral_points(rStart=100,rInc=10,numSeg=4,numCir=60, ofs=(0, 0)) + #sp.gen_spiral_points(rStart=100,rInc=130,numSeg=4,numCir=2, ofs=(0, 0)) + #sp.gen_grid_points(w=10,h=10,pitch=100,rnd=0,ofs=(0,0));sp.sort_points(False); + #sp.gen_grid_points(w=1,h=10,pitch=100,rnd=0,ofs=(0,0)) + sp.gen_spiral_points(rStart=100,rInc=20,numSeg=8,numCir=32, ofs=(0, 0)) + #sp.gen_closed_shifted() + sp.setup_gather(acq_per=1) + sp.setup_sync(verbose=args.verbose&32) - #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(mode=1) #sync with timing system (PROG) - sp.setup_sync(mode=2) #sync with timing system and PLC to sync speed (PROG) sp.setup_coord_trf() # reset to shape path system - sp.setup_motion(fnPrg=fn + '.prg', mode=1) - #sp.gen_grid_points(w=2,h=2,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,acq_per=1) - #sp.gen_swissmx_points(width=1000,ofs=(-500,0));sp.setup_motion(fnPrg=fn+'.prg',mode=1,acq_per=1) + sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1,dwell=10) + #sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=1,dwell=10) + #sp.setup_motion(fnPrg=fn + '.prg', mode=1, scale=0,dwell=10) + sp.homing() + sp.run() + sp.trigger(0.5) #send a start trigger (if needed) ater given time + sp.gather_upload(fnRec=fn+'.npz') + dp=DebugPlot(sp);dp.plot_gather(mode=11) - #sp.gen_grid_points(w=30,h=30,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=200,h=200,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - - #sp.gen_grid_points(w=2,h=20,pitch=50,rnd=0);sp.setup_motion(fnPrg=fn+'.prg',mode=1,acq_per=1) - #sp.gen_rand_points(n=500, scale=1000);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,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,) - #sp.gen_rand_points(n=400, scale=1000);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1) + #sp.plot_points(sp.points);plt.show() - #sp.gen_swissmx_points(width=2000,flipx=True,flipy=True,ofs=(1014,-281));sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=20,h=20,pitch=20,rnd=0,ofs=(-464,1754));sp.sort_points(True);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=20,h=20,pitch=20,rnd=0,ofs=(-160,3700));sp.sort_points(False);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=5,h=5,pitch=100,rnd=0,ofs=(-1590,-1070));sp.sort_points(False);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=5,h=5,pitch=100,rnd=0,ofs=(-1580,-1070));sp.sort_points(False);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=5,h=5,pitch=100,rnd=0,ofs=(-1580,-1060));sp.sort_points(False);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - #sp.gen_grid_points(w=5,h=5,pitch=100,rnd=0,ofs=(-1590,-1060));sp.sort_points(False);sp.setup_motion(fnPrg=fn+'.prg',mode=1) - - #>>>setup gather and sync<<< - #sp.setup_gather() - #sp.setup_sync() - - #>>>setup motion program<<< - #sp.setup_motion(fnPrg=fn+'.prg',mode=1) #>>>run gather and plot trajectory<<< #return - sp.run() - #trigger(0.5) - sp.gather_upload(fnRec=fn+'.npz') - Tools.plot_gather(sp,mode=11) from optparse import OptionParser, IndentedHelpFormatter