Exemplo n.º 1
0
 def _get_trace_and_maxc(self, sid,fs=None,nf=None ):
     
     from Get_Data import readframe_series
     from XPCS_Functions import get_trace_and_maxc
     imgs = readframe_series( sid, inDir )
     print ('Doing trace analysis for sid_%s with %s frames'%(sid,noframes ))
     trace, max_cts = get_trace_and_maxc(imgs,self.pixellist,self.qind,fs,nf)        
     return trace,max_cts
Exemplo n.º 2
0
    def _get_trace_and_maxc(self, sid, fs=None, nf=None):

        from Get_Data import readframe_series
        from XPCS_Functions import get_trace_and_maxc
        imgs = readframe_series(sid, inDir)
        print('Doing trace analysis for sid_%s with %s frames' %
              (sid, noframes))
        trace, max_cts = get_trace_and_maxc(imgs, self.pixellist, self.qind,
                                            fs, nf)
        return trace, max_cts
Exemplo n.º 3
0
    def __init__(self,):
        """ DOCUMENT __init__(   )
        the initilization of the XPCS class
          """
        from Get_Data import readframe_series
        from XPCS_Functions import make_qlist,calqlist
        #from Setup_file import qstart,qend,qwidth,noqs,sid, inDir 
	#from Setup_file import dimx,dimy,cenx,ceny, mask

        self.version='version_1'
        self.create_time='Octa_18_2015'
        self.author='Yugang_Zhang_chx11id_nsls2_BNL'
        self.email='*****@*****.**'
        self.email2='*****@*****.**'
        
        self.data = readframe_series( sid, inDir   ) #read data with sid, and bg_id
        self.qlist,self.qradi = make_qlist(qstart,qend,qwidth,noqs)
        self.pixellist,self.qind,self.nopr,self.nopixels = calqlist(
            self.qlist,self.qradi, dimx,dimy,
                        cenx,ceny,qmask=mask)
        if min(self.qind)!=0:print ('The qmin is too small!')
Exemplo n.º 4
0
    def __init__(self, ):
        """ DOCUMENT __init__(   )
        the initilization of the XPCS class
          """
        from Get_Data import readframe_series
        from XPCS_Functions import make_qlist, calqlist
        #from Setup_file import qstart,qend,qwidth,noqs,sid, inDir
        #from Setup_file import dimx,dimy,cenx,ceny, mask

        self.version = 'version_1'
        self.create_time = 'Octa_18_2015'
        self.author = 'Yugang_Zhang_chx11id_nsls2_BNL'
        self.email = '*****@*****.**'
        self.email2 = '*****@*****.**'

        self.data = readframe_series(sid,
                                     inDir)  #read data with sid, and bg_id
        self.qlist, self.qradi = make_qlist(qstart, qend, qwidth, noqs)
        self.pixellist, self.qind, self.nopr, self.nopixels = calqlist(
            self.qlist, self.qradi, dimx, dimy, cenx, ceny, qmask=mask)
        if min(self.qind) != 0: print('The qmin is too small!')
