Changeset 1711 in lmdz_wrf
- Timestamp:
- Dec 12, 2017, 11:48:07 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r1710 r1711 36 36 # var_cllmh: Fcuntion to compute cllmh on a 1D column 37 37 # var_clt: Function to compute the total cloud fraction following 'newmicro.F90' from LMDZ using 1D vertical column values 38 # var_rh: Function to compute relative humidity following 'Tetens' equation (T,P) ...' 38 39 # var_mslp: Fcuntion to compute mean sea-level pressure 39 40 # var_td: Function to compute dew-point air temperature from temperature and pressure values … … 1264 1265 return wd 1265 1266 1267 ####### Variables (as they arrive without dimensions staff) 1268 1269 def var_rh(p, t, q): 1270 """ Function to compute relative humidity following 'Tetens' equation (T,P) ...' 1271 [t]= temperature (assuming [[t],z,y,x] in [K]) 1272 [p] = pressure field (assuming in [hPa]) 1273 [q] = mixing ratio in [kgkg-1] 1274 """ 1275 fname = 'var_rh' 1276 1277 data1 = 10.*0.6112*np.exp(17.67*(t-273.16)/(t-29.65)) 1278 data2 = 0.622*data1/(0.01*p-(1.-0.622)*data1) 1279 1280 rh = q/data2 1281 1282 return rh 1283 1266 1284 def var_td(t, p, qv): 1267 1285 """ Function to compute dew-point air temperature from temperature and pressure values … … 1329 1347 self.units = None 1330 1348 1331 if Cdiag == 'td': 1349 if Cdiag == 'hur': 1350 """ Computing dew-point temperature 1351 """ 1352 vn = 'hur' 1353 CF3Dvars = ['ta', 'plev', 'hus'] 1354 for v3D in CF3Dvars: 1355 if not vars3D.has_key(v3D): 1356 print gen.errormsg 1357 print ' ' + fname + ": missing variable '" + v3D + \ 1358 "' attribution to compute '" + vn + "' !!" 1359 print ' Equivalence of 3D variables provided _______' 1360 gen.printing_dictionary(vars3D) 1361 quit(-1) 1362 if not self.incvars.has_key(vars3D[v3D]): 1363 print gen.errormsg 1364 print ' ' + fname + ": missing variable '" + vars3D[v3D] + \ 1365 "' in input file to compute '" + vn + "' !!" 1366 print ' available variables:', self.incvars.keys() 1367 print ' looking for variables _______' 1368 gen.printing_dictionary(vars3D) 1369 quit(-1) 1370 1371 ta = ncobj.variables[vars3D['ta']][:] 1372 p = ncobj.variables[vars3D['plev']][:] 1373 hus = ncobj.variables[vars3D['hus']][:] 1374 1375 if len(ta.shape) != len(p.shape): 1376 p = gen.fill_Narray(p, ta*0., filldim=[0,2,3]) 1377 1378 self.values = var_rh(ta, p, hus) 1379 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1380 dictdims['lon']] 1381 self.units = '1' 1382 1383 elif Cdiag == 'td': 1332 1384 """ Computing dew-point temperature 1333 1385 """ … … 1353 1405 ta = ncobj.variables[vars3D['ta']][:] 1354 1406 p = ncobj.variables[vars3D['plev']][:] 1355 hu r= ncobj.variables[vars3D['hus']][:]1407 hus = ncobj.variables[vars3D['hus']][:] 1356 1408 1357 1409 if len(ta.shape) != len(p.shape): 1358 1410 p = gen.fill_Narray(p, ta*0., filldim=[0,2,3]) 1359 1411 1360 self.values = var_td(ta, p, hu r)1412 self.values = var_td(ta, p, hus) 1361 1413 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1362 1414 dictdims['lon']]
Note: See TracChangeset
for help on using the changeset viewer.