Esempio n. 1
0
def budgetplot(maindir, xdir, dx, dy, dt):
    files = sorted(glob.glob(maindir + xdir + '/*.h5'))
    nt = len(files)
    updraft = np.zeros(nt)
    vapflux = np.zeros(nt)
    tracflux = np.zeros(nt)
    totalmass = np.zeros(nt)
    for t, filename in enumerate(files):
        print t
        f = hdf.File(filename, 'r')
        w = getvar(f, 'w')
        q = getvar(f, 'total_cond') / 1000.
        vap = getvar(f, 'vapor') / 1000.
        trac = getvar(f, 'tracer002') * (100.**3)
        height = getvar(f, 'z_coords')
        rho = getrho(f)
        dz = getdz(f)
        f.close()
        nz, nx, ny = q.shape
        azz = np.argmin(np.absolute(height - 8000))
        bzz = nz - 1

        advw = rho * w * q
        advv = rho * w * vap
        advt = w * trac

        updraft[t] = dx * dy * dt * (np.sum(advw[azz, :, :]) -
                                     np.sum(advw[bzz, :, :]))
        vapflux[t] = dx * dy * dt * (np.sum(advv[azz, :, :]) -
                                     np.sum(advv[bzz, :, :]))
        tracflux[t] = dx * dy * dt * (np.sum(advt[azz, :, :]) -
                                      np.sum(advt[bzz, :, :]))
        totalmass[t] = np.sum(q[azz:bzz, :, :] * rho[azz:bzz, :, :] *
                              dz[azz:bzz, None, None]) * dx * dy

    for t, filename in enumerate(files):
        print t
        #       advw = rho * w * q
        #       advv = rho * w * vap
        #       advt = w * trac

        #        updraft[t] = dx * dy * dt * (np.sum(advw[azz,:,:]) - np.sum(advw[bzz,:,:]))
        #        vapflux[t] = dx * dy * dt * (np.sum(advv[azz,:,:]) - np.sum(advv[bzz,:,:]))
        #        tracflux[t] = dx * dy * dt * (np.sum(advt[azz,:,:]) - np.sum(advt[bzz,:,:]))
        #        totalmass[t] = np.sum(q[azz:bzz,:,:]*rho[azz:bzz,:,:] * dz[azz:bzz,None,None]) * dx * dy

        return updraft, vapflux, tracflux, totalmass
def budgetplot(maindir, xdir, dx, dy, dt):
    files = sorted(glob.glob(maindir + xdir + '/*.h5'))
    nt = len(files)
    updraft = np.zeros(nt)
    onlyup = np.zeros(nt)
    for t, filename in enumerate(files):
        print t
        f = hdf.File(filename, 'r')
        w = getvar(f, 'w')
        height = getvar(f, 'z_coords')
        rho = getrho(f)
        dz = getdz(f)
        f.close()
        nz, nx, ny = w.shape
        azz = np.argmin(np.absolute(height - 8000))
        bzz = nz - 1
        advw = rho * w
        upw = copy.deepcopy(advw)
        upw[w < 1] = 0.
        updraft[t] = dx * dy * dt * (np.sum(advw[azz, :, :]) -
                                     np.sum(advw[bzz, :, :]))
        onlyup[t] = dx * dy * dt * (np.sum(upw[azz, :, :]) -
                                    np.sum(upw[bzz, :, :]))
    return updraft, onlyup
Esempio n. 3
0
modeldirs = ['feb23-control','aug11-control','aug17-control']

updraftfrac = {}

plt.set_cmap('summer')

for xdir in modeldirs:
    print xdir
    files = sorted(glob.glob('/nobackup/rstorer/convperts/revu/'+xdir+'/*h5'))
    nt = len(files)
    uptimes = np.zeros(nt)
    downtimes = np.zeros(nt)
    for t in range(nt):
        w = (getvar(files[t],'w')[h8km:,:,:])
        rho = getrho(files[t])[h8km::,10,10]
        cond = (getvar(files[t],'total_cond')[h8km:,:,:])
        flux = w*rho[:,None,None]*dz[:,None,None]
        
        inboth = np.where(np.logical_and(cond>0.1,w>2))
        inbothdown = np.where(np.logical_and(cond>0.1,w<-2))

        if len(inboth[0]) >1:

            sumdz = np.sum(dz[:np.max(np.asarray(inboth[0]))])

            fluxup = copy.deepcopy(flux)
            fluxdown = copy.deepcopy(flux)

            fluxup[w<2]=0.
            fluxdown[w>-2]=0.
