Exemplo n.º 1
0
def cs_contrib(a,b,bins,subsamp=10):
    from metobs.generic import get_dims
    '''
a,b: raw time series (not perturbations)

Compute the contribution of coherent structures to the total flux of a'b'.

bins: list of arrays that contain N.arange(start_index,stop_index) for CS events
      the list is returned from metobs.vis.wavelet_plt() as the first member.

subsamp: number of samples in original time series for each sample in subsampled
timeseres (if timeseries was subsampled to calculate wavelet).
    '''
    sensors,obs,blks=get_dims(a,b)
    a=a.reshape((sensors,obs,blks))
    b=a.reshape((sensors,obs,blks))
    cohf_n=[]
    tcoh=[]
    ap=get_pert(a)
    bp=get_pert(b)
    for i in range(0,len(bins[0])):
        tcoh.append(len(bins[0][i])*subsamp)
        cohf_n.append(tcoh[i]*N.average(
                   ap[0,bins[0][i][0]*subsamp:bins[0][i][-1]*subsamp+subsamp-1,0]*
                   bp[0,bins[0][i][0]*subsamp:bins[0][i][-1]*subsamp+subsamp-1,0]))
        
    F_coh=N.array(cohf_n).squeeze().sum()/(a.shape[1]*turb_covar(a[0,:,0],b[0,:,0]))
    TE=F_coh/((1./a.shape[1])*N.array(tcoh).sum())
    return (F_coh,TE,tcoh)
Exemplo n.º 2
0
def tke(u, v, w):
    '''
Compute the turbulence kinetic energy from the time series of the velocity \
components u,v, and w.
    '''
    ax = 1

    up = get_pert(u)
    vp = get_pert(v)
    wp = get_pert(w)

    tke = N.power(N.average(N.power(up,2),axis=ax)+\
                  N.average(N.power(vp,2),axis=ax)+\
                  N.average(N.power(wp,2),axis=ax),0.5)

    return tke
Exemplo n.º 3
0
def tke(u,v,w):
    '''
Compute the turbulence kinetic energy from the time series of the velocity \
components u,v, and w.
    '''
    ax=1

    up = get_pert(u)
    vp = get_pert(v)
    wp = get_pert(w)

    tke = N.power(N.average(N.power(up,2),axis=ax)+\
                  N.average(N.power(vp,2),axis=ax)+\
                  N.average(N.power(wp,2),axis=ax),0.5)

    return tke
Exemplo n.º 4
0
def kurtosis(a):
    '''
Compute the kurtosis of the timeseries a
    '''
    ax = 1

    ap = get_pert(a)
    K = N.average(N.power(ap, 4), axis=ax) / N.power(N.std(ap), 4)

    return K
Exemplo n.º 5
0
def skewness(a):
    '''
Compute the skewness of the timeseries a
    '''
    ax = 1

    ap = get_pert(a)
    S = N.average(N.power(ap, 3), axis=ax) / N.power(N.std(ap), 3)

    return S
Exemplo n.º 6
0
def kurtosis(a):
    '''
Compute the kurtosis of the timeseries a
    '''
    ax=1

    ap = get_pert(a)
    K = N.average(N.power(ap,4),axis=ax)/N.power(N.std(ap),4)

    return K
Exemplo n.º 7
0
def skewness(a):
    '''
Compute the skewness of the timeseries a
    '''
    ax = 1

    ap = get_pert(a)
    S = N.average(N.power(ap,3),axis=ax)/N.power(N.std(ap),3)

    return S