Exemplo n.º 5
0
    def XSVS_Single( self, sid,  expose_time = 1.0, maxcts = 50,
            do_bining = True,timebin = 2,timebin_level=None):

        '''sid:   give the sample name/folder 
           qRings:  a pixel list for different qs
           maxcts: the max counts for the lowest exposure time
           bins:
              if True, bin the images; bin number is timebines,
                       timebin_level gives the max level for bin
              if Flase: just do histgram for the images

          Return: expose time: a list with length as timebin_level 
                  Bins: for each expose time, each Qs, shaped as [time_lev, Qs]
                  Histrogram_3D_Matrix: a histrogram, shaped as [time_lev, Qs]
                  HistStddev_all: a deviation of histrogram, shaped as [time_lev, Qs]
           
        '''
        from Get_Data import readframe_series        
        img = readframe_series( sid, inDir )
        N = len(img)
        
	
        if noframes>N:noframes_=N
        else:noframes_=noframes
        
        qRings = self.qRings        
        if do_bining:        
            if timebin_level is None:
                timebin_level = int( np.log( noframes  )/np.log(2)) #  +1            
            time_list = [ 2**i for i in range(timebin_level)]
        else:
            timebin_level = 1
            time_list = [  expose_time ]
            
        Bins =  np.zeros([timebin_level,noqs],dtype=object)        #GlobalPDFArray_all  is the Histrogram_3D_Matrix
        Histrogram_3D_Matrix = np.zeros([timebin_level,noqs],dtype=object)

        Histrogram2_3D_Matrix = np.zeros([timebin_level,noqs],dtype=object)
        #this function is to calculate the deviation of histrogram        

        BinEdges = np.arange( maxcts )
        #print BinEdges

	#print img      
        for i,n in enumerate(time_list):
            for j in range(noqs): 
                Bins[ i,j ]=  np.arange( maxcts * time_list[i] )
        ###########################################################
     
        print ('Running sample---%s'%(sid))
        print ('Doing histrogram for %s frames'%noframes_         )
        buf=np.zeros([ timebin_level, timebin], dtype=object)  #// matrix of buffers
        cts=np.zeros(timebin_level)
        cur=np.ones(timebin_level) * timebin
        num= np.array(np.zeros(  timebin_level ),dtype='int')

        ###############################################
        #the loop for process of each frame
        #print noframes_,noframes
        for n in range(1,noframes_ +1 ):
            #print n+ begframe-1,
            cur[0]=1+cur[0]%timebin                       
            ifg =  img[ n + begframe-1 ].ravel()           
            ifg[ (np.where(ifg<0))[0] ]=0
            buf[0, cur[0]-1 ]= np.array( ifg, dtype=float)    
            #img=[] #//save space                
            #self.process(lev=0, bufno=cur[0]-1 )                
            self.process(0,cur[0]-1, buf, num, qRings, Bins[ 0,0 ],
                        Histrogram2_3D_Matrix,Histrogram_3D_Matrix)
            
            processing=1        
            lev=1                
            #print cts
            if do_bining==False:processing = 0
            while processing: 
                if cts[lev]:
                    prev=  1+ (cur[lev-1]-1-1+nobuf)%timebin
                    cur[lev]=  1+ cur[lev]%timebin
                    buf[lev,cur[lev]-1] = (
                        buf[lev-1,prev-1] + buf[lev-1,cur[lev-1]-1] ) #/2.
                    cts[lev]=0                 
                    #self.process(lev= lev, bufno= cur[lev]-1 , n=n)
                    self.process(lev,cur[lev]-1, buf, num, qRings, Bins[ lev,0 ],
                                Histrogram2_3D_Matrix,Histrogram_3D_Matrix)                        
                    lev+=1
                    if lev<timebin_level:processing = 1
                    else:processing = 0                                
                else:
                    
                    cts[lev]=1      #// set flag to process next time
                    processing=0    #// can stop until more images are accumulated

            if isnan( Histrogram_3D_Matrix[0,0][0] ):
                print (n)
 
        HistStddev_all = np.power( ( Histrogram2_3D_Matrix  -
                            np.power(Histrogram_3D_Matrix ,2)), .5)  
        #expost = time_list
        self.time_list = np.array( time_list ) *expose_time
        self.timebin_level=timebin_level
        self.noframes = noframes
        return  Bins, Histrogram_3D_Matrix, HistStddev_all
