Changeset 1710 in lmdz_wrf


Ignore:
Timestamp:
Dec 12, 2017, 11:40:43 PM (7 years ago)
Author:
lfita
Message:

Adding:

  • `compute_WRFhur': Function to compute WRF relative humidity following Teten's equation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r1702 r1710  
    1919# compute_wds: Function to compute the wind direction
    2020# compute_wss: Function to compute the wind speed
     21# compute_WRFhur: Function to compute WRF relative humidity following Teten's equation
    2122# compute_WRFta: Function to compute WRF air temperature
    2223# compute_WRFtd: Function to compute WRF dew-point air temperature
     
    982983    return times
    983984
     985def compute_WRFhur(t, p, qv, dimns, dimvns):
     986    """ Function to compute WRF relative humidity following Teten's equation
     987      t= orginal WRF temperature
     988      p= original WRF pressure (P + PB)
     989      formula:
     990          temp = theta*(p/p0)**(R/Cp)
     991
     992    """
     993    fname = 'compute_WRFtd'
     994
     995    tk = (t+300.)*(p/fdef.module_definitions.p0ref)**(fdef.module_definitions.rcp)
     996    data1 = 10.*0.6112*np.exp(17.67*(tk-273.16)/(tk-29.65))
     997    data2 = 0.622*data1/(0.01*p-(1.-0.622)*data1)
     998
     999    rh = qv/data2
     1000               
     1001    dnamesvar = ['Time','bottom_top','south_north','west_east']
     1002    dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dimns,dimvns)
     1003
     1004    return rh, dnamesvar, dvnamesvar
     1005
    9841006def compute_WRFua(u, v, sina, cosa, dimns, dimvns):
    9851007    """ Function to compute geographical rotated WRF 3D winds
     
    14291451        self.units = None
    14301452
    1431         if Wdiag == 'p':
     1453        if Wdiag == 'hur':
     1454            """ Computing relative humidity
     1455            """
     1456            vn = 'hur'
     1457            CF3Dvars = ['ta', 'hus']
     1458            for v3D in CF3Dvars:
     1459                if not vars3D.has_key(v3D):
     1460                    print gen.errormsg
     1461                    print '  ' + fname + ": missing variable '" + v3D +              \
     1462                      "' attribution to compute '" + vn + "' !!"
     1463                    print '  Equivalence of 3D variables provided _______'
     1464                    gen.printing_dictionary(vars3D)
     1465                    quit(-1)
     1466
     1467            ta = ncobj.variables['T'][:]
     1468            p = ncobj.variables['P'][:] + ncobj.variables['PB'][:]
     1469            hur = ncobj.variables['QVAPOR'][:]
     1470   
     1471            vals, dims, vdims = compute_WRFhur(ta, p, hur, indims, invardims)
     1472            self.values = vals
     1473            self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'],        \
     1474              dictdims['lon']]
     1475            self.units = '1'
     1476
     1477        elif Wdiag == 'p':
    14321478            """ Computing air pressure
    14331479            """
     
    14781524            ta = ncobj.variables['T'][:]
    14791525            p = ncobj.variables['P'][:] + ncobj.variables['PB'][:]
    1480             hur = ncobj.variables['QVAPOR'][:]
    1481    
    1482             vals, dims, vdims = compute_WRFtd(ta, p, hur, indims, invardims)
     1526            hus = ncobj.variables['QVAPOR'][:]
     1527   
     1528            vals, dims, vdims = compute_WRFtd(ta, p, hus, indims, invardims)
    14831529            self.values = vals
    14841530            self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'],        \
Note: See TracChangeset for help on using the changeset viewer.