Changeset 642 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Sep 19, 2015, 12:47:01 PM (10 years ago)
Author:
lfita
Message:

Adding OMEGA to w transformation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diagnostics.py

    r616 r642  
    532532    return mslpv, mslpdims, mslpvdims
    533533
     534def compute_OMEGAw(omega, p, t, dimns, dimvns):
     535    """ Function to transform OMEGA [Pas-1] to velocities [ms-1]
     536      tacking: https://www.ncl.ucar.edu/Document/Functions/Contributed/omega_to_w.shtml
     537      [omega] = vertical velocity [in ms-1] (assuming [t],z,y,x)
     538      [p] = pressure in [Pa] (assuming [t],z,y,x)
     539      [t] = temperature in [K] (assuming [t],z,y,x)
     540      [dimns]= list of the name of the dimensions of [q]
     541      [dimvns]= list of the name of the variables with the values of the
     542        dimensions of [q]
     543    """
     544    fname = 'compute_OMEGAw'
     545
     546    rgas = 287.058            # J/(kg-K) => m2/(s2 K)
     547    g    = 9.80665            # m/s2
     548
     549    wdims = dimns[:]
     550    wvdims = dimvns[:]
     551
     552    rho  = p/(rgas*t)         # density => kg/m3
     553    w    = -omega/(rho*g)     
     554
     555    return w, wdims, wvdims
     556
    534557def compute_prw(dens, q, dimns, dimvns):
    535558    """ Function to compute water vapour path (prw)
     
    10321055
    10331056        ncvar.insert_variable(ncobj, 'psl', diagout, diagoutd, diagoutvd, newnc)
     1057
     1058# OMEGAw (omega, p, t) from NCL formulation (https://www.ncl.ucar.edu/Document/Functions/Contributed/omega_to_w.shtml)
     1059    elif diag == 'OMEGAw':
     1060           
     1061        var0 = ncobj.variables[depvars[0]][:]
     1062        var1 = ncobj.variables[depvars[1]][:]
     1063        var1 = ncobj.variables[depvars[2]][:]
     1064
     1065        dnamesvar = ncobj.variables[depvars[0]].dimensions
     1066        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
     1067
     1068        diagout, diagoutd, diagoutvd = compute_OMEGAw(var0,var1,var2,dnamesvar,dvnamesvar)
     1069
     1070        ncvar.insert_variable(ncobj, 'wa', diagout, diagoutd, diagoutvd, newnc)
    10341071
    10351072# raintot: instantaneous total precipitation from WRF as (RAINC + RAINC) / dTime
Note: See TracChangeset for help on using the changeset viewer.