Changeset 1581 in lmdz_wrf


Ignore:
Timestamp:
Jun 9, 2017, 9:51:14 PM (8 years ago)
Author:
lfita
Message:

Adding: clivi', clwvl' and fixing 'mslp'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diagnostics.py

    r1419 r1581  
    304304                    zclear = 1.
    305305                    zcloud = 0.
    306                     ncvar.percendone(it*dx*dy + ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
     306                    gen.percendone(it*dx*dy + ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
    307307                    clt[it,iy,ix] = var_clt(cldfra[it,:,iy,ix])
    308308
     
    318318                zclear = 1.
    319319                zcloud = 0.
    320                 ncvar.percendone(ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
     320                gen.percendone(ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
    321321                clt[iy,ix] = var_clt(cldfra[:,iy,ix])
    322322
     
    463463            for ix in range(dx):
    464464                for iy in range(dy):
    465                     ncvar.percendone(it*dx*dy + ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
     465                    gen.percendone(it*dx*dy + ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
    466466                    cllmh[:,it,iy,ix] = var_cllmh(cldfra[it,:,iy,ix], pres[it,:,iy,ix])
    467467       
     
    477477        for ix in range(dx):
    478478            for iy in range(dy):
    479                 ncvar.percendone(ix*dy + iy,dx*dy, 5, 'diagnosted')
     479                gen.percendone(ix*dy + iy,dx*dy, 5, 'diagnosted')
    480480                cllmh[:,iy,ix] = var_cllmh(cldfra[:,iy,ix], pres[:,iy,ix])
    481481
    482482    return cllmh, cllmhdims, cllmhvdims
     483
     484def compute_clivi(dens, qtot, dimns, dimvns):
     485    """ Function to compute cloud-ice water path (clivi)
     486      [dens] = density [in kgkg-1] (assuming [t],z,y,x)
     487      [qtot] = added mixing ratio of all cloud-ice species in [kgkg-1] (assuming [t],z,y,x)
     488      [dimns]= list of the name of the dimensions of [q]
     489      [dimvns]= list of the name of the variables with the values of the
     490        dimensions of [q]
     491    """
     492    fname = 'compute_clivi'
     493
     494    clividims = dimns[:]
     495    clivivdims = dimvns[:]
     496
     497    if len(qtot.shape) == 4:
     498        clividims.pop(1)
     499        clivivdims.pop(1)
     500    else:
     501        clividims.pop(0)
     502        clivivdims.pop(0)
     503
     504    data1 = dens*qtot
     505    clivi = np.sum(data1, axis=1)
     506
     507    return clivi, clividims, clivivdims
     508
     509
     510def compute_clwvl(dens, qtot, dimns, dimvns):
     511    """ Function to compute condensed water path (clwvl)
     512      [dens] = density [in kgkg-1] (assuming [t],z,y,x)
     513      [qtot] = added mixing ratio of all cloud-water species in [kgkg-1] (assuming [t],z,y,x)
     514      [dimns]= list of the name of the dimensions of [q]
     515      [dimvns]= list of the name of the variables with the values of the
     516        dimensions of [q]
     517    """
     518    fname = 'compute_clwvl'
     519
     520    clwvldims = dimns[:]
     521    clwvlvdims = dimvns[:]
     522
     523    if len(qtot.shape) == 4:
     524        clwvldims.pop(1)
     525        clwvlvdims.pop(1)
     526    else:
     527        clwvldims.pop(0)
     528        clwvlvdims.pop(0)
     529
     530    data1 = dens*qtot
     531    clwvl = np.sum(data1, axis=1)
     532
     533    return clwvl, clwvldims, clwvlvdims
    483534
    484535def var_virtualTemp (temp,rmix):
     
    619670                          qvapor[it,:,iy,ix])
    620671
    621                         ncvar.percendone(it*dx*dy + ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
     672                        gen.percendone(it*dx*dy + ix*dy + iy, dx*dy*dt, 5, 'diagnosted')
    622673                else:
    623674                    mslpv[:,iy,ix] = psurface[:,iy,ix]
     
    639690        for ix in range(dx):
    640691            for iy in range(dy):
    641                 ncvar.percendone(ix*dy + iy,dx*dy, 5, 'diagnosted')
     692                gen.percendone(ix*dy + iy,dx*dy, 5, 'diagnosted')
    642693                if terval[iy,ix] > 0.:
    643694                    mslpv[iy,ix] = var_mslp(pressure[:,iy,ix], psurface[iy,ix],          \
     
    879930availdiags = ['ACRAINTOT', 'accum', 'clt', 'cllmh', 'deaccum', 'LMDZrh', 'mslp',     \
    880931  'OMEGAw', 'RAINTOT',                                                               \
    881   'rvors', 'td', 'turbulence', 'WRFgeop', 'WRFp', 'WRFrvors', 'ws', 'wds', 'wss',    \
    882   'WRFheight', 'WRFheightrel', 'WRFua', 'WRFva']
     932  'rvors', 'td', 'turbulence', 'WRFclivi', 'WRFclwvl', 'WRFgeop', 'WRFp',            \
     933  'WRFrvors', 'ws', 'wds', 'wss', 'WRFheight', 'WRFheightrel', 'WRFua', 'WRFva']
    883934
    884935methods = ['accum', 'deaccum']
     
    886937# Variables not to check
    887938NONcheckingvars = ['cllmh', 'deaccum', 'TSrhs', 'TStd', 'TSwds', 'TSwss', 'WRFbils', \
    888   'WRFdens', 'WRFgeop',                                                              \
     939  'WRFclivi', 'WRFclwvl', 'WRFdens', 'WRFgeop',                                      \
    889940  'WRFp', 'WRFtd',                                                                   \
    890941  'WRFpos', 'WRFprc', 'WRFprls', 'WRFrh', 'LMDZrh', 'LMDZrhs', 'WRFrhs', 'WRFrvors', \
     
    13051356          dnamesvar, dvnamesvar)
    13061357
     1358        # Removing the nonChecking variable-dimensions from the initial list
     1359        varsadd = []
     1360        diagoutvd = list(dvnames)
     1361        for nonvd in NONchkvardims:
     1362            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     1363            varsadd.append(nonvd)
    13071364        ncvar.insert_variable(ncobj, 'psl', diagout, diagoutd, diagoutvd, newnc)
    13081365
     
    14721529        ncvar.insert_variable(ncobj, 'bils', diagout, dnamesvar, dvnamesvar, newnc)
    14731530
     1531# WRFclivi WRF water vapour path WRFdens, QICE, QGRAUPEL, QHAIL
     1532    elif diag == 'WRFclivi':
     1533           
     1534        var0 = WRFdens
     1535        qtot = ncobj.variables[depvars[1]]
     1536        qtotv = qtot[:]
     1537        Nspecies = len(depvars) - 2
     1538        for iv in range(Nspecies):
     1539            var1 = ncobj.variables[depvars[iv+2]][:]
     1540            qtotv = qtotv + var1
     1541
     1542        dnamesvar = list(qtot.dimensions)
     1543        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
     1544
     1545        diagout, diagoutd, diagoutvd = compute_clivi(var0, qtotv, dnamesvar,dvnamesvar)
     1546
     1547        # Removing the nonChecking variable-dimensions from the initial list
     1548        varsadd = []
     1549        diagoutvd = list(dvnames)
     1550        for nonvd in NONchkvardims:
     1551            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     1552            varsadd.append(nonvd)
     1553        ncvar.insert_variable(ncobj, 'clivi', diagout, diagoutd, diagoutvd, newnc)
     1554
     1555# WRFclwvl WRF water cloud-condensed path WRFdens, QCLOUD, QICE, QGRAUPEL, QHAIL
     1556    elif diag == 'WRFclwvl':
     1557           
     1558        var0 = WRFdens
     1559        qtot = ncobj.variables[depvars[1]]
     1560        qtotv = ncobj.variables[depvars[1]]
     1561        Nspecies = len(depvars) - 2
     1562        for iv in range(Nspecies):
     1563            var1 = ncobj.variables[depvars[iv+2]]
     1564            qtotv = qtotv + var1[:]
     1565
     1566        dnamesvar = list(qtot.dimensions)
     1567        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
     1568
     1569        diagout, diagoutd, diagoutvd = compute_clwvl(var0, qtotv, dnamesvar,dvnamesvar)
     1570
     1571        # Removing the nonChecking variable-dimensions from the initial list
     1572        varsadd = []
     1573        diagoutvd = list(dvnames)
     1574        for nonvd in NONchkvardims:
     1575            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     1576            varsadd.append(nonvd)
     1577        ncvar.insert_variable(ncobj, 'clwvl', diagout, diagoutd, diagoutvd, newnc)
     1578
    14741579# WRFgeop geopotential from WRF as PH + PHB
    14751580    elif diag == 'WRFgeop':
Note: See TracChangeset for help on using the changeset viewer.