コード例 #1
0
 def generateCorrelations(self,doDetrend=True):
     # auto correlation corefficient of u
     if doDetrend:
         ux=signal.detrend(self.ux());
         uy=signal.detrend(self.uy());
         uz=signal.detrend(self.uz());
         umag=signal.detrend(self.Umag());
     else:
         ux=self.ux();
         uy=self.uy();
         uz=self.uz();
         umag=self.Umag();
     #ux=ux[-samples:-1]
     #uy=uy[-samples:-1]
     #uz=uz[-samples:-1]
     self.data['r11'],self.data['taur11'] = tt.xcorr_fft(ux, maxlags=None, norm='coeff')
     self.data['r22'],self.data['taur22'] = tt.xcorr_fft(uy, maxlags=None, norm='coeff')
     self.data['r33'],self.data['taur33'] = tt.xcorr_fft(uz, maxlags=None, norm='coeff')
     self.data['r12'],self.data['taur12'] = tt.xcorr_fft(ux,y=uy, maxlags=None, norm='coeff')
     self.data['r13'],self.data['taur13'] = tt.xcorr_fft(ux,y=uz, maxlags=None, norm='coeff')
     self.data['r23'],self.data['taur23'] = tt.xcorr_fft(uy,y=uz, maxlags=None, norm='coeff')
     self.data['rmag'],self.data['taurmag'] = tt.xcorr_fft(umag, maxlags=None, norm='coeff')
     # auto correlation of u
     self.data['R11'],self.data['tauR11'] = tt.xcorr_fft(ux, maxlags=None, norm='biased')
     self.data['R22'],self.data['tauR22'] = tt.xcorr_fft(uy, maxlags=None, norm='biased')
     self.data['R33'],self.data['tauR33'] = tt.xcorr_fft(uz, maxlags=None, norm='biased')
コード例 #2
0
    def generateAutoCorrelations(self,doDetrend=True):
        # auto correlation corefficient of u
        if doDetrend:
            ux=signal.detrend(self.ux());
            uy=signal.detrend(self.uy());
            uz=signal.detrend(self.uz());
        else:
            ux=self.ux();
            uy=self.uy();
            uz=self.uz();

        self.data['r11'],self.data['taur11'] = tt.xcorr_fft(ux, maxlags=None, norm='coeff')
        self.data['r22'],self.data['taur22'] = tt.xcorr_fft(uy, maxlags=None, norm='coeff')
        self.data['r33'],self.data['taur33'] = tt.xcorr_fft(uz, maxlags=None, norm='coeff')
コード例 #3
0
 def generateCorrelations(self, doDetrend=True):
     # auto correlation corefficient of u
     if doDetrend:
         ux = signal.detrend(self.ux())
         uy = signal.detrend(self.uy())
         uz = signal.detrend(self.uz())
         umag = signal.detrend(self.Umag())
     else:
         ux = self.ux()
         uy = self.uy()
         uz = self.uz()
         umag = self.Umag()
     #ux=ux[-samples:-1]
     #uy=uy[-samples:-1]
     #uz=uz[-samples:-1]
     self.data['r11'], self.data['taur11'] = tt.xcorr_fft(ux,
                                                          maxlags=None,
                                                          norm='coeff')
     self.data['r22'], self.data['taur22'] = tt.xcorr_fft(uy,
                                                          maxlags=None,
                                                          norm='coeff')
     self.data['r33'], self.data['taur33'] = tt.xcorr_fft(uz,
                                                          maxlags=None,
                                                          norm='coeff')
     self.data['r12'], self.data['taur12'] = tt.xcorr_fft(ux,
                                                          y=uy,
                                                          maxlags=None,
                                                          norm='coeff')
     self.data['r13'], self.data['taur13'] = tt.xcorr_fft(ux,
                                                          y=uz,
                                                          maxlags=None,
                                                          norm='coeff')
     self.data['r23'], self.data['taur23'] = tt.xcorr_fft(uy,
                                                          y=uz,
                                                          maxlags=None,
                                                          norm='coeff')
     self.data['rmag'], self.data['taurmag'] = tt.xcorr_fft(umag,
                                                            maxlags=None,
                                                            norm='coeff')
     # auto correlation of u
     self.data['R11'], self.data['tauR11'] = tt.xcorr_fft(ux,
                                                          maxlags=None,
                                                          norm='biased')
     self.data['R22'], self.data['tauR22'] = tt.xcorr_fft(uy,
                                                          maxlags=None,
                                                          norm='biased')
     self.data['R33'], self.data['tauR33'] = tt.xcorr_fft(uz,
                                                          maxlags=None,
                                                          norm='biased')
