Example #1
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
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
Example #3
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
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