Ejemplo n.º 1
0
def plotvel(geofil,
            fil,
            xstart,
            xend,
            ystart,
            yend,
            zs,
            ze,
            meanax,
            twa=True,
            savfil=None,
            loop=True):
    datau, datav = extractvel(geofil, fil, xstart, xend, ystart, yend, zs, ze,
                              meanax, twa, loop)
    plt.figure()
    ax = plt.subplot(3, 2, 1)
    im = m6plot(datau, ax, xlab='x from EB (Deg)', ylab='z (m)')
    im2 = plt.contour(datau[0], datau[1], datau[3], 1, colors='k')

    ax = plt.subplot(3, 2, 2)
    im = m6plot(datav, ax, xlab='x from EB (Deg)', ylab='z (m)')
    im2 = plt.contour(datav[0], datav[1], datav[3], 1, colors='k')
    ax.set_yticklabels([])

    if savfil:
        plt.savefig(savfil + '.eps',
                    dpi=300,
                    facecolor='w',
                    edgecolor='w',
                    format='eps',
                    transparent=False,
                    bbox_inches='tight')
    else:
        plt.show()
def plot_twamomx(geofil,fil,xstart,xend,ystart,yend,zs,ze,meanax,
        savfil1=None,savfil2=None,alreadysaved=False):
    X,Y,P = extract_twamomx_terms(geofil,fil,xstart,xend,ystart,yend,zs,ze,meanax,
            alreadysaved)
    cmax = np.nanmax(np.absolute(P))
    plt.figure()
    ti = ['(a)','(b)','(c)','(d)','(e)','(f)']
    for i in range(P.shape[-1]):
        ax = plt.subplot(3,2,i+1)
        im = m6plot((X,Y,P[:,:,i]),ax,Zmax=cmax,titl=ti[i])
        if i % 2:
            ax.set_yticklabels([])
        else:
            plt.ylabel('z (m)')

        if i > 3:
            plt.xlabel('x from EB (Deg)')
        else:
            ax.set_xticklabels([])
    
    if savfil1:
        plt.savefig(savfil1+'.eps', dpi=300, facecolor='w', edgecolor='w', 
                    format='eps', transparent=False, bbox_inches='tight')
    else:
        im = m6plot((X,Y,np.sum(P,axis=2)),Zmax=cmax)
        plt.show()

    P1 = np.concatenate((P[:,:,0:2],np.sum(P[:,:,2:4],axis=2,keepdims=True)
        ,P[:,:,4:]),axis=2)
    cmax = np.nanmax(np.absolute(P1))
    plt.figure()
    ti = ['(a)','(b)','(c)','(d)','(e)']
    for i in range(P1.shape[-1]):
        ax = plt.subplot(3,2,i+1)
        im = m6plot((X,Y,P1[:,:,i]),ax,Zmax=cmax,titl=ti[i])
        if i % 2:
            ax.set_yticklabels([])
        else:
            plt.ylabel('z (m)')

        if i > 3:
            plt.xlabel('x from EB (Deg)')
        else:
            ax.set_xticklabels([])
    
    if savfil2:
        plt.savefig(savfil2+'.eps', dpi=300, facecolor='w', edgecolor='w', 
                    format='eps', transparent=False, bbox_inches='tight')
    else:
        im = m6plot((X,Y,np.sum(P1,axis=2)),Zmax=cmax)
        plt.show()
Ejemplo n.º 3
0
def plot_pv(geofil,
            fil,
            xstart,
            xend,
            ystart,
            yend,
            zs,
            ze,
            meanax,
            savfil=None,
            alreadysaved=False):
    X, Y, P = extract_pvterms(geofil, fil, xstart, xend, ystart, yend, zs, ze,
                              meanax, alreadysaved)
    cmax = np.nanmax(np.absolute(P))
    plt.figure()
    ti = ['(a)', '(b)', '(c)', '(d)', '(e)', '(f)', '(g)']
    for i in range(P.shape[-1]):
        ax = plt.subplot(4, 2, i + 1)
        im = m6plot((X, Y, P[:, :, i]), ax, Zmax=cmax, titl=ti[i])
        if i % 2:
            ax.set_yticklabels([])
        else:
            plt.ylabel('z (m)')

        if i > 5:
            plt.xlabel('x from EB (Deg)')
        else:
            ax.set_xticklabels([])

    if savfil:
        plt.savefig(savfil + '.eps',
                    dpi=300,
                    facecolor='w',
                    edgecolor='w',
                    format='eps',
                    transparent=False,
                    bbox_inches='tight')
    else:
        im = m6plot((X, Y, np.sum(P, axis=2)), Zmax=cmax)
        plt.show()
def plot_eb_transport(geofil,
                      vgeofil,
                      fil,
                      xstart,
                      xend,
                      ystart,
                      yend,
                      zs,
                      ze,
                      meanax,
                      savfil=None):

    keepax = ()
    for i in range(4):
        if i not in meanax:
            keepax += (i, )

    fh = mfdset(fil)
    (xs, xe), (ys, ye), dimv = rdp1.getlatlonindx(fh,
                                                  wlon=xstart,
                                                  elon=xend,
                                                  slat=ystart,
                                                  nlat=yend,
                                                  zs=zs,
                                                  ze=ze,
                                                  yhyq='yq')
    fhgeo = dset(geofil)
    D = rdp1.getgeombyindx(fhgeo, xs, xe, ys, ye)[0]
    fhgeo.close()
    nt_const = dimv[0].size
    vh = fh.variables['vh'][0:, zs:ze, ys:ye, xs:xe]
    e = fh.variables['e'][0:, zs:ze, ys:ye, xs:xe]
    fh.close()
    vh = vh.filled(0)

    X = dimv[keepax[1]]
    Y = dimv[keepax[0]]
    if 1 in keepax:
        z = np.linspace(-np.nanmax([2000]), -1, num=50)
        Y = z
    P = getvaratzc(vh, z, e)
    P = np.ma.apply_over_axes(np.mean, P, meanax)
    P = P.squeeze()
    #P = np.ma.apply_over_axes(np.mean, vh, meanax).squeeze()
    im = m6plot((X, Y, P),
                titl='Transport near EB',
                ylab='z (m)',
                xlab='y (Deg)')

    if savfil:
        plt.savefig(savfil + '.eps',
                    dpi=300,
                    facecolor='w',
                    edgecolor='w',
                    format='eps',
                    transparent=False,
                    bbox_inches='tight')
    else:
        im = m6plot((X, Y, P),
                    titl='Transport near EB',
                    ylab='z (m)',
                    xlab='y (Deg)')
        plt.show()