コード例 #4
0
def corrVert(f1, f2=None, i_ref=0, j_ref=0, norm=True):
    '''
    Do the two point vertical correlation from a reference point
    pt(i_ref,j_ref). The field has dimension of NxM with T time realization.
    
    Arguments:
        *f1*: np.array of shape (T,N,M).
         In general, one of the fields (vx,vy or vz) of a 
         pyFlowStat.SurfaceTimeSeries object.
    
        *f2*: np.array of shape (T,N,M).
         Same as f1. If None, then f1 is used has second field. Default=None
         
        *i_ref*: python int.
         Vertical location of the horizontal line. Default=0
         
        *j_ref*: python int.
         Vertical location of the horizontal line. Default=0
         
        *Norm*: python bool.
         Normalization of the correlation. Default=True.
         
         
    Returns:
        *lags_l*: numpy array.
         Array of left/negative lags.
        
        *res_l*: numpy array.
         Array of left/negative results.
        
        *lags_r*: numpy array.
         Array of right/positive lags.
        
        *res_r*: numpy array.
         Array of right/positive results.       
    '''
    f1sum = np.sum(f1, axis=0)
    if f2 == None:
        f2 = f1
        f2sum = f1sum
    else:
        f2sum = np.sum(f2, axis=0)

    res = np.empty(f1[0].shape[0], dtype=float)
    res[:] = np.nan
    k, dx, dy = f1.shape
    for i in range(dx):
        if np.isnan(f1sum[i_ref, j_ref]) or np.isnan(f2sum[i_ref, j_ref]):
            res[i] = np.nan
        else:
            res[i] = tt.twoPointCorr(x=f1[:, i_ref, j_ref],
                                     y=f2[:, i, j_ref],
                                     norm=True)
    if norm == True:
        res = res / res[i_ref]
    res_l = res[:i_ref + 1][::-1]
    res_r = res[i_ref:]
    lags_l = np.arange(len(res_l))
    lags_r = np.arange(len(res_r))
    return lags_l, res_l, lags_r, res_r
コード例 #5
0
def corrVert(f1,f2=None,i_ref=0,j_ref=0,norm=True):
    '''
    Do the two point vertical correlation from a reference point
    pt(i_ref,j_ref). The field has dimension of NxM with T time realization.
    
    Arguments:
        *f1*: np.array of shape (T,N,M).
         In general, one of the fields (vx,vy or vz) of a 
         pyFlowStat.SurfaceTimeSeries object.
    
        *f2*: np.array of shape (T,N,M).
         Same as f1. If None, then f1 is used has second field. Default=None
         
        *i_ref*: python int.
         Vertical location of the horizontal line. Default=0
         
        *j_ref*: python int.
         Vertical location of the horizontal line. Default=0
         
        *Norm*: python bool.
         Normalization of the correlation. Default=True.
         
         
    Returns:
        *lags_l*: numpy array.
         Array of left/negative lags.
        
        *res_l*: numpy array.
         Array of left/negative results.
        
        *lags_r*: numpy array.
         Array of right/positive lags.
        
        *res_r*: numpy array.
         Array of right/positive results.       
    '''
    f1sum=np.sum(f1,axis=0)
    if f2==None:
        f2=f1
        f2sum=f1sum
    else:
        f2sum=np.sum(f2,axis=0)
    
    res=np.empty(f1[0].shape[0], dtype=float)
    res[:] = np.nan
    k,dx,dy=f1.shape
    for i in range(dx):
        if np.isnan(f1sum[i_ref,j_ref]) or np.isnan(f2sum[i_ref,j_ref]):
            res[i]=np.nan
        else:
            res[i]=tt.twoPointCorr(x=f1[:,i_ref,j_ref],y=f2[:,i,j_ref],norm=True)
    if norm==True:
        res=res/res[i_ref]
    res_l=res[:i_ref+1][::-1]
    res_r=res[i_ref:]
    lags_l=np.arange(len(res_l))
    lags_r=np.arange(len(res_r))
    return lags_l,res_l,lags_r,res_r