Exemplo n.º 6
0
    def XSVS_Single(self,
                    sid,
                    expose_time=1.0,
                    maxcts=50,
                    do_bining=True,
                    timebin=2,
                    timebin_level=None):
        '''sid:   give the sample name/folder 
           qRings:  a pixel list for different qs
           maxcts: the max counts for the lowest exposure time
           bins:
              if True, bin the images; bin number is timebines,
                       timebin_level gives the max level for bin
              if Flase: just do histgram for the images

          Return: expose time: a list with length as timebin_level 
                  Bins: for each expose time, each Qs, shaped as [time_lev, Qs]
                  Histrogram_3D_Matrix: a histrogram, shaped as [time_lev, Qs]
                  HistStddev_all: a deviation of histrogram, shaped as [time_lev, Qs]
           
        '''
        from Get_Data import readframe_series
        img = readframe_series(sid, inDir)
        N = len(img)

        if noframes > N: noframes_ = N
        else: noframes_ = noframes

        qRings = self.qRings
        if do_bining:
            if timebin_level is None:
                timebin_level = int(np.log(noframes) / np.log(2))  #  +1
            time_list = [2**i for i in range(timebin_level)]
        else:
            timebin_level = 1
            time_list = [expose_time]

        Bins = np.zeros(
            [timebin_level, noqs],
            dtype=object)  #GlobalPDFArray_all  is the Histrogram_3D_Matrix
        Histrogram_3D_Matrix = np.zeros([timebin_level, noqs], dtype=object)

        Histrogram2_3D_Matrix = np.zeros([timebin_level, noqs], dtype=object)
        #this function is to calculate the deviation of histrogram

        BinEdges = np.arange(maxcts)
        #print BinEdges

        #print img
        for i, n in enumerate(time_list):
            for j in range(noqs):
                Bins[i, j] = np.arange(maxcts * time_list[i])
        ###########################################################

        print('Running sample---%s' % (sid))
        print('Doing histrogram for %s frames' % noframes_)
        buf = np.zeros([timebin_level, timebin],
                       dtype=object)  #// matrix of buffers
        cts = np.zeros(timebin_level)
        cur = np.ones(timebin_level) * timebin
        num = np.array(np.zeros(timebin_level), dtype='int')

        ###############################################
        #the loop for process of each frame
        #print noframes_,noframes
        for n in range(1, noframes_ + 1):
            #print n+ begframe-1,
            cur[0] = 1 + cur[0] % timebin
            ifg = img[n + begframe - 1].ravel()
            ifg[(np.where(ifg < 0))[0]] = 0
            buf[0, cur[0] - 1] = np.array(ifg, dtype=float)
            #img=[] #//save space
            #self.process(lev=0, bufno=cur[0]-1 )
            self.process(0, cur[0] - 1, buf, num, qRings, Bins[0, 0],
                         Histrogram2_3D_Matrix, Histrogram_3D_Matrix)

            processing = 1
            lev = 1
            #print cts
            if do_bining == False: processing = 0
            while processing:
                if cts[lev]:
                    prev = 1 + (cur[lev - 1] - 1 - 1 + nobuf) % timebin
                    cur[lev] = 1 + cur[lev] % timebin
                    buf[lev,
                        cur[lev] - 1] = (buf[lev - 1, prev - 1] +
                                         buf[lev - 1, cur[lev - 1] - 1])  #/2.
                    cts[lev] = 0
                    #self.process(lev= lev, bufno= cur[lev]-1 , n=n)
                    self.process(lev, cur[lev] - 1, buf, num, qRings, Bins[lev,
                                                                           0],
                                 Histrogram2_3D_Matrix, Histrogram_3D_Matrix)
                    lev += 1
                    if lev < timebin_level: processing = 1
                    else: processing = 0
                else:

                    cts[lev] = 1  #// set flag to process next time
                    processing = 0  #// can stop until more images are accumulated

            if isnan(Histrogram_3D_Matrix[0, 0][0]):
                print(n)

        HistStddev_all = np.power(
            (Histrogram2_3D_Matrix - np.power(Histrogram_3D_Matrix, 2)), .5)
        #expost = time_list
        self.time_list = np.array(time_list) * expose_time
        self.timebin_level = timebin_level
        self.noframes = noframes
        return Bins, Histrogram_3D_Matrix, HistStddev_all