Changeset 1718 in lmdz_wrf for trunk/tools/diag_tools.py
- Timestamp:
- Dec 14, 2017, 1:32:14 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r1717 r1718 37 37 # var_clt: Function to compute the total cloud fraction following 'newmicro.F90' from LMDZ using 1D vertical column values 38 38 # var_hur: Function to compute relative humidity following 'August - Roche - Magnus' formula 39 # var_hur_Uhus: Function to compute relative humidity following 'August - Roche - Magnus' formula using hus 39 40 # var_mslp: Fcuntion to compute mean sea-level pressure 40 41 # var_td: Function to compute dew-point air temperature from temperature and pressure values … … 1295 1296 hur = q/(ws*1000.) 1296 1297 1297 print 'q:', q[5,5,5,5], 't:', t[5,5,5,5], 'p:', p[5,5,5,5] 1298 print 'es:', es[5,5,5,5], 'ws:', ws[5,5,5,5], 'hur:', hur[5,5,5,5] 1298 #print 'q:', q[5,5,5,5], 't:', t[5,5,5,5], 'p:', p[5,5,5,5] 1299 #print 'es:', es[5,5,5,5], 'ws:', ws[5,5,5,5], 'hur:', hur[5,5,5,5] 1300 1301 return hur 1302 1303 def var_hur_Uhus(p, t, hus): 1304 """ Function to compute relative humidity following 'August - Roche - Magnus' formula using hus 1305 [t]= temperature (assuming [[t],z,y,x] in [K]) 1306 [p] = pressure field (assuming in [Pa]) 1307 [hus] = specific humidty [1] 1308 ref.: M. G. Lawrence, BAMS, 2005, 225 1309 >>> print var_rh(101300., 290., 3.) 1310 0.250250256174 1311 """ 1312 fname = 'var_hur_Uhus' 1313 1314 # Enthalpy of vaporization [Jkg-1] 1315 L = 2.453*10.**6 1316 # Gas constant for water vapor [JK-1Kg-1] 1317 Rv = 461.5 1318 1319 # Computing saturated pressure 1320 #es = 10.*0.6112*np.exp(17.67*(t-273.16)/(t-29.65)) 1321 #es = 6.11*np.exp(L/Rv*(1.-273./t)/273.) 1322 1323 # August - Roche - Magnus formula 1324 es = 6.1094*np.exp(17.625*(t-273.15)/((t-273.15)+243.04)) 1325 1326 # Saturated mixing ratio [g/kg] 1327 ws = 0.622*es/(0.01*p-es) 1328 1329 # Mixing ratio 1330 q = hus/(1.+hus) 1331 1332 hur = q/(ws*1000.) 1333 1334 #print 'q:', q[5,5,5,5], 't:', t[5,5,5,5], 'p:', p[5,5,5,5] 1335 #print 'es:', es[5,5,5,5], 'ws:', ws[5,5,5,5], 'hur:', hur[5,5,5,5] 1299 1336 1300 1337 return hur … … 1367 1404 if Cdiag == 'hur': 1368 1405 """ Computing relative humidity 1406 """ 1407 vn = 'hur' 1408 CF3Dvars = ['ta', 'plev', 'q'] 1409 for v3D in CF3Dvars: 1410 if not vars3D.has_key(v3D): 1411 print gen.errormsg 1412 print ' ' + fname + ": missing variable '" + v3D + \ 1413 "' attribution to compute '" + vn + "' !!" 1414 print ' Equivalence of 3D variables provided _______' 1415 gen.printing_dictionary(vars3D) 1416 quit(-1) 1417 if not self.incvars.has_key(vars3D[v3D]): 1418 print gen.errormsg 1419 print ' ' + fname + ": missing variable '" + vars3D[v3D] + \ 1420 "' in input file to compute '" + vn + "' !!" 1421 print ' available variables:', self.incvars.keys() 1422 print ' looking for variables _______' 1423 gen.printing_dictionary(vars3D) 1424 quit(-1) 1425 1426 ta = ncobj.variables[vars3D['ta']][:] 1427 p = ncobj.variables[vars3D['plev']][:] 1428 q = ncobj.variables[vars3D['q']][:] 1429 1430 if len(ta.shape) != len(p.shape): 1431 p = gen.fill_Narray(p, ta*0., filldim=[0,2,3]) 1432 1433 self.values = var_hur(p, ta, q) 1434 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1435 dictdims['lon']] 1436 self.units = '1' 1437 1438 if Cdiag == 'hur_Uhus': 1439 """ Computing relative humidity using hus 1369 1440 """ 1370 1441 vn = 'hur' … … 1394 1465 p = gen.fill_Narray(p, ta*0., filldim=[0,2,3]) 1395 1466 1396 self.values = var_hur (p, ta, hus)1467 self.values = var_hur_Uhus(p, ta, hus) 1397 1468 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1398 1469 dictdims['lon']]
Note: See TracChangeset
for help on using the changeset viewer.