コード例 #6
0
    def generateAutoCorrelations(self, doDetrend=True):
        # auto correlation corefficient of u
        if doDetrend:
            ux = signal.detrend(self.ux())
            uy = signal.detrend(self.uy())
            uz = signal.detrend(self.uz())
        else:
            ux = self.ux()
            uy = self.uy()
            uz = self.uz()

        self.data['r11'], self.data['taur11'] = tt.xcorr_fft(ux,
                                                             maxlags=None,
                                                             norm='coeff')
        self.data['r22'], self.data['taur22'] = tt.xcorr_fft(uy,
                                                             maxlags=None,
                                                             norm='coeff')
        self.data['r33'], self.data['taur33'] = tt.xcorr_fft(uz,
                                                             maxlags=None,
                                                             norm='coeff')
コード例 #7
0
def fitExp(r11,maxlag=None):
    if maxlag==None:
        maxlag=len(r11)
    xdata=np.arange(len(r11[:maxlag]))
    ydata=np.array(r11[:maxlag])
    try:
        popt, pcov = tt.fit_exp_correlation(xdata,ydata)
        T=popt
    except RuntimeError:
        print("Error - curve_fit failed")
        T=0
    return T
コード例 #8
0
def fitExp(r11, maxlag=None):
    if maxlag == None:
        maxlag = len(r11)
    xdata = np.arange(len(r11[:maxlag]))
    ydata = np.array(r11[:maxlag])
    try:
        popt, pcov = tt.fit_exp_correlation(xdata, ydata)
        T = popt
    except RuntimeError:
        print("Error - curve_fit failed")
        T = 0
    return T
コード例 #9
0
 def generateSpectra(self, doDetrend=True):
     '''
     uifrq:  [numpy.array of shape=(?)] u1 in frequency domain. For i=1,2,3
     uiamp:  [numpy.array of shape=(?)] amplitude of u1 in frequency domain. For i=1,2,3
     Seiifrq:[numpy.array of shape=(?)] Frequencies for energy spectrum Seii. For i=1,2,3
     Seii:   [numpy.array of shape=(?)] Energy spectrum Seii derived from Rii. For i=1,2,3
     '''
     if doDetrend:
         ux = signal.detrend(self.ux())
         uy = signal.detrend(self.uy())
         uz = signal.detrend(self.uz())
     else:
         ux = self.ux()
         uy = self.uy()
         uz = self.uz()
     #u in frequency domain
     self.data['u1frq'], self.data['u1amp'] = tt.dofft(
         sig=ux, samplefrq=self.data['frq'])
     self.data['u2frq'], self.data['u2amp'] = tt.dofft(
         sig=uy, samplefrq=self.data['frq'])
     self.data['u3frq'], self.data['u3amp'] = tt.dofft(
         sig=uz, samplefrq=self.data['frq'])
     #Time energy sectrum Se11 (mean: Rii in frequency domain...)
     self.data['Se11frq'], self.data['Se11'] = tt.dofft(
         sig=self.data['R11'], samplefrq=self.data['frq'])
     self.data['Se22frq'], self.data['Se22'] = tt.dofft(
         sig=self.data['R22'], samplefrq=self.data['frq'])
     self.data['Se33frq'], self.data['Se33'] = tt.dofft(
         sig=self.data['R33'], samplefrq=self.data['frq'])
コード例 #10
0
def corrField(f1, f2=None, i_ref=0, j_ref=0, norm=True):
    '''
    Two point correlation of an entire field with the point pt(i_ref,j_ref) as
    reference. The field has the dimension of NxM with T time realization.
    
    Arguments:
        *f1*: np.array of shape (T,N,M).
         In general, one of the fields (vx,vy or vz) of a 
         pyFlowStat.SurfaceTimeSeries object.
    
        *f2*: np.array of shape (T,N,M).
         Same as f1. If None, then f1 is used has second field. Default=None
         
        *i_ref*: python int.
         Horizontal location of the reference point. Default=0
         
        *j_ref*: python int.
         Vertical location of the reference point. Default=0
         
        *Norm*: python bool.
         Normalization of the correlation. Default=True.
         
         
    Returns:
        *res*: np.array of shape (N,M).
         the two point horizontal correlation. 
    '''
    f1sum = np.sum(f1, axis=0)
    if f2 == None:
        f2 = f1
        f2sum = f1sum
    else:
        f2sum = np.sum(f2, axis=0)

    res = np.empty(f1[0].shape, dtype=float)
    res[:] = np.nan
    k, dx, dy = f1.shape
    if np.isnan(f1sum[i_ref, j_ref]):
        res[i_ref, j_ref] = np.nan
    else:
        for i in range(dx):
            for j in range(dy):
                if np.isnan(f2sum[i, j]):
                    res[i, j] = np.nan
                else:
                    res[i, j] = tt.twoPointCorr(x=f1[:, i_ref, j_ref],
                                                y=f2[:, i, j],
                                                norm=True)
    if norm == True:
        return res / res[i_ref, j_ref]
    else:
        return res
コード例 #11
0
def corrField(f1,f2=None,i_ref=0,j_ref=0,norm=True):
    '''
    Two point correlation of an entire field with the point pt(i_ref,j_ref) as
    reference. The field has the dimension of NxM with T time realization.
    
    Arguments:
        *f1*: np.array of shape (T,N,M).
         In general, one of the fields (vx,vy or vz) of a 
         pyFlowStat.SurfaceTimeSeries object.
    
        *f2*: np.array of shape (T,N,M).
         Same as f1. If None, then f1 is used has second field. Default=None
         
        *i_ref*: python int.
         Horizontal location of the reference point. Default=0
         
        *j_ref*: python int.
         Vertical location of the reference point. Default=0
         
        *Norm*: python bool.
         Normalization of the correlation. Default=True.
         
         
    Returns:
        *res*: np.array of shape (N,M).
         the two point horizontal correlation. 
    '''
    f1sum=np.sum(f1,axis=0)
    if f2==None:
        f2=f1
        f2sum=f1sum
    else:
        f2sum=np.sum(f2,axis=0)
        
    res=np.empty(f1[0].shape, dtype=float)
    res[:] = np.nan
    k,dx,dy=f1.shape
    if np.isnan(f1sum[i_ref,j_ref]):
        res[i_ref,j_ref] = np.nan
    else:
        for i in range(dx):
            for j in range(dy):
                if np.isnan(f2sum[i,j]):
                    res[i,j]=np.nan
                else:
                    res[i,j]=tt.twoPointCorr(x=f1[:,i_ref,j_ref],y=f2[:,i,j],norm=True)
    if norm==True:
        return res/res[i_ref,j_ref]
    else:
        return res
コード例 #12
0
ファイル: PointProbe.py プロジェクト: mparada/pyFlowStat
 def doAutoCorr(xkey,ykey,Tkey,Lkey=None,threshold=0.1):
     xdata=self.data[xkey]
     ydata=self.data[ykey]
     
     if checkAutoCorr(xdata,ydata,threshold=threshold):
         try:
             popt, pcov = tt.fit_exp_correlation(xdata,ydata)
             #self.data['Txx']=abs(popt[0])*np.sqrt(np.pi)*0.5*self.data['dt']
             self.data[Tkey]=popt[0]*self.data['dt']
             if Lkey:
                 self.data[Lkey]=self.data[Tkey]*self.Umean()
         except RuntimeError:
             print("Error - curve_fit failed")
             self.data[Tkey]=0
             if Lkey:
                 self.data[Lkey]=0
     else:
         self.data[Tkey]=0
         if Lkey:
             self.data[Lkey]=0
コード例 #13
0
 def generateSpectra(self,doDetrend=True):
     '''
     uifrq:  [numpy.array of shape=(?)] u1 in frequency domain. For i=1,2,3
     uiamp:  [numpy.array of shape=(?)] amplitude of u1 in frequency domain. For i=1,2,3
     Seiifrq:[numpy.array of shape=(?)] Frequencies for energy spectrum Seii. For i=1,2,3
     Seii:   [numpy.array of shape=(?)] Energy spectrum Seii derived from Rii. For i=1,2,3
     '''
     if doDetrend:
         ux=signal.detrend(self.ux());
         uy=signal.detrend(self.uy());
         uz=signal.detrend(self.uz());
     else:
         ux=self.ux();
         uy=self.uy();
         uz=self.uz();
     #u in frequency domain
     self.data['u1frq'],self.data['u1amp'] = tt.dofft(sig=ux,samplefrq=self.data['frq'])
     self.data['u2frq'],self.data['u2amp'] = tt.dofft(sig=uy,samplefrq=self.data['frq'])
     self.data['u3frq'],self.data['u3amp'] = tt.dofft(sig=uz,samplefrq=self.data['frq'])
     #Time energy sectrum Se11 (mean: Rii in frequency domain...)
     self.data['Se11frq'],self.data['Se11'] = tt.dofft(sig=self.data['R11'],samplefrq=self.data['frq'])
     self.data['Se22frq'],self.data['Se22'] = tt.dofft(sig=self.data['R22'],samplefrq=self.data['frq'])
     self.data['Se33frq'],self.data['Se33'] = tt.dofft(sig=self.data['R33'],samplefrq=self.data['frq'])
コード例 #14
0
ファイル: PointProbe.py プロジェクト: mparada/pyFlowStat
    def generateStatistics(self,doDetrend=True):
        '''
        Generates statistics and populates member variable data.

        Arguments:
            doDetrend: detrend data bevor sigbal processing

        Populates the "data" python dict with with the following keys:
            rii:    [numpy.array of shape=(?)] Auto-correlation coefficent rii. For i=1,2,3
            taurii: [numpy.array of shape=(?)] Time lags for rii. For i=1,2,3
            Rii:    [numpy.array of shape=(?)] Auto-correlation Rii. For i=1,2,3
            tauRii: [numpy.array of shape=(?)] Time lags for Rii. For i=1,2,3

            uifrq:  [numpy.array of shape=(?)] u1 in frequency domain. For i=1,2,3
            uiamp:  [numpy.array of shape=(?)] amplitude of u1 in frequency domain. For i=1,2,3
            Seiifrq:[numpy.array of shape=(?)] Frequencies for energy spectrum Seii. For i=1,2,3
            Seii:   [numpy.array of shape=(?)] Energy spectrum Seii derived from Rii. For i=1,2,3
        '''
        # auto correlation corefficient of u
        if doDetrend:
            ux=signal.detrend(self.ux());
            uy=signal.detrend(self.uy());
            uz=signal.detrend(self.uz());
            umag=signal.detrend(self.Umag());
        else:
            ux=self.ux();
            uy=self.uy();
            uz=self.uz();
            umag=self.Umag();
        #ux=ux[-samples:-1]
        #uy=uy[-samples:-1]
        #uz=uz[-samples:-1]
        self.data['r11'],self.data['taur11'] = tt.xcorr_fft(ux, maxlags=None, norm='coeff')
        self.data['r22'],self.data['taur22'] = tt.xcorr_fft(uy, maxlags=None, norm='coeff')
        self.data['r33'],self.data['taur33'] = tt.xcorr_fft(uz, maxlags=None, norm='coeff')
        self.data['r12'],self.data['taur12'] = tt.xcorr_fft(ux,y=uy, maxlags=None, norm='coeff')
        self.data['r13'],self.data['taur13'] = tt.xcorr_fft(ux,y=uz, maxlags=None, norm='coeff')
        self.data['r23'],self.data['taur23'] = tt.xcorr_fft(uy,y=uz, maxlags=None, norm='coeff')
        self.data['rmag'],self.data['taurmag'] = tt.xcorr_fft(umag, maxlags=None, norm='coeff')
        # auto correlation of u
        self.data['R11'],self.data['tauR11'] = tt.xcorr_fft(ux, maxlags=None, norm='none')
        self.data['R22'],self.data['tauR22'] = tt.xcorr_fft(uy, maxlags=None, norm='none')
        self.data['R33'],self.data['tauR33'] = tt.xcorr_fft(uz, maxlags=None, norm='none')


        #u in frequency domain
        self.data['u1frq'],self.data['u1amp'] = tt.dofft(sig=ux,samplefrq=self.data['frq'])
        self.data['u2frq'],self.data['u2amp'] = tt.dofft(sig=uy,samplefrq=self.data['frq'])
        self.data['u3frq'],self.data['u3amp'] = tt.dofft(sig=uz,samplefrq=self.data['frq'])
        #Time energy sectrum Se11 (mean: Rii in frequency domain...)
        self.data['Se11frq'],self.data['Se11'] = tt.dofft(sig=self.data['R11'],samplefrq=self.data['frq'])
        self.data['Se22frq'],self.data['Se22'] = tt.dofft(sig=self.data['R22'],samplefrq=self.data['frq'])
        self.data['Se33frq'],self.data['Se33'] = tt.dofft(sig=self.data['R33'],samplefrq=self.data['frq'])