Esempio n. 4
0
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from rachelutils.hdfload import getvar, getrho
import numpy as np

cond1 = getvar(
    '../h5files/mature/mature-aug11-control-condensate-smoothed3km-56.h5', 'q')
cond2 = getvar(
    '../h5files/mature/mature-aug11-control-condensate-smoothed3km-59.h5', 'q')
w = getvar(
    '../h5files/mature/mature-aug11-control-refbudgetvars-90s-smoothed3km-56.h5',
    'w')
precip = getvar(
    '../h5files/mature/mature-aug11-control-precip3d-smoothed3km-56.h5', 'q')
rho = getrho(
    '/nobackup/rstorer/convperts/mature/aug11-control/aug11-control-mature-057.h5'
)[:, 0, 0]
z = getvar(
    '/nobackup/rstorer/convperts/mature/aug11-control/aug11-control-mature-057.h5',
    'z_coords') / 1000.
pcp = getvar(
    '../h5files/mature/mature-aug11-control-pcprate-smoothed3km-56.h5', 'q')
xs = np.arange(33) * 3.

cmf = (cond1 / 1000.) * rho[:, None, None] * w
net = cmf - precip

wconv = precip / (rho[:, None, None] * (cond1 / 1000.))
wconv[cond1 < .01] = 0.

cond1 = cond1 * rho[:, None, None]
Esempio n. 5
0
#h10 = np.load('growing-controlonly-h10.npz')
#w10 = np.load('growing-controlonly-w10.npz')
#flux10 = np.load('growing-controlonly-flux10.npz')

for xdir in modeldirs:
    print xdir
    files = sorted(glob.glob('/nobackup/rstorer/convperts/growing/'+xdir+'/*h5'))
    reffiles = sorted(glob.glob('/nobackup/rstorer/convperts/growing/quickbeam/'+xdir+'*h5'))
    nt = len(files)
    h10[xdir] = np.zeros((nt,400,400))
    w10[xdir] = np.zeros((nt,400,400))
    flux10[xdir] = np.zeros((nt,400,400))
    for t in range(nt):
        print t
        fil = files[t]
        flux = ((getvar(fil,'total_cond')[km5:,:,:]/1000.) * getvar(fil,'w')[km5:,:,:] * getrho(fil)[km5:,:,:]) - getvar(fil,'precip3d')[km5:,:,:]
        w = getvar(fil,'w')[km5:,:,:]
        ref = getvar(reffiles[t],'reflectivity')[km5:,:,:]
        ref[ref<-40]=-40
        maxref = np.max(ref,0)
        for i in range(400):
            for j in range(400):
                if maxref[i,j] >10 and np.max(w[:,i,j])>1:
                    h10[xdir][t,i,j],w10[xdir][t,i,j],flux10[xdir][t,i,j] = findheight(ref[:,i,j],w[:,i,j],flux[:,i,j],height[km5:],10.)
    wall = w10[xdir][0:-1,:,:]
    fluxall = flux10[xdir][0:-1,:,:]
    h10all = h10[xdir][0:-1,:,:]
    diffall = np.diff(h10[xdir], axis=0)
    diffall[h10all < 1000] = 0

Esempio n. 6
0
import numpy as np
import h5py as hdf
from rachelutils.hdfload import getvar, getrho
from rachelutils.dumbnaming import pert75
import glob

modeldirs = pert75()

times = ['mature', 'growing']

for xdir in modeldirs:
    rho = getrho('../convperts/revu/' + xdir + '/' + xdir + '-revu-001.h5')[:,
                                                                            0,
                                                                            0]
    for time in times:
        print xdir, time
        wfiles = sorted(
            glob.glob('../h5files/' + time + '/*' + xdir +
                      '-*refbudgetvars*h5'))
        vfiles = sorted(
            glob.glob('../h5files/' + time + '/*' + xdir + '-*vapor*h5'))
        cfiles = sorted(
            glob.glob('../h5files/' + time + '/*' + xdir + '-*cond*h5'))
        pfiles = sorted(
            glob.glob('../h5files/' + time + '/*' + xdir + '-*precip3d*h5'))
        nt = len(wfiles)
        for t in range(nt):
            print t
            w = getvar(wfiles[t], 'w')
            v = getvar(vfiles[t], 'q') / 1000.
            c = getvar(cfiles[t], 'q') / 1000.
Esempio n. 7
0
actdownboth = {}

for xdir in modeldirs:
    print xdir
    files = sorted(
        glob.glob('/nobackup/rstorer/convperts/mature/' + xdir + '/*h5'))
    nt = len(files)
    estup[xdir] = np.zeros(nt)
    actupup[xdir] = np.zeros(nt)
    actupcond[xdir] = np.zeros(nt)
    actupboth[xdir] = np.zeros(nt)
    actdownboth[xdir] = np.zeros(nt)

    for t in range(nt):
        w = (getvar(files[t], 'w')[h8km, :, :]).flatten()
        rho = np.mean(getrho(files[t])[h8km, :, :])
        cond = (getvar(files[t], 'total_cond')[h8km, :, :]).flatten()

        incloud = np.where(cond > 0.1)
        inup = np.where(w > 1)
        inboth = np.where(np.logical_and(cond > 0.1, w > 1))
        inbothdown = np.where(np.logical_and(cond > 0.1, w < -1))

        if len(incloud[0]) > 1:
            sigma = 1.0 * len(inup[0]) / len(incloud[0])
            estup[xdir][t] = rho * sigma * np.mean(w[inboth])
            actupboth[xdir][t] = np.mean(rho * w[inboth])
            actupcond[xdir][t] = np.mean(rho * w[incloud])
            actupup[xdir][t] = np.mean(rho * w[inup])

            actdownboth[xdir][t] = np.mean(rho * w[inbothdown])
Esempio n. 8
0
vals = [0,5,10,20]

for thresh in vals:

    finalw = []
    finalmaxw = []
    finaldiff = []
    finalflux = []

    for xdir in modeldirs:
        print xdir
        files = sorted(glob.glob('/nobackup/rstorer/h5files/mature-'+xdir+'*refbudgetvars*h5'))
        condfiles = sorted(glob.glob('/nobackup/rstorer/h5files/mature-'+xdir+'*cond*3km*h5'))
        pcpfiles = sorted(glob.glob('/nobackup/rstorer/h5files/mature-'+xdir+'*precip*3km*h5'))
        rho = getrho('/nobackup/rstorer/convperts/mature/'+xdir+'/'+xdir+'-mature-001.h5')[:,0,0]
        nt = len(files)
        print len(files),len(condfiles),len(pcpfiles),nt
        h10[xdir] = np.zeros((nt,33,33))
        flux10[xdir] = np.zeros((nt,33,33))
        w10[xdir] = np.zeros((nt,33,33))
        maxw[xdir] = np.zeros((nt,33,33))
        for t in range(nt):
            print t
            fil = files[t]
            w = getvar(fil,'w')
            ref = getvar(fil,'ref')
            cond = getvar(condfiles[t],'q')/1000.
            pcp = getvar(pcpfiles[t],'q')
            flux = (cond*w*rho[:,None,None])-pcp
            maxflux = np.max(flux,0)
for thresh in vals:

    finalw = []
    finalmaxw = []
    finaldiff = []
    finalflux = []

    for xdir in modeldirs:
        print xdir
        files = sorted(
            glob.glob('/nobackup/rstorer/convperts/growing/' + xdir + '/*h5'))
        reffiles = sorted(
            glob.glob('/nobackup/rstorer/convperts/growing/quickbeam/' + xdir +
                      '*h5'))
        rho = getrho(files[0])[:, 0, 0]
        nt = len(files)
        h10[xdir] = np.zeros((nt, 400, 400))
        flux10[xdir] = np.zeros((nt, 400, 400))
        w10[xdir] = np.zeros((nt, 400, 400))
        maxw[xdir] = np.zeros((nt, 400, 400))
        for t in range(nt):
            print t
            fil = files[t]
            w = getvar(fil, 'w')
            ref = getvar(reffiles[t], 'reflectivity')
            cond = getvar(fil, 'total_cond') / 1000.
            pcp = getvar(fil, 'precip3d')
            flux = (cond * w * rho[:, None, None]) - pcp
            maxflux = np.max(flux, 0)
            maxref = np.max(ref, 0)