Changeset 754 in ETALON
- Timestamp:
- Jan 19, 2018, 6:51:35 PM (6 years ago)
- Location:
- CLIO/control
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
CLIO/control/CLIO_graphical_interface.py
r750 r754 74 74 #Scan variables 75 75 self.scanON=False 76 self.scanStart=4 50000076 self.scanStart=4000000 77 77 self.scanStop=5500000 78 self.scanStep= 1000078 self.scanStep=5000 79 79 self.scanNextStep=0 80 80 self.scanDuration=10 81 81 self.scanWaitUntil=0 82 82 self.motor_value_steps=-999 83 83 # canvas for image 84 84 self.canvas = Canvas(self.parent, width=800, height=800) … … 181 181 self.labelPositionCurrent.grid(row=3,column=2,columnspan=1) 182 182 183 buttonScanMotor = Button(self.frameMotors, text="Scan", command=self.onButtonScan)184 buttonScanMotor.grid(row=4,column=2)183 self.buttonScanMotor = Button(self.frameMotors, text="Scan", command=self.onButtonScan) 184 self.buttonScanMotor.grid(row=4,column=2) 185 185 186 186 #Check process status … … 268 268 imageNames[2]=self.latest_file_with_signal.replace(".sig","_signal.png") 269 269 imageNames[3]=self.latest_file_with_signal.replace(".sig","_amplitude.png") 270 imageNames[4]= "/var/www/html/CLIO/data_comparison.png"271 imageNames[5]= "/var/www/html/CLIO/data_comparison_with_reference.png"270 imageNames[4]=data_directory_base+'data_comparison.png' 271 imageNames[5]=data_directory_base+"data_comparison_with_reference.png" 272 272 time.sleep(0.1) 273 273 … … 279 279 self.imageLabel[iimage].image=self.newImage[iimage] 280 280 except: 281 time.sleep(0.1) 281 282 print("An error occurred while opening the image: "+imageNames[iimage]+" image "+str(iimage)) 282 283 time.sleep(0.1) 283 284 284 285 285 self.getMotorPosition() 286 286 #Check acquisition status … … 387 387 388 388 def getMotorPosition(self): 389 if (len(glob.glob(motor_position_info))==0): 390 print "Motor position file does not exist - wait 1s" 391 time.sleep(1) 392 389 393 if (len(glob.glob(motor_position_info))>0): 390 394 fid=open(motor_position_info,'r') … … 398 402 fid.close() 399 403 if key_values['motor_value']: 404 self.motor_value_steps=int(round(float(key_values['motor_value'].strip()))) 400 405 self.labelPositionStep.config(text=key_values['motor_value']+' stp'); 401 406 self.labelPositionStep.config(bg='green',fg='black'); … … 409 414 self.labelPositionCurrent.config(bg='red',fg='black'); 410 415 else: 416 print "Motor position file does not exist" 411 417 self.labelPositionCurrent.config(bg='blue',fg='white'); 412 418 self.labelPositionStep.config(bg='blue',fg='white'); … … 535 541 self.popup.destroy() 536 542 if (self.scanON): 543 self.pauseOn() 537 544 self.moveMotorAbsolute(self.scanStart) 538 545 self.scanNextStep=self.scanStart … … 541 548 def scanCheck(self): 542 549 if (self.scanON): 550 self.buttonScanMotor.config(bg='blue',fg='white',text='Scanning...') 543 551 print "Scan in progress" 552 print self.motor_value_steps 553 print self.scanNextStep 544 554 #Are we at the target position? 545 if (int((self.labelPositionStep.text[:-4]).strip())==self.scanNextStep): 546 #If yes, are we waiting 555 print self.motor_value_steps 556 if (self.motor_value_steps==int(self.scanNextStep)): 557 print "At position" 558 #If yes, are we waiting and taking data 547 559 if self.scanWaitUntil==0: 548 560 #No => wait 561 print "Start waiting..." 549 562 self.scanWaitUntil=time.time()+self.scanDuration 550 563 else: 551 564 #yes => did we finish waiting? 552 565 if (time.time()>self.scanWaitUntil): 566 print "Done waiting..." 553 567 #yes: Are we still below the last position? 554 568 if (self.scanNextStep<self.scanStop): 569 print "Next step..." 570 self.pauseOn() 555 571 self.scanNextStep=self.scanNextStep+self.scanStep 556 self.moveMotorAbsolute( self.scanNextStep)572 self.moveMotorAbsolute(int(self.scanNextStep)) 557 573 self.scanWaitUntil=0 558 574 else: 559 575 print "Scan finished" 576 self.pauseOn() 560 577 self.scanON=False 578 self.moveMotorAbsolute(self.scanStart) 561 579 else: 580 self.pauseOff() 562 581 print "Taking data..." 563 582 else: 583 #We should already be moving to the next step but just in case issue the command again 584 if ((self.refresh_loop%10)==0): 585 print "#We should already be moving to the next step but just in case issue the command again" 586 time.sleep(0.1) 587 self.moveMotorAbsolute(int(self.scanNextStep)) 588 self.scanWaitUntil=0 564 589 else: 565 print "No scan" 590 self.buttonScanMotor.config(bg='grey',fg='black',text='Scan') 591 #print "No scan" 566 592 567 593 def onButtonPower(self,value): … … 580 606 pause_file = glob.glob(FILE_PAUSE) 581 607 if (len(pause_file)==0): 582 filename=FILE_PAUSE 583 fid=open(filename,'w') 584 fid.write("pause") 585 fid.close() 608 self.pauseOn() 586 609 else: 610 self.pauseOff() 611 612 def pauseOn(self): 613 filename=FILE_PAUSE 614 fid=open(filename,'w') 615 fid.write("pause") 616 fid.close() 617 self.buttonAcqPause.config(text="*Paused*") 618 619 def pauseOff(self): 620 pause_file = glob.glob(FILE_PAUSE) 621 if (len(pause_file)>0): 587 622 os.remove(FILE_PAUSE) 588 589 623 self.buttonAcqPause.config(text="Pause") 624 590 625 #---------------- 591 626 def onButtonAcqStop(self): … … 597 632 def onButtonRef(self): 598 633 print "Set Ref "+ self.latest_file_with_signal 634 self.buttonSetRef.config(bg='red') 599 635 filename=FILE_REF 600 636 fid=open(filename,'w') 601 637 fid.write(self.latest_file_with_signal) 602 638 fid.close() 639 time.sleep(2.0) 640 self.buttonSetRef.config(bg='grey') 603 641 604 642 def onButtonCompare(self): 605 643 print "Compare "+ self.latest_file_with_signal 644 self.buttonSetCompare.config(bg='red') 606 645 filename=FILE_COMPARE 607 646 fid=open(filename,'a') … … 609 648 fid.write("\n") 610 649 fid.close() 650 time.sleep(2.0) 651 self.buttonSetCompare.config(bg='grey') 611 652 612 653 def onButtonClearCompare(self): -
CLIO/control/plot_compare.py
r748 r754 19 19 global FILE_COMPARE 20 20 global data_directory_base 21 22 23 print "Use plot several files instead" 24 exit -1 21 25 22 26 … … 61 65 plt.figure(1) 62 66 67 filenames=[] 68 69 with open(FILE_COMPARE) as cfid: 70 fname=cfid.readline().rstrip() 71 if (len(fname)==0): 72 fname=cfid.readline().rstrip() 73 fnameprev='' 74 while(len(fname)>0): 75 if (fname!=fnameprev): 76 print fname 77 filenames.append(fname) 78 fnameprev=fname 79 fname=cfid.readline().rstrip() 80 cfid.close() 81 82 print "Plotting" 83 63 84 dataref=load_reference_signal() 64 85 alldata=dataref 65 86 66 with open(FILE_COMPARE) as cfid: 67 fname=cfid.readline().rstrip() 68 while(len(fname)>0): 69 print fname 70 filedata=np.loadtxt(fname, comments='#', delimiter='\t', usecols=range(0,3)) 71 alldata=np.hstack((alldata,np.zeros((np.shape(alldata)[0],1),dtype=alldata.dtype))) 72 colref=np.shape(alldata)[1]-1 73 for angle in alldata[:,0]: 74 idx=list(alldata[:,0]).index(angle) 75 idxref=np.where(filedata == angle) 87 for fname in filenames: 88 print fname 89 filedata=np.loadtxt(fname, comments='#', delimiter='\t', usecols=range(0,3)) 90 alldata=np.hstack((alldata,np.zeros((np.shape(alldata)[0],1),dtype=alldata.dtype))) 91 colref=np.shape(alldata)[1]-1 92 for angle in alldata[:,0]: 93 idx=list(alldata[:,0]).index(angle) 94 idxref=np.where(filedata == angle) 95 if (len(idxref[0])==1): 76 96 alldata[idx,colref]=filedata[idxref[0],1] 77 97 78 79 plt.plot(alldata[:,0], alldata[:,colref],label=os.path.basename(fname).replace("data_CLIO_","").replace(".sig",""))80 plt.figure(2)81 plt.plot(alldata[:,0], alldata[:,colref]-alldata[:,1],label=os.path.basename(fname).replace("data_CLIO_","").replace(".sig",""))82 fname=cfid.readline().rstrip()98 plt.figure(1) 99 plt.plot(alldata[:,0], alldata[:,colref],label=(os.path.basename(fname).replace("data_CLIO_","").replace(".sig",""))[-8:]) 100 # plt.plot(alldata[:,0], alldata[:,colref],label=(os.path.basename(fname).replace("data_CLIO_","").replace(".sig",""))) 101 plt.figure(2) 102 plt.plot(alldata[:,0], alldata[:,colref]-alldata[:,1],label=os.path.basename(fname).replace("data_CLIO_","").replace(".sig","")[-8:]) 83 103 84 104 # ckey_values={} … … 91 111 # fid.close() 92 112 93 cfid.close()94 113 95 114 96 115 plt.figure(1) 97 plt.title('Comparison ')116 plt.title('Comparison of the selected data') 98 117 plt.ylabel('Signal amplitude [a.u.]') 99 118 plt.xlabel('Detector angle [deg.]') … … 105 124 106 125 plt.figure(2) 107 plt.title('Comparison (ref substracted)')126 plt.title('Comparison (reference substracted)') 108 127 plt.ylabel('Signal amplitude above reference [a.u.]') 109 128 plt.xlabel('Detector angle [deg.]') -
CLIO/control/plot_data_versus_position.py
r691 r754 17 17 from clio_constants import * 18 18 19 print "Use plot several files instead" 20 exit -1 21 22 print "Not working" 23 exit 24 19 25 filemask="data_CLIO*.sig" 20 26 list_of_files = glob.glob(data_directory+filemask) … … 23 29 irange=0 24 30 if irange==0: 25 data_start='1 8-42-00'26 data_end='1 9-05-53'27 comment='Tir E8 - 24MeV'31 data_start='11-50-00' 32 data_end='12-30-00' 33 comment='Tir XX - 37 MeV' 28 34 elif irange==1: 29 35 data_start='19-08-00' … … 32 38 33 39 nfiles=0 40 alldata=[] 34 41 for filename in list_of_files: 35 42 #print filename … … 38 45 if (((os.path.basename(filename)[21:29])>data_start)and((os.path.basename(filename)[21:29])<data_end)): 39 46 print os.path.basename(filename) 40 #print "File in range"41 filedata=np.loadtxt(filename)42 47 48 #read parameters 43 49 key_values={} 44 with open(filename .replace(".sig",".val"),'r') as fid:50 with open(filename,'r') as fid: 45 51 fileline=fid.readline() 46 while (len(fileline)>0) :47 entries=fileline.replace(' ','').replace('\n','').split('=')52 while (len(fileline)>0)and(fileline[0]=='#'): 53 entries=fileline.replace('#','').replace(' ','').replace('\n','').split('=') 48 54 key_values[entries[0]]=entries[1] 49 55 fileline=fid.readline() 50 56 fid.close() 57 58 for p in key_values: print p,'=', key_values[p] 59 60 filedata=np.loadtxt(filename, comments='#', delimiter='\t', usecols=range(0,3)) 61 if (len(alldata)==0): 62 alldata=filedata 63 else: 64 alldata=np.hstack((alldata,np.zeros((np.shape(alldata)[0],1),dtype=alldata.dtype))) 65 colref=np.shape(alldata)[1]-1 66 for angle in alldata[:,0]: 67 idx=list(alldata[:,0]).index(angle) 68 idxref=np.where(filedata == angle) 69 alldata[idx,colref]=filedata[idxref[0],1] 51 70 52 71 if (nfiles==0): -
CLIO/control/read_plot_data.py
r748 r754 197 197 198 198 plt.figure(1) 199 plt.title( key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value'])199 plt.title('Full data\n'+key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value']) 200 200 plt.ylabel('Signal amplitude [a.u.]') 201 201 plt.xlabel('Time [ms]') … … 222 222 if (electrons_found): 223 223 plt.figure(2) 224 plt.title( key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value'])224 plt.title('Zoom on electrons\n'+key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value']) 225 225 plt.ylabel('Signal amplitude [a.u] - pedestal removed') 226 226 plt.xlabel('Time [ms]') … … 248 248 plt.figure(3) 249 249 plt.plot(angles_sorted, Sig_mean,'r^-',label='Data') 250 refdata=load_reference_signal()250 (refdata,refname)=load_reference_signal() 251 251 if (len(refdata)>0): 252 252 # print refdata[:,0] 253 253 # print refdata[:,1] 254 plt.plot(refdata[:,0],refdata[:,1],'go:',label='Reference ')255 plt.title( key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value'])254 plt.plot(refdata[:,0],refdata[:,1],'go:',label='Reference '+refname[-12:-4]) 255 plt.title('Spectrum (with reference)\n'+key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value']) 256 256 plt.ylabel('Signal amplitude [a.u.]') 257 257 plt.xlabel('Detector angle [deg.]') … … 273 273 #print diffdata 274 274 plt.plot(diffdata[:,0], diffdata[:,1],'r^-') 275 plt.title(' Diff --- '+key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value'])275 plt.title('Spectrum (reference substracted)\n'+key_values['date']+ ' --- Motor value: '+key_values['motor_value']+ ' --- Current: '+key_values['current_value']) 276 276 plt.ylabel('Signal amplitude above reference [a.u.]') 277 277 plt.xlabel('Detector angle [deg.]') … … 344 344 allrefdata=np.loadtxt(refname, comments='#', delimiter='\t', usecols=range(0,3)) 345 345 # print allrefdata 346 return allrefdata346 return (allrefdata,refname) -
CLIO/control/run_acq.sh
r744 r754 11 11 rm /home/etalon-admin/acquisition_data/pause_acquisition 12 12 13 /home/etalon-admin/savedata/savedata_CLIO 13 /home/etalon-admin/savedata/savedata_CLIO_triggered 14 14 15 15 echo "To start the driver type" -
CLIO/control/run_makefile_recent.sh
r744 r754 14 14 cd ../`date +%Y%m%d` 15 15 cd - 16 sleep 516 sleep 1 17 17 done
Note: See TracChangeset
for help on using the changeset viewer.