diff --git a/python/MXTuning.py b/python/MXTuning.py index c2984d3..ddccd99 100755 --- a/python/MXTuning.py +++ b/python/MXTuning.py @@ -30,7 +30,7 @@ from scipy import signal 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 +from pbtools.misc.pp_comm import PPComm,GpasciiChannel from pbtools.misc.gather import Gather from pbtools.misc.tuning import Tuning @@ -44,6 +44,7 @@ class MXTuning(Tuning): def init_stage(self): comm=self.comm + if comm is None: return gpascii=comm.gpascii sys.stdout.write('homing stage');sys.stdout.flush() gpascii.send_line('enable plc1') @@ -201,100 +202,6 @@ class MXTuning(Tuning): # tp print see also: print(np.poly1d([1,2,3], variable='s')), print(np.poly1d([1,2,3], r=True, variable='s')) - def custom_chirp(self): - motor = 1 - amp, minFrq, maxFrq, tSec = (10, 10, 300, 30) - file='/tmp/gather.npz' - # if not os.path.isfile(f): tune.init_stage();plt.close('all') - # tune.bode_chirp(openloop=True, file=f, motor=mot, amp=amp, minFrq=minFrq, maxFrq=maxFrq, tSec=tSec) - prog = ''' - &0 //cout works only in coord 0 - open prog 999 - L11=0 - L10=0 - L12=0 - L13=0 - L14=0 - Gather.Enable=2 - while(L10<300005) - { - L12=10*sin(31.415926535897931*(pow(1.058324104020218,(L10*0.000199996614513))-1)/log(1.058324104020218)) - cout%d:(L12) - L10=L10+1 - } - Gather.Enable=0 - close - b999r - '''%motor - gpascii = self.comm.gpascii - gt = self.gather - print(gpascii.servo_period) - gt.set_phasemode(False) - address=("Motor[1].IqCmd", "Motor[1].ActPos",) - gt.set_address(*address) - #Gather.Enable=1 - gt.set_property(MaxSamples=300000, Period=1) - - # gt.enable(2) - gpascii.send_line(prog) - gpascii.sync() - - gt.wait_stopped() - self.data=data=gt.upload() - meta={'motor':motor,'date':time.asctime(),'minFrq':minFrq,'maxFrq':maxFrq,'tSec':tSec,'amp':amp,'address':address} - np.savez_compressed(file, data=data, meta=meta) - meta['file'] = file - self.bode_chirp_plot(data, meta,True) - pass - - - def bode_sine(self,openloop=True,motor=1,minFrq=1,maxFrq=20,numFrq=15,amp=10,file='/tmp/gather.npz'): - '''calculates phase and amplitude at different frequencies and - saves:#loads and plots the bode diagram''' - if False:# os.path.isfile(file): - f=np.load(file) - bode=f['bode'] - meta=f['meta'].item() - meta['file']=file - else: - gpascii=self.comm.gpascii - #motor 1 maximum: 13750 - #amp= percentage of maximum amplitude - fig = plt.figure() - ax = fig.add_subplot(1, 1, 1) - frqLst=np.logspace(np.log10(minFrq),np.log10(maxFrq),numFrq) - n=len(frqLst) - #frqLst=(10,15,20,25,30) - bode=np.ndarray((n,3)) - bode[:, 0]=frqLst - #for i in range(n): - for i in range(n-1,-1,-1): - frq=frqLst[i] - t=1 - rep=max(1,frq*t) - if openloop: - data=self.do_command('openloopsine',motor,amp,frq,rep,0) - else: - data=self.do_command('sinusoidal',motor,amp,frq,rep,0) - data=data[:,(1,2)] - gpascii.send_line('#1j=0') - time.sleep(1) - ax.clear() - avg=data.mean(0) - print(avg) - ax.plot(data[:, 0]-avg[0] , 'b-', label='input') - ax.plot(data[:, 1]-avg[1], 'g-', label='output') - #plt.pause(.05) - bode[i,1:]=self.phase_amp(frq, rep) - print('frq %g ampl %g phase %g'%tuple(bode[i,:])) - plt.show(block=False);plt.pause(.05) - - meta={'motor':motor,'date':time.asctime()} - np.savez_compressed(file, bode=bode, meta=meta) - meta['file']=file - self.bode_sine_plot(bode, meta) - - def bode(mdl): w,mag,phase = signal.bode(mdl,1000) f=w/(2*np.pi) @@ -315,7 +222,7 @@ if __name__=='__main__': from argparse import ArgumentParser,RawDescriptionHelpFormatter import logging logger = logging.getLogger(__name__) - logger = logging.getLogger('pbtools.misc.pp_comm') + #logger = logging.getLogger('pbtools.misc.pp_comm') logger.setLevel(logging.DEBUG) logging.basicConfig(format=('%(asctime)s %(name)-12s ' '%(levelname)-8s %(message)s'), @@ -342,10 +249,13 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n ' args=parser.parse_args() #plt.ion() - #comm = PPComm(host=args.host) - #gt = Gather(comm) - #tune=MXTuning(comm,gt) - tune = MXTuning(None,None) + args.host='MOTTEST-CPPM-CRM0573' + if args.host is None: + comm=gt=None + else: + comm = PPComm(host=args.host) + gt = Gather(comm) + tune=MXTuning(comm,gt) base='MXTuning' if args.dir is not None: base=args.dir @@ -426,10 +336,12 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n ' tune.bode_chirp(openloop=False, file=fn) print('done') elif mode==7: #further tests - tune.init_stage(); - plt.close('all') - tune.bode_sine() - tune.custom_chirp() + #tune.init_stage(); + plt.close('all') + #tune.custom_chirp() + tune.custom_chirp(motor=1,minFrq=1,maxFrq=3000,tSec=5,mode=0,file='/tmp/cst_chirp0.npz') + tune.custom_chirp(motor=2,minFrq=1,maxFrq=1000,tSec=5,mode=1,file='/tmp/cst_chirp1.npz') + tune.custom_chirp(motor=1,minFrq=1,maxFrq=3000,tSec=5,mode=2,file='/tmp/cst_chirp2.npz') plt.show() #------------------ Main Code ---------------------------------- diff --git a/python/shapepath.py b/python/shapepath.py index 8b35662..f397259 100755 --- a/python/shapepath.py +++ b/python/shapepath.py @@ -51,6 +51,27 @@ class ShapePath(MotionBase): def __init__(self,comm, gather, verbose): MotionBase.__init__(self,comm, gather, verbose) + def gen_swissmx_points(self,scale=10): + 'generathe a path that writes swissfel' + #string from inkscape path of the drawing + d="m 524.7061,637.31536 3.54883,0 3.54882,0 3.54883,0 0,-4.20801 0,-4.20801 0,-4.208 0,-4.20801 4.22949,0 4.22949,0 4.2295,0 4.22949,0 0,-3.55957 0,-3.55957 0,-3.55957 0,-3.55957 -4.22949,0 -4.2295,0 -4.22949,0 -4.22949,0 0,-4.22949 0,-4.2295 0,-4.22949 0,-4.22949 -3.54883,0 -3.54882,0 -3.54883,0 -3.54883,0 0,4.22949 0,4.22949 0,4.2295 0,4.22949 -4.20752,0 -4.20752,0 -4.20752,0 -4.20752,0 0,3.55957 0,3.55957 0,3.55957 0,3.55957 4.20752,0 4.20752,0 4.20752,0 4.20752,0 0,4.20801 0,4.208 0,4.20801 0,4.20801 -11.87126,0.36152 -12.12171,-0.13934 -2.52941,3.93977 -2.57238,3.94369 -2.50854,3.88614 -2.50731,3.91767 -2.49035,3.88268 -2.50987,3.91244 -2.50453,3.88732 -2.51897,3.9189 -6.39782,5.72802 -6.63782,6.70894 -3.21517,5.11464 -3.3404,5.32333 -3.08995,5.11464 -3.17343,5.15637 -16.69223,0.0698 5.55908,0 5.55909,0 5.55908,0 3.18604,-5.17432 3.18603,-5.17431 3.18604,-5.17432 3.18603,-5.17431 3.17481,5.17431 3.1748,5.17432 3.17481,5.17431 3.1748,5.17432 5.59229,0 5.59228,0 5.59229,0 5.59228,0 -2.74121,-4.15283 -2.74121,-4.15283 -2.74121,-4.15283 -2.74121,-4.15284 -2.74122,-4.15283 -2.74121,-4.15283 -2.74121,-4.15283 -2.74121,-4.15283 2.50488,-3.90015 2.50489,-3.90015 2.50488,-3.90014 2.50488,-3.90015 2.50488,-3.90015 2.50489,-3.90015 2.50488,-3.90014 2.50488,-3.90015 -5.42724,0 -5.42725,0 -5.42724,0 -5.42725,0 -2.76855,4.95508 -2.76856,4.95508 -2.76855,4.95508 -2.76856,4.95508 -2.85644,-4.95508 -2.85645,-4.95508 -2.85644,-4.95508 -2.85645,-4.95508 -5.48193,0 -5.48194,0 -5.48194,0 -5.48193,0 2.52686,3.8562 2.52685,3.8562 2.52686,3.8562 2.52686,3.85621 2.52685,3.8562 2.52686,3.8562 2.52685,3.8562 2.52686,3.8562 -2.77954,4.19678 -2.77954,4.19678 -2.77954,4.19677 -2.77955,4.19678 -2.77954,4.19678 -2.77954,4.19678 -2.77954,4.19677 -2.77954,4.19678 -4.91638,0 -4.91638,0 -4.91639,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91639,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91638,0 -4.91639,0 -4.91638,0 -4.91638,0 4.07568,0 4.07568,0 4.07569,0 4.07568,0 0,-6.14136 0,-6.14135 0,-6.14136 0,-6.14136 0,-6.14136 0,-6.14135 0,-6.14136 0,-6.14136 1.57105,6.14136 1.57104,6.14136 1.57104,6.14135 1.57105,6.14136 1.57105,6.14136 1.57104,6.14136 1.57104,6.14135 1.57105,6.14136 3.68066,0 3.68067,0 3.68067,0 3.68066,0 1.57642,-6.14136 1.57641,-6.14135 1.57642,-6.14136 1.57641,-6.14136 1.57642,-6.14136 1.57642,-6.14135 1.57641,-6.14136 1.57642,-6.14136 0,6.14136 0,6.14136 0,6.14135 0,6.14136 0,6.14136 0,6.14136 0,6.14135 0,6.14136 4.06494,0 4.06494,0 4.06494,0 4.06494,0 0,-8.05298 0,-8.05298 0,-8.05298 0,-8.05297 0,-8.05298 0,-8.05298 0,-8.05298 0,-8.05298 -6.52588,0 -6.52588,0 -6.52587,0 -6.52588,0 -1.25781,4.8999 -1.25782,4.89991 -1.25781,4.8999 -1.25781,4.8999 -1.25781,4.8999 -1.25782,4.89991 -1.25781,4.8999 -1.25781,4.8999 -1.26343,-4.8999 -1.26343,-4.8999 -1.26343,-4.89991 -1.26343,-4.8999 -1.26342,-4.8999 -1.26343,-4.8999 -1.26343,-4.89991 -1.26343,-4.8999 -6.54785,0 -6.54785,0 -6.54785,0 -6.54785,0 0,8.05298 0,8.05298 0,8.05298 0,8.05298 0,8.05297 0,8.05298 0,8.05298 -4.25755,8.13646 -8.40743,0.19687 -8.40743,0.19687 -8.40743,0.19687 -8.40743,0.19687 5.93521,0.22812 8.09742,-0.56079 6.18579,-1.6814 4.55883,-2.66919 3.13062,-3.43823 1.84571,-3.87866 0.61523,-3.98853 -0.58179,-3.83373 -1.74634,-3.50416 -2.802,-2.95581 -3.83472,-2.18676 -5.49316,-1.60401 -7.77832,-1.20849 -7.64649,-1.58204 -1.75781,-2.59179 1.36328,-2.59375 4.4375,-1.09766 5.09766,1.40625 2.19727,3.29492 4.24072,-0.41748 4.24073,-0.41748 4.24072,-0.41748 4.24072,-0.41748 -1.98804,-4.09741 -2.44946,-3.15259 -2.97778,-2.3291 -3.65894,-1.62598 -5.05371,-0.95629 -7.25098,-0.3191 -7.10766,0.41748 -5.50367,1.25244 -4.19677,2.05494 -3.18604,2.91186 -2.01099,3.65796 -0.67065,4.29517 0.61523,3.98852 1.84571,3.5271 2.78002,2.823 3.32935,1.87817 5.06421,1.42822 7.89868,1.56006 7.69141,1.84571 2.02148,2.98828 -1.53906,2.85742 -5.58008,1.53711 -5.27344,-1.36133 -3.07617,-4.52734 -4.43847,0.41748 -4.43848,0.41748 -4.43848,0.41748 -4.43847,0.41748 2.50488,5.95459 4.43848,4.4165 3.18313,1.59592 4.10031,1.14017 -3.65979,0.0939 -5.9713,6e-5 -5.97131,5e-5 -5.9713,6e-5 -5.9713,6e-5 -5.9713,5e-5 -5.97131,6e-5 -5.9713,5e-5 -5.9713,6e-5 5.34491,0.81842 8.09742,-0.56079 6.18579,-1.6814 4.55883,-2.66919 3.13062,-3.43823 1.84571,-3.87866 0.61523,-3.98853 -0.58179,-3.83373 -1.74634,-3.50416 -2.802,-2.95581 -3.83472,-2.18676 -5.49316,-1.60401 -7.77832,-1.20849 -7.64649,-1.58204 -1.75781,-2.59179 1.36328,-2.59375 4.4375,-1.09766 5.09766,1.40625 2.19727,3.29492 4.24072,-0.41748 4.24073,-0.41748 4.24072,-0.41748 4.24072,-0.41748 -1.98804,-4.09741 -2.44946,-3.15259 -2.97778,-2.3291 -3.65894,-1.62598 -5.05371,-0.95629 -7.25098,-0.3191 -7.10766,0.41748 -5.50367,1.25244 -4.19677,2.05494 -3.18604,2.91186 -2.01099,3.65796 -0.67065,4.29517 0.61523,3.98852 1.84571,3.5271 2.78002,2.823 3.32935,1.87817 5.06421,1.42822 7.89868,1.56006 7.69141,1.84571 2.02148,2.98828 -1.53906,2.85742 -5.58008,1.53711 -5.27344,-1.36133 -3.07617,-4.52734 -4.43847,0.41748 -4.43848,0.41748 -4.43848,0.41748 -4.43847,0.41748 2.50488,5.95459 4.43848,4.4165 3.18313,1.59592 4.10031,1.14017 -3.06953,-0.0416 -3.06952,-0.0416 -8.58102,-0.0261 -10.12782,-0.0261 -7.03422,-0.0261 -8.58102,-0.0261 4.47168,0 6.6151,0 2.32826,0 4.47168,0 0,-5.83374 0,-5.83374 0,-5.83374 0,-5.83374 0,-5.83374 0,-5.83374 0,-5.83374 0,-5.83374 -4.47168,0 -4.47168,0 -4.47168,0 0,-5.5796 4.47168,0 4.47168,0 4.47168,0 0,-6.08691 0,-6.08692 -4.47168,0 -4.47168,0 -4.47168,0 -4.47168,0 0,6.08692 0,6.08691 0,5.5796 0,5.83374 0,5.83374 0,5.83374 0,5.83374 0,5.83374 0,5.83374 0,5.83374 -3.67318,5.83374 -8.7308,0 -10.73079,0 -6.7308,0 -9.10563,0 -2.25201,0.007 -8.72971,0.0266 -7.53755,-0.0442 -9.68477,0.0107 -6.3443,0 3.99902,0 3.99902,0 3.99903,0 3.99902,0 2.28516,-7.02002 2.28516,-7.02002 2.28516,-7.02002 2.28516,-7.02002 2.36181,7.02002 2.36182,7.02002 2.36181,7.02002 2.36182,7.02002 3.97705,0 3.97705,0 3.97705,0 3.97705,0 2.14795,-5.83374 2.14795,-5.83374 2.14795,-5.83374 2.14795,-5.83374 2.14795,-5.83374 2.14795,-5.83374 2.14795,-5.83374 2.14795,-5.83374 -4.2959,0 -4.2959,0 -4.2959,0 -4.2959,0 -0.93921,3.67505 -0.93921,3.67505 -0.93921,3.67505 -0.93921,3.67505 -0.9392,3.67504 -0.93921,3.67505 -0.93921,3.67505 -0.93921,3.67505 -1.23047,-3.67505 -1.23047,-3.67505 -1.23047,-3.67505 -1.23047,-3.67504 -1.23046,-3.67505 -1.23047,-3.67505 -1.23047,-3.67505 -1.23047,-3.67505 -4.03223,0 -4.03222,0 -4.03223,0 -4.03223,0 -1.18652,3.67505 -1.18653,3.67505 -1.18652,3.67505 -1.18653,3.67505 -1.18652,3.67504 -1.18652,3.67505 -1.18653,3.67505 -1.18652,3.67505 -0.93921,-3.67505 -0.93921,-3.67505 -0.93921,-3.67505 -0.93921,-3.67504 -0.9392,-3.67505 -0.93921,-3.67505 -0.93921,-3.67505 -0.93921,-3.67505 -4.32862,0 -4.32861,0 -4.32862,0 -4.32861,0 2.16431,5.83374 2.1643,5.83374 2.16431,5.83374 2.16431,5.83374 2.16431,5.83374 2.1643,5.83374 2.16431,5.83374 -3.84635,5.83374 -5.60781,0.003 -5.6078,0.003 -5.60781,0.003 -5.6078,0.003 -5.4839,-1.59358 0,0 5.47119,-3.35034 4.10888,-4.60278 2.5708,-5.4712 0.85694,-5.95459 -0.64868,-5.02123 -1.94507,-4.51587 -3.32837,-3.91114 -4.88843,-3.20801 -7.482173,-2.87842 -5.1337,-1.42273 -6.06186,-1.41174 -6.67969,-2.37304 -1.44922,-2.76758 1.75782,-3.56055 5.22851,-1.49414 6.5918,1.97852 1.99951,2.5708 1.16455,3.75732 4.69141,-0.2749 4.691403,-0.2749 4.6914,-0.27491 4.69141,-0.2749 -0.94483,-4.66918 -1.604,-3.98804 -2.26318,-3.30688 -2.92236,-2.62574 -3.59802,-2.01858 -4.334103,-1.44162 -5.0702,-0.86484 -5.80627,-0.28824 -4.76547,0.1593 -4.23282,0.47791 -6.86695,1.91162 -5.04223,2.98828 -3.61401,3.95507 -2.14283,4.53687 -0.7146,4.82251 1.40625,6.88892 4.21875,5.54858 3.26035,2.31812 4.19986,2.07641 5.13919,1.83472 6.07834,1.59302 6.54785,1.81226 3.64746,1.92211 2.19727,4.48242 -2.33008,4.65821 -6.54688,1.97851 -5.05371,-0.97827 -3.73535,-2.93384 -1.57153,-2.9663 -0.93433,-4.06495 -4.73486,0.29688 -4.73487,0.29687 -4.73486,0.29688 -4.73486,0.29687 0.76065,4.6637 1.44711,4.23523 2.13376,3.80676 2.82059,3.3783 3.79577,2.76855 5.0592,1.97754 6.32264,1.18652 7.58606,0.39551 9.481626,-0.95145 -7.224723,-0.043 -7.224724,-0.043 -7.224723,-0.043 -7.224723,-0.043 -7.224723,-0.043 -7.224723,-0.043 -7.224724,-0.043 -7.224723,-0.043" + d=d.split() + pts=np.ndarray((len(d)-1,2),dtype=np.float) + for i in xrange(pts.shape[0]): + pts[i,:]=map(float,d[i+1].split(',')) + + pts[0,:]=(5,0) + pts=pts.cumsum(0) + pts[:,1]=-pts[:,1] + pts*=scale + self.points=pts + + verb=self.verbose + if verb&2: + self.plot_points(pts) + plt.show() + + def gen_swissfel_points(self,scale=10): 'generathe a path that writes swissfel' #string from inkscape path of the drawing @@ -69,7 +90,7 @@ class ShapePath(MotionBase): verb=self.verbose if verb&2: self.plot_points(pts) - plt.show() + plt.show() def gen_rand_points(self,n=107,scale=1000): 'generate random distributed points' @@ -385,8 +406,104 @@ class ShapePath(MotionBase): ax.yaxis.set_label_text('pos-error um') legend = ax.legend(loc='upper right', shadow=True) print('average error x %g um, y %g um, %g um'%(np.abs(errx).mean(),np.abs(erry).mean(),err.mean())) + + self.bode_plot(xy=(4,1),mode=31,db=True) # FX + self.bode_plot(xy=(5,2),mode=31,db=True) # FY + plt.show() + def bode_plot(self,xy=(0,1),mode=25,db=True): + '''displays a bode plot of the data + Y(s)=G(s)*X(s) + Y= output signal + X= input signal + xy are the row indexes of input and output signal + meta= meta information (dictionary) of data + + mode bits: (+mean default) + +1: display time signal + 2: display bode of X(s) signal + 4: display bode of Y(s) signal + +8: display bode of G(s) signal + +16: clip frequencies out of minFrq,maxFrq + +"Motor[3].ActPos","Motor[2].ActPos","Motor[1].ActPos","Motor[3].DesPos","Motor[2].DesPos","Motor[1].DesPos") + ACT DES +motors RY FX FY RY FX FY + 3 2 1 3 2 1 + + + ''' + data=self.rec + strMot=('RY.act','FX.act','FY.act','RY.des','FX.des','FY.des') + + ts=self.meta['timebase']*1E-3 #0.2ms + num=data.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((self.points.shape[0]-2)*.01/ts) + + num=rngMax-rngMin + + minFrq=1/(num*ts)#minimal frq to show bode + maxFrq=1/(2*ts) #maximal frq to show bode + xIdx,yIdx=xy + #remove DC value + x=data[rngMin:rngMax,xIdx]-data[rngMin,xIdx] + y=data[rngMin:rngMax,yIdx]-data[rngMin,yIdx] + #make last value same as first (nice periodicity) + x=x-(x[-1]*np.arange(num)/(num-1.)) + y=y-(y[-1]*np.arange(num)/(num-1.)) + if mode&1: + t = ts*np.arange(num) + fig=plt.figure('raw {}->{}'.format(strMot[xIdx],strMot[yIdx])) + ax=fig.gca() + ax.plot(t,x,'b') + ax.plot(t,y,'g') + + fig=plt.figure('bode {}->{}'.format(strMot[xIdx],strMot[yIdx])) + ax1=fig.add_subplot(2,1,1) + ax1.grid(True) + ax1.yaxis.set_label_text('Amplitude'+ (' [dB]' if db else '')) + ax1.axvline(minFrq,c='k');ax1.axvline(maxFrq,c='k') + + ax2=fig.add_subplot(2,1,2, sharex = ax1) + ax2.grid(True) + ax2.xaxis.set_label_text('Frequency [Hz]') + ax2.yaxis.set_label_text('Phase [degree]') + + ftX=np.fft.rfft(x) + ftY=np.fft.rfft(y) + + fMax=.5/ts #fs=1/ts, fMax=1/2fs + n=ftX.shape[0] + f=np.arange(n)*fMax/(n-1) + + if mode&16: + i=int(minFrq*num*ts); j=int(maxFrq*num*ts); #print(w[i],w[j]) + f=f[i:j+1] + ftX=ftX[i:j+1] + ftY=ftY[i:j+1] + ftLst=[] + if mode&2: + ftLst.append((ftX,'b')) + if mode&4: + ftLst.append((ftY,'g')) + if mode&8: + ftLst.append((ftY/ftX,'r')) + + for ft,c in ftLst: + phase=np.angle(ft) + phase=np.degrees(np.unwrap(phase)) + mag=np.abs(ft) #ftY)/np.abs(ftX) + if db: + magDb=20*np.log10(mag) #in decibel (20=10*2: factor 2 because rfft only half) + ax1.semilogx(f,magDb,c) # Bode magnitude plot + else: + ax1.semilogx(f, mag, c) # Bode magnitude plot + ax2.semilogx(f,phase,c) # Bode phase plot + plt.show(block=False) + + if __name__=='__main__': #import logging #logger = logging.getLogger(__name__) @@ -404,9 +521,18 @@ if __name__=='__main__': comm = PPComm(host=args.host) gather = Gather(comm) sp = ShapePath(comm, gather, args.verbose) + + #fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/PBMotionAnalyzer/records/mode1' + #fh=np.load(fn+'.npz') + #for k,v in fh.iteritems(): + # setattr(sp,k,v) + #sp.meta=sp.meta.item() + #sp.points=sp.pts; del sp.pts + #sp.plot_gather() + #return + fn='/tmp/shapepath' #sp.setup_coord_trf() - fn='/tmp/shapepath' #sp.points=np.zeros((2,2)) #sp.meta={'timebase':.2} #sp.gather_upload(fnRec=fn+'.npz') @@ -431,7 +557,11 @@ if __name__=='__main__': sp.setup_sync() #no sync at all #sp.setup_sync(mode=1) #sync with timing system - sp.gen_grid_points(w=20,h=20,pitch=50,rnd=.2);sp.sort_points(xy);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=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,pt2pt_time=10,acq_per=1) + #sp.gen_swissmx_points(scale=10);sp.setup_motion(fnPrg=fn+'.prg',mode=1,pt2pt_time=10,acq_per=1) + + #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) #>>>setup gather and sync<<<