Changeset 754 in ETALON


Ignore:
Timestamp:
Jan 19, 2018, 6:51:35 PM (6 years ago)
Author:
delerue
Message:

Graphical interface updated

Location:
CLIO/control
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • CLIO/control/CLIO_graphical_interface.py

    r750 r754  
    7474        #Scan variables
    7575        self.scanON=False
    76         self.scanStart=4500000
     76        self.scanStart=4000000
    7777        self.scanStop=5500000
    78         self.scanStep=10000
     78        self.scanStep=5000
    7979        self.scanNextStep=0
    8080        self.scanDuration=10
    8181        self.scanWaitUntil=0
    82        
     82        self.motor_value_steps=-999       
    8383        # canvas for image
    8484        self.canvas = Canvas(self.parent, width=800, height=800)
     
    181181        self.labelPositionCurrent.grid(row=3,column=2,columnspan=1)
    182182
    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)
    185185       
    186186        #Check process status
     
    268268            imageNames[2]=self.latest_file_with_signal.replace(".sig","_signal.png")
    269269            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"
    272272            time.sleep(0.1)
    273273
     
    279279                    self.imageLabel[iimage].image=self.newImage[iimage]
    280280                except:
     281                    time.sleep(0.1)
    281282                    print("An error occurred while opening the image: "+imageNames[iimage]+" image "+str(iimage))
    282283                time.sleep(0.1)
    283284
    284        
    285285        self.getMotorPosition()
    286286        #Check acquisition status
     
    387387           
    388388    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           
    389393        if (len(glob.glob(motor_position_info))>0):
    390394            fid=open(motor_position_info,'r')
     
    398402            fid.close()
    399403            if key_values['motor_value']:
     404                self.motor_value_steps=int(round(float(key_values['motor_value'].strip())))
    400405                self.labelPositionStep.config(text=key_values['motor_value']+' stp');
    401406                self.labelPositionStep.config(bg='green',fg='black');
     
    409414                self.labelPositionCurrent.config(bg='red',fg='black');
    410415        else:
     416            print "Motor position file does not exist"
    411417            self.labelPositionCurrent.config(bg='blue',fg='white');
    412418            self.labelPositionStep.config(bg='blue',fg='white');
     
    535541        self.popup.destroy()
    536542        if (self.scanON):
     543            self.pauseOn()
    537544            self.moveMotorAbsolute(self.scanStart)
    538545            self.scanNextStep=self.scanStart
     
    541548    def scanCheck(self):
    542549        if (self.scanON):
     550            self.buttonScanMotor.config(bg='blue',fg='white',text='Scanning...')
    543551            print "Scan in progress"
     552            print self.motor_value_steps
     553            print self.scanNextStep
    544554            #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
    547559                if self.scanWaitUntil==0:
    548560                    #No => wait
     561                    print "Start waiting..."
    549562                    self.scanWaitUntil=time.time()+self.scanDuration
    550563                else:
    551564                    #yes => did we finish waiting?
    552565                    if (time.time()>self.scanWaitUntil):
     566                        print "Done waiting..."
    553567                        #yes: Are we still below the last position?
    554568                        if (self.scanNextStep<self.scanStop):
     569                            print "Next step..."
     570                            self.pauseOn()
    555571                            self.scanNextStep=self.scanNextStep+self.scanStep
    556                             self.moveMotorAbsolute(self.scanNextStep)
     572                            self.moveMotorAbsolute(int(self.scanNextStep))
    557573                            self.scanWaitUntil=0
    558574                        else:
    559575                            print "Scan finished"
     576                            self.pauseOn()
    560577                            self.scanON=False
     578                            self.moveMotorAbsolute(self.scanStart)
    561579                    else:
     580                        self.pauseOff()
    562581                        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
    564589        else:
    565             print "No scan"
     590            self.buttonScanMotor.config(bg='grey',fg='black',text='Scan')
     591            #print "No scan"
    566592           
    567593    def onButtonPower(self,value):
     
    580606        pause_file = glob.glob(FILE_PAUSE)
    581607        if (len(pause_file)==0):
    582             filename=FILE_PAUSE
    583             fid=open(filename,'w')
    584             fid.write("pause")
    585             fid.close()
     608            self.pauseOn()
    586609        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):
    587622            os.remove(FILE_PAUSE)
    588             self.buttonAcqPause.config(text="Pause")
    589 
     623        self.buttonAcqPause.config(text="Pause")
     624       
    590625    #----------------
    591626    def onButtonAcqStop(self):
     
    597632    def onButtonRef(self):
    598633        print "Set Ref "+ self.latest_file_with_signal
     634        self.buttonSetRef.config(bg='red')
    599635        filename=FILE_REF
    600636        fid=open(filename,'w')
    601637        fid.write(self.latest_file_with_signal)
    602638        fid.close()
     639        time.sleep(2.0)
     640        self.buttonSetRef.config(bg='grey')
    603641       
    604642    def onButtonCompare(self):
    605643        print "Compare "+ self.latest_file_with_signal
     644        self.buttonSetCompare.config(bg='red')
    606645        filename=FILE_COMPARE
    607646        fid=open(filename,'a')
     
    609648        fid.write("\n")
    610649        fid.close()
     650        time.sleep(2.0)
     651        self.buttonSetCompare.config(bg='grey')
    611652
    612653    def onButtonClearCompare(self):
  • CLIO/control/plot_compare.py

    r748 r754  
    1919global FILE_COMPARE
    2020global data_directory_base
     21
     22
     23print "Use plot several files instead"
     24exit -1
    2125
    2226
     
    6165plt.figure(1)
    6266
     67filenames=[]
     68
     69with 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()
     80cfid.close()
     81
     82print "Plotting"
     83
    6384dataref=load_reference_signal()
    6485alldata=dataref
    6586
    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)
     87for 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):
    7696            alldata[idx,colref]=filedata[idxref[0],1]
    7797           
    78         plt.figure(1)
    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:])
    83103
    84104#    ckey_values={}
     
    91111#        fid.close()                       
    92112
    93 cfid.close()
    94113
    95114
    96115plt.figure(1)
    97 plt.title('Comparison')
     116plt.title('Comparison of the selected data')
    98117plt.ylabel('Signal amplitude [a.u.]')
    99118plt.xlabel('Detector angle [deg.]')
     
    105124
    106125plt.figure(2)
    107 plt.title('Comparison (ref substracted)')
     126plt.title('Comparison (reference substracted)')
    108127plt.ylabel('Signal amplitude above reference [a.u.]')
    109128plt.xlabel('Detector angle [deg.]')
  • CLIO/control/plot_data_versus_position.py

    r691 r754  
    1717from clio_constants import *
    1818
     19print "Use plot several files instead"
     20exit -1
     21
     22print "Not working"
     23exit
     24
    1925filemask="data_CLIO*.sig"
    2026list_of_files = glob.glob(data_directory+filemask)
     
    2329irange=0
    2430if irange==0:
    25     data_start='18-42-00'
    26     data_end='19-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'
    2834elif irange==1:
    2935    data_start='19-08-00'
     
    3238
    3339nfiles=0
     40alldata=[]
    3441for filename in list_of_files:
    3542    #print filename
     
    3845    if (((os.path.basename(filename)[21:29])>data_start)and((os.path.basename(filename)[21:29])<data_end)):
    3946        print os.path.basename(filename)
    40         #print "File in range"
    41         filedata=np.loadtxt(filename)
    4247
     48        #read parameters   
    4349        key_values={}
    44         with open(filename.replace(".sig",".val"),'r') as fid:
     50        with open(filename,'r') as fid:
    4551            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('=')
    4854                key_values[entries[0]]=entries[1]
    4955                fileline=fid.readline()
    5056        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]
    5170
    5271        if (nfiles==0):
  • CLIO/control/read_plot_data.py

    r748 r754  
    197197           
    198198    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'])
    200200    plt.ylabel('Signal amplitude [a.u.]')
    201201    plt.xlabel('Time [ms]')
     
    222222    if (electrons_found):
    223223        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'])
    225225        plt.ylabel('Signal amplitude [a.u] - pedestal removed')
    226226        plt.xlabel('Time [ms]')
     
    248248        plt.figure(3)
    249249        plt.plot(angles_sorted, Sig_mean,'r^-',label='Data')
    250         refdata=load_reference_signal()
     250        (refdata,refname)=load_reference_signal()       
    251251        if (len(refdata)>0):
    252252#            print refdata[:,0]
    253253#            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'])
    256256        plt.ylabel('Signal amplitude [a.u.]')
    257257        plt.xlabel('Detector angle [deg.]')
     
    273273            #print diffdata
    274274            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'])
    276276            plt.ylabel('Signal amplitude above reference [a.u.]')
    277277            plt.xlabel('Detector angle [deg.]')
     
    344344        allrefdata=np.loadtxt(refname, comments='#', delimiter='\t', usecols=range(0,3))
    345345#        print allrefdata
    346         return allrefdata
     346        return (allrefdata,refname)
  • CLIO/control/run_acq.sh

    r744 r754  
    1111rm /home/etalon-admin/acquisition_data/pause_acquisition
    1212
    13 /home/etalon-admin/savedata/savedata_CLIO 
     13/home/etalon-admin/savedata/savedata_CLIO_triggered
    1414
    1515echo "To start the driver type"
  • CLIO/control/run_makefile_recent.sh

    r744 r754  
    1414    cd ../`date  +%Y%m%d`
    1515    cd -
    16     sleep 5
     16    sleep 1
    1717done
Note: See TracChangeset for help on using the changeset viewer.