Changeset 1720 in lmdz_wrf
- Timestamp:
- Dec 14, 2017, 2:12:51 AM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r1718 r1720 40 40 # var_mslp: Fcuntion to compute mean sea-level pressure 41 41 # var_td: Function to compute dew-point air temperature from temperature and pressure values 42 # var_td_Uhus: Function to compute dew-point air temperature from temperature and pressure values using hus 42 43 # var_virtualTemp: This function returns virtual temperature in K, 43 44 # var_WRFtime: Function to copmute CFtimes from WRFtime variable … … 1358 1359 return td 1359 1360 1361 def var_td_Uhus(t, p, hus): 1362 """ Function to compute dew-point air temperature from temperature and pressure values using hus 1363 t= temperature [K] 1364 hus= specific humidity [1] 1365 formula: 1366 temp = theta*(p/p0)**(R/Cp) 1367 1368 """ 1369 fname = 'compute_td' 1370 1371 tk = (t)*(p/fdef.module_definitions.p0ref)**(fdef.module_definitions.rcp) 1372 data1 = 10.*0.6112*np.exp(17.67*(tk-273.16)/(tk-29.65)) 1373 data2 = 0.622*data1/(0.01*p-(1.-0.622)*data1) 1374 1375 qv = hus/(1.+hus) 1376 1377 rh = qv/data2 1378 1379 pa = rh * data1 1380 td = 257.44*np.log(pa/6.1121)/(18.678-np.log(pa/6.1121)) 1381 1382 return td 1383 1360 1384 def var_wd(u, v): 1361 1385 """ Function to compute the wind direction … … 1474 1498 """ 1475 1499 vn = 'td' 1476 CF3Dvars = ['ta', 'plev', ' hus']1500 CF3Dvars = ['ta', 'plev', 'q'] 1477 1501 for v3D in CF3Dvars: 1478 1502 if not vars3D.has_key(v3D): … … 1494 1518 ta = ncobj.variables[vars3D['ta']][:] 1495 1519 p = ncobj.variables[vars3D['plev']][:] 1496 hus = ncobj.variables[vars3D['hus']][:]1520 q = ncobj.variables[vars3D['q']][:] 1497 1521 1498 1522 if len(ta.shape) != len(p.shape): 1499 1523 p = gen.fill_Narray(p, ta*0., filldim=[0,2,3]) 1500 1524 1501 self.values = var_td(ta, p, hus) 1525 self.values = var_td(ta, p, q) 1526 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1527 dictdims['lon']] 1528 self.units = 'K' 1529 1530 elif Cdiag == 'td_Uhus': 1531 """ Computing dew-point temperature 1532 """ 1533 vn = 'td' 1534 CF3Dvars = ['ta', 'plev', 'hus'] 1535 for v3D in CF3Dvars: 1536 if not vars3D.has_key(v3D): 1537 print gen.errormsg 1538 print ' ' + fname + ": missing variable '" + v3D + \ 1539 "' attribution to compute '" + vn + "' !!" 1540 print ' Equivalence of 3D variables provided _______' 1541 gen.printing_dictionary(vars3D) 1542 quit(-1) 1543 if not self.incvars.has_key(vars3D[v3D]): 1544 print gen.errormsg 1545 print ' ' + fname + ": missing variable '" + vars3D[v3D] + \ 1546 "' in input file to compute '" + vn + "' !!" 1547 print ' available variables:', self.incvars.keys() 1548 print ' looking for variables _______' 1549 gen.printing_dictionary(vars3D) 1550 quit(-1) 1551 1552 ta = ncobj.variables[vars3D['ta']][:] 1553 p = ncobj.variables[vars3D['plev']][:] 1554 hus = ncobj.variables[vars3D['hus']][:] 1555 1556 if len(ta.shape) != len(p.shape): 1557 p = gen.fill_Narray(p, ta*0., filldim=[0,2,3]) 1558 1559 self.values = var_td_Uhus(ta, p, hus) 1502 1560 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1503 1561 dictdims['lon']] -
trunk/tools/get_stations.py
r1719 r1720 21 21 22 22 # Gneric variables prepared to be computed 23 Cvars = ['C_hur', 'C_hur_Uhus', 'C_td', 'C_ wd', 'C_ws']23 Cvars = ['C_hur', 'C_hur_Uhus', 'C_td', 'C_td_hus', 'C_wd', 'C_ws'] 24 24 25 25 # WRF specific diagnostics
Note: See TracChangeset
for help on using the changeset viewer.