Changeset 1687 in lmdz_wrf for trunk/tools/diag_tools.py
- Timestamp:
- Dec 5, 2017, 1:11:15 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r1685 r1687 16 16 # compute_td: Function to compute the dew point temperature 17 17 # compute_turbulence: Function to compute the rubulence term of the Taylor's decomposition ...' 18 # C_diagnostic: Class to compute generic variables 18 19 # compute_wds: Function to compute the wind direction 19 20 # compute_wss: Function to compute the wind speed 20 21 # compute_WRFta: Function to compute WRF air temperature 21 22 # compute_WRFtd: Function to compute WRF dew-point air temperature 23 # compute_WRFua: Function to compute geographical rotated WRF x-wind 24 # compute_WRFva: Function to compute geographical rotated WRF y-wind 22 25 # compute_WRFuava: Function to compute geographical rotated WRF 3D winds 26 # compute_WRFuas: Function to compute geographical rotated WRF 2-meter x-wind 27 # compute_WRFvas: Function to compute geographical rotated WRF 2-meter y-wind 23 28 # compute_WRFuasvas: Fucntion to compute geographical rotated WRF 2-meter winds 24 29 # derivate_centered: Function to compute the centered derivate of a given field 25 30 # def Forcompute_cllmh: Function to compute cllmh: low/medium/hight cloud fraction following newmicro.F90 from LMDZ via Fortran subroutine 26 31 # Forcompute_clt: Function to compute the total cloud fraction following 'newmicro.F90' from LMDZ via a Fortran module 32 # W_diagnostic: Class to compute WRF diagnostics variables 27 33 28 34 # Others just providing variable values … … 33 39 # var_virtualTemp: This function returns virtual temperature in K, 34 40 # var_WRFtime: Function to copmute CFtimes from WRFtime variable 41 # var_wd: Function to compute the wind direction 42 # var_wd: Function to compute the wind speed 35 43 # rotational_z: z-component of the rotatinoal of horizontal vectorial field 36 44 # turbulence_var: Function to compute the Taylor's decomposition turbulence term from a a given variable … … 52 60 # Constants 53 61 grav = fdef.module_definitions.grav 62 63 # Available WRFiag 64 Wavailablediags = ['p', 'ta', 'td', 'ua', 'va', 'uas', 'vas', 'wd', 'ws', 'zg'] 65 66 # Available General diagnostics 67 Cavailablediags = ['td', 'wd', 'ws'] 54 68 55 69 # Gneral information … … 968 982 return times 969 983 984 def compute_WRFua(u, v, sina, cosa, dimns, dimvns): 985 """ Function to compute geographical rotated WRF 3D winds 986 u= orginal WRF x-wind 987 v= orginal WRF y-wind 988 sina= original WRF local sinus of map rotation 989 cosa= original WRF local cosinus of map rotation 990 formula: 991 ua = u*cosa-va*sina 992 va = u*sina+va*cosa 993 """ 994 fname = 'compute_WRFua' 995 996 var0 = u 997 var1 = v 998 var2 = sina 999 var3 = cosa 1000 1001 # un-staggering variables 1002 unstgdims = [var0.shape[0], var0.shape[1], var0.shape[2], var0.shape[3]-1] 1003 ua = np.zeros(tuple(unstgdims), dtype=np.float) 1004 unstgvar0 = np.zeros(tuple(unstgdims), dtype=np.float) 1005 unstgvar1 = np.zeros(tuple(unstgdims), dtype=np.float) 1006 unstgvar0 = 0.5*(var0[:,:,:,0:var0.shape[3]-1] + var0[:,:,:,1:var0.shape[3]]) 1007 unstgvar1 = 0.5*(var1[:,:,0:var1.shape[2]-1,:] + var1[:,:,1:var1.shape[2],:]) 1008 1009 for iz in range(var0.shape[1]): 1010 ua[:,iz,:,:] = unstgvar0[:,iz,:,:]*var3 - unstgvar1[:,iz,:,:]*var2 1011 1012 dnamesvar = ['Time','bottom_top','south_north','west_east'] 1013 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dimns,dimvns) 1014 1015 return ua, dnamesvar, dvnamesvar 1016 1017 def compute_WRFva(u, v, sina, cosa, dimns, dimvns): 1018 """ Function to compute geographical rotated WRF 3D winds 1019 u= orginal WRF x-wind 1020 v= orginal WRF y-wind 1021 sina= original WRF local sinus of map rotation 1022 cosa= original WRF local cosinus of map rotation 1023 formula: 1024 ua = u*cosa-va*sina 1025 va = u*sina+va*cosa 1026 """ 1027 fname = 'compute_WRFva' 1028 1029 var0 = u 1030 var1 = v 1031 var2 = sina 1032 var3 = cosa 1033 1034 # un-staggering variables 1035 unstgdims = [var0.shape[0], var0.shape[1], var0.shape[2], var0.shape[3]-1] 1036 va = np.zeros(tuple(unstgdims), dtype=np.float) 1037 unstgvar0 = np.zeros(tuple(unstgdims), dtype=np.float) 1038 unstgvar1 = np.zeros(tuple(unstgdims), dtype=np.float) 1039 unstgvar0 = 0.5*(var0[:,:,:,0:var0.shape[3]-1] + var0[:,:,:,1:var0.shape[3]]) 1040 unstgvar1 = 0.5*(var1[:,:,0:var1.shape[2]-1,:] + var1[:,:,1:var1.shape[2],:]) 1041 1042 for iz in range(var0.shape[1]): 1043 va[:,iz,:,:] = unstgvar0[:,iz,:,:]*var2 + unstgvar1[:,iz,:,:]*var3 1044 1045 dnamesvar = ['Time','bottom_top','south_north','west_east'] 1046 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dimns,dimvns) 1047 1048 return va, dnamesvar, dvnamesvar 1049 970 1050 def compute_WRFuava(u, v, sina, cosa, dimns, dimvns): 971 1051 """ Function to compute geographical rotated WRF 3D winds … … 1003 1083 return ua, va, dnamesvar, dvnamesvar 1004 1084 1085 def compute_WRFuas(u10, v10, sina, cosa, dimns, dimvns): 1086 """ Function to compute geographical rotated WRF 2-meter x-wind 1087 u10= orginal WRF 10m x-wind 1088 v10= orginal WRF 10m y-wind 1089 sina= original WRF local sinus of map rotation 1090 cosa= original WRF local cosinus of map rotation 1091 formula: 1092 uas = u10*cosa-va10*sina 1093 vas = u10*sina+va10*cosa 1094 """ 1095 fname = 'compute_WRFuas' 1096 1097 var0 = u10 1098 var1 = v10 1099 var2 = sina 1100 var3 = cosa 1101 1102 uas = np.zeros(var0.shape, dtype=np.float) 1103 vas = np.zeros(var0.shape, dtype=np.float) 1104 1105 uas = var0*var3 - var1*var2 1106 1107 dnamesvar = ['Time','south_north','west_east'] 1108 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dimns,dimvns) 1109 1110 return uas, dnamesvar, dvnamesvar 1111 1112 def compute_WRFvas(u10, v10, sina, cosa, dimns, dimvns): 1113 """ Function to compute geographical rotated WRF 2-meter y-wind 1114 u10= orginal WRF 10m x-wind 1115 v10= orginal WRF 10m y-wind 1116 sina= original WRF local sinus of map rotation 1117 cosa= original WRF local cosinus of map rotation 1118 formula: 1119 uas = u10*cosa-va10*sina 1120 vas = u10*sina+va10*cosa 1121 """ 1122 fname = 'compute_WRFvas' 1123 1124 var0 = u10 1125 var1 = v10 1126 var2 = sina 1127 var3 = cosa 1128 1129 uas = np.zeros(var0.shape, dtype=np.float) 1130 vas = np.zeros(var0.shape, dtype=np.float) 1131 1132 vas = var0*var2 + var1*var3 1133 1134 dnamesvar = ['Time','south_north','west_east'] 1135 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dimns,dimvns) 1136 1137 return vas, dnamesvar, dvnamesvar 1138 1005 1139 def compute_WRFuasvas(u10, v10, sina, cosa, dimns, dimvns): 1006 1140 """ Function to compute geographical rotated WRF 2-meter winds … … 1072 1206 return td, dnamesvar, dvnamesvar 1073 1207 1208 def compute_WRFwd(u, v, sina, cosa, dimns, dimvns): 1209 """ Function to compute the wind direction 1210 u= W-E wind direction [ms-1] 1211 v= N-S wind direction [ms-1] 1212 sina= original WRF local sinus of map rotation 1213 cosa= original WRF local cosinus of map rotation 1214 """ 1215 fname = 'compute_WRFwd' 1216 var0 = u 1217 var1 = v 1218 var2 = sina 1219 var3 = cosa 1220 1221 # un-staggering variables 1222 unstgdims = [var0.shape[0], var0.shape[1], var0.shape[2], var0.shape[3]-1] 1223 ua = np.zeros(tuple(unstgdims), dtype=np.float) 1224 va = np.zeros(tuple(unstgdims), dtype=np.float) 1225 unstgvar0 = np.zeros(tuple(unstgdims), dtype=np.float) 1226 unstgvar1 = np.zeros(tuple(unstgdims), dtype=np.float) 1227 unstgvar0 = 0.5*(var0[:,:,:,0:var0.shape[3]-1] + var0[:,:,:,1:var0.shape[3]]) 1228 unstgvar1 = 0.5*(var1[:,:,0:var1.shape[2]-1,:] + var1[:,:,1:var1.shape[2],:]) 1229 1230 for iz in range(var0.shape[1]): 1231 ua[:,iz,:,:] = unstgvar0[:,iz,:,:]*var3 - unstgvar1[:,iz,:,:]*var2 1232 va[:,iz,:,:] = unstgvar0[:,iz,:,:]*var2 + unstgvar1[:,iz,:,:]*var3 1233 1234 theta = np.arctan2(va,ua) 1235 theta = np.where(theta < 0., theta + 2.*np.pi, theta) 1236 1237 wd = 360.*theta/(2.*np.pi) 1238 1239 dnamesvar = ['Time','bottom_top','south_north','west_east'] 1240 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dimns,dimvns) 1241 1242 return wd 1243 1074 1244 def var_td(t, p, qv): 1075 1245 """ Function to compute dew-point air temperature from temperature and pressure values … … 1092 1262 1093 1263 return td 1264 1265 def var_wd(u, v): 1266 """ Function to compute the wind direction 1267 [u]= W-E wind direction [ms-1, knot, ...] 1268 [v]= N-S wind direction [ms-1, knot, ...] 1269 """ 1270 fname = 'var_wd' 1271 1272 theta = np.arctan2(v,u) 1273 theta = np.where(theta < 0., theta + 2.*np.pi, theta) 1274 1275 wd = 360.*theta/(2.*np.pi) 1276 1277 return wd 1278 1279 def var_ws(u, v): 1280 """ Function to compute the wind speed 1281 [u]= W-E wind direction [ms-1, knot, ...] 1282 [v]= N-S wind direction [ms-1, knot, ...] 1283 """ 1284 fname = 'var_ws' 1285 1286 ws = np.sqrt(u*u + v*v) 1287 1288 return ws 1289 1290 class C_diagnostic(object): 1291 """ Class to compute generic variables 1292 Cdiag: name of the diagnostic to compute 1293 ncobj: netcdf object with data 1294 sfcvars: dictionary with CF equivalencies of surface variables inside file 1295 vars3D: dictionary with CF equivalencies of 3D variables inside file 1296 dictdims: dictionary with CF equivalencies of dimensions inside file 1297 self.values = Values of the diagnostic 1298 self.dims = Dimensions of the diagnostic 1299 self.units = units of the diagnostic 1300 self.incvars = list of variables from the input netCDF object 1301 """ 1302 def __init__(self, Cdiag, ncobj, sfcvars, vars3D, dictdims): 1303 fname = 'C_diagnostic' 1304 self.values = None 1305 self.dims = None 1306 self.incvars = ncobj.variables 1307 self.units = None 1308 1309 if Cdiag == 'td': 1310 """ Computing dew-point temperature 1311 """ 1312 vn = 'td' 1313 CF3Dvars = ['ta', 'plev', 'hur'] 1314 for v3D in CF3Dvars: 1315 if not vars3D.has_key(v3D): 1316 print gen.errormsg 1317 print ' ' + fname + ": missing variable '" + v3D + \ 1318 "' attribution to compute '" + vn + "' !!" 1319 print ' Equivalence of 3D variables provided _______' 1320 gen.printing_dictionary(vars3D) 1321 quit(-1) 1322 if not self.incvars.has_key(vars3D[v3D]): 1323 print gen.errormsg 1324 print ' ' + fname + ": missing variable '" + vars3D[v3D] + \ 1325 "' in input file to compute '" + vn + "' !!" 1326 print ' available variables:', self.incvars.keys() 1327 print ' looking for variables _______' 1328 gen.printing_dictionary(vars3D) 1329 quit(-1) 1330 1331 ta = ncobj.variables[vars3D['ta']][:] 1332 p = ncobj.variables[vars3D['plev']][:] 1333 hur = ncobj.variables[vars3D['hur']][:] 1334 1335 self.values = var_td(ta, p, hur) 1336 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1337 dictdims['lon']] 1338 self.units = 'K' 1339 1340 elif Cdiag == 'wd': 1341 """ Computing wind direction 1342 """ 1343 vn = 'wd' 1344 CF3Dvars = ['ua', 'va'] 1345 for v3D in CF3Dvars: 1346 if not vars3D.has_key(v3D): 1347 print gen.errormsg 1348 print ' ' + fname + ": missing variable '" + v3D + \ 1349 "self.' attribution to compute '" + vn + "' !!" 1350 print ' Equivalence of 3D variables provided _______' 1351 gen.printing_dictionary(vars3D) 1352 quit(-1) 1353 if not self.incvars.has_key(vars3D[v3D]): 1354 print gen.errormsg 1355 print ' ' + fname + ": missing variable '" + vars3D[v3D] + \ 1356 "' in input file to compute '" + vn + "' !!" 1357 print ' available variables:', self.incvars.keys() 1358 print ' looking for variables _______' 1359 gen.printing_dictionary(vars3D) 1360 quit(-1) 1361 1362 ua = ncobj.variables[vars3D['ua']][:] 1363 va = ncobj.variables[vars3D['va']][:] 1364 1365 self.values = var_wd(ua, va) 1366 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1367 dictdims['lon']] 1368 self.units = 'degree' 1369 1370 elif Cdiag == 'ws': 1371 """ Computing wind speed 1372 """ 1373 vn = 'ws' 1374 CF3Dvars = ['ua', 'va'] 1375 for v3D in CF3Dvars: 1376 if not vars3D.has_key(v3D): 1377 print gen.errormsg 1378 print ' ' + fname + ": missing variable '" + v3D + \ 1379 "' attribution to compute '" + vn + "' !!" 1380 print ' Equivalence of 3D variables provided _______' 1381 gen.printing_dictionary(vars3D) 1382 quit(-1) 1383 if not self.incvars.has_key(vars3D[v3D]): 1384 print gen.errormsg 1385 print ' ' + fname + ": missing variable '" + vars3D[v3D] + \ 1386 "' in input file to compute '" + vn + "' !!" 1387 print ' available variables:', self.incvars.keys() 1388 print ' looking for variables _______' 1389 gen.printing_dictionary(vars3D) 1390 quit(-1) 1391 1392 ua = ncobj.variables[vars3D['ua']][:] 1393 va = ncobj.variables[vars3D['va']][:] 1394 1395 self.values = var_ws(ua, va) 1396 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1397 dictdims['lon']] 1398 self.units = ncobj.variables[vars3D['ua']].units 1399 1400 else: 1401 print gen.errormsg 1402 print ' ' + fname + ": variable '" + Wdiag + "' not ready !!" 1403 print ' available ones:', Cavailablediags 1404 quit(-1) 1405 1406 class W_diagnostic(object): 1407 """ Class to compute WRF diagnostics variables 1408 Wdiag: name of the diagnostic to compute 1409 ncobj: netcdf object with data 1410 sfcvars: dictionary with CF equivalencies of surface variables inside file 1411 vars3D: dictionary with CF equivalencies of 3D variables inside file 1412 indims: list of dimensions inside file 1413 invardims: list of dimension-variables inside file 1414 dictdims: dictionary with CF equivalencies of dimensions inside file 1415 self.values = Values of the diagnostic 1416 self.dims = Dimensions of the diagnostic 1417 self.units = units of the diagnostic 1418 self.incvars = list of variables from the input netCDF object 1419 """ 1420 def __init__(self, Wdiag, ncobj, sfcvars, vars3D, indims, invardims, dictdims): 1421 fname = 'W_diagnostic' 1422 1423 self.values = None 1424 self.dims = None 1425 self.incvars = ncobj.variables 1426 self.units = None 1427 1428 if Wdiag == 'p': 1429 """ Computing air pressure 1430 """ 1431 vn = 'p' 1432 1433 self.values = ncobj.variables['PB'][:] + ncobj.variables['P'][:] 1434 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1435 dictdims['lon']] 1436 self.units = ncobj.variables['PB'].units 1437 1438 elif Wdiag == 'ta': 1439 """ Computing air temperature 1440 """ 1441 vn = 'ta' 1442 CF3Dvars = ['ta'] 1443 for v3D in CF3Dvars: 1444 if not vars3D.has_key(v3D): 1445 print gen.errormsg 1446 print ' ' + fname + ": missing variable '" + v3D + \ 1447 "' attribution to compute '" + vn + "' !!" 1448 print ' Equivalence of 3D variables provided _______' 1449 gen.printing_dictionary(vars3D) 1450 quit(-1) 1451 1452 ta = ncobj.variables['T'][:] 1453 p = ncobj.variables['P'][:] + ncobj.variables['PB'][:] 1454 1455 vals, dims, vdims = compute_WRFta(ta, p, indims, invardims) 1456 self.values = vals 1457 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1458 dictdims['lon']] 1459 self.units = 'K' 1460 1461 elif Wdiag == 'td': 1462 """ Computing dew-point temperature 1463 """ 1464 vn = 'td' 1465 CF3Dvars = ['ta', 'hus'] 1466 for v3D in CF3Dvars: 1467 if not vars3D.has_key(v3D): 1468 print gen.errormsg 1469 print ' ' + fname + ": missing variable '" + v3D + \ 1470 "' attribution to compute '" + vn + "' !!" 1471 print ' Equivalence of 3D variables provided _______' 1472 gen.printing_dictionary(vars3D) 1473 quit(-1) 1474 1475 ta = ncobj.variables['T'][:] 1476 p = ncobj.variables['P'][:] + ncobj.variables['PB'][:] 1477 hur = ncobj.variables['QVAPOR'][:] 1478 1479 vals, dims, vdims = compute_WRFtd(ta, p, hur, indims, invardims) 1480 self.values = vals 1481 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1482 dictdims['lon']] 1483 self.units = 'K' 1484 1485 elif Wdiag == 'ua': 1486 """ Computing x-wind 1487 """ 1488 vn = 'ua' 1489 CF3Dvars = ['ua', 'va'] 1490 for v3D in CF3Dvars: 1491 if not vars3D.has_key(v3D): 1492 print gen.errormsg 1493 print ' ' + fname + ": missing variable '" + v3D + \ 1494 "' attribution to compute '" + vn + "' !!" 1495 print ' Equivalence of 3D variables provided _______' 1496 gen.printing_dictionary(vars3D) 1497 quit(-1) 1498 1499 ua = ncobj.variables['U'][:] 1500 va = ncobj.variables['V'][:] 1501 sina = ncobj.variables['SINALPHA'][:] 1502 cosa = ncobj.variables['COSALPHA'][:] 1503 1504 vals, dims, vdims = compute_WRFua(ua, va, sina, cosa, indims, invardims) 1505 self.values = vals 1506 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1507 dictdims['lon']] 1508 self.units = ncobj.variables['U'].units 1509 1510 elif Wdiag == 'uas': 1511 """ Computing 10m x-wind 1512 """ 1513 vn = 'uas' 1514 CFsfcvars = ['uas', 'vas'] 1515 for vsf in CFsfcvars: 1516 if not sfcvars.has_key(vsf): 1517 print gen.errormsg 1518 print ' ' + fname + ": missing variable '" + vsf + \ 1519 "' attribution to compute '" + vn + "' !!" 1520 print ' Equivalence of sfc variables provided _______' 1521 gen.printing_dictionary(sfcvars) 1522 quit(-1) 1523 1524 uas = ncobj.variables['U10'][:] 1525 vas = ncobj.variables['V10'][:] 1526 sina = ncobj.variables['SINALPHA'][:] 1527 cosa = ncobj.variables['COSALPHA'][:] 1528 1529 vals,dims,vdims = compute_WRFuas(uas, vas, sina, cosa, indims, invardims) 1530 self.values = vals 1531 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1532 dictdims['lon']] 1533 self.units = ncobj.variables['U10'].units 1534 1535 elif Wdiag == 'va': 1536 """ Computing y-wind 1537 """ 1538 vn = 'ua' 1539 CF3Dvars = ['ua', 'va'] 1540 for v3D in CF3Dvars: 1541 if not vars3D.has_key(v3D): 1542 print gen.errormsg 1543 print ' ' + fname + ": missing variable '" + v3D + \ 1544 "' attribution to compute '" + vn + "' !!" 1545 print ' Equivalence of 3D variables provided _______' 1546 gen.printing_dictionary(vars3D) 1547 quit(-1) 1548 1549 ua = ncobj.variables['U'][:] 1550 va = ncobj.variables['V'][:] 1551 sina = ncobj.variables['SINALPHA'][:] 1552 cosa = ncobj.variables['COSALPHA'][:] 1553 1554 vals, dims, vdims = compute_WRFva(ua, va, sina, cosa, indims, invardims) 1555 self.values = vals 1556 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1557 dictdims['lon']] 1558 self.units = ncobj.variables['U'].units 1559 1560 elif Wdiag == 'vas': 1561 """ Computing 10m y-wind 1562 """ 1563 vn = 'uas' 1564 CFsfcvars = ['uas', 'vas'] 1565 for vsf in CFsfcvars: 1566 if not sfcvars.has_key(vsf): 1567 print gen.errormsg 1568 print ' ' + fname + ": missing variable '" + vsf + \ 1569 "' attribution to compute '" + vn + "' !!" 1570 print ' Equivalence of sfc variables provided _______' 1571 gen.printing_dictionary(sfcvars) 1572 quit(-1) 1573 1574 uas = ncobj.variables['U10'][:] 1575 vas = ncobj.variables['V10'][:] 1576 sina = ncobj.variables['SINALPHA'][:] 1577 cosa = ncobj.variables['COSALPHA'][:] 1578 1579 vals,dims,vdims = compute_WRFvas(uas, vas, sina, cosa, indims, invardims) 1580 self.values = vals 1581 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1582 dictdims['lon']] 1583 self.units = ncobj.variables['U10'].units 1584 1585 elif Wdiag == 'wd': 1586 """ Computing wind direction 1587 """ 1588 vn = 'wd' 1589 CF3Dvars = ['ua', 'va'] 1590 for v3D in CF3Dvars: 1591 if not vars3D.has_key(v3D): 1592 print gen.errormsg 1593 print ' ' + fname + ": missing variable '" + v3D + \ 1594 "' attribution to compute '" + vn + "' !!" 1595 print ' Equivalence of 3D variables provided _______' 1596 gen.printing_dictionary(vars3D) 1597 quit(-1) 1598 1599 ua = ncobj.variables['U10'][:] 1600 va = ncobj.variables['V10'][:] 1601 sina = ncobj.variables['SINALPHA'][:] 1602 cosa = ncobj.variables['COSALPHA'][:] 1603 1604 vals, dims, vdims = compute_WRFwd(ua, va, sina, cosa, indims, invardims) 1605 self.values = vals 1606 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1607 dictdims['lon']] 1608 self.units = 'degree' 1609 1610 elif Wdiag == 'ws': 1611 """ Computing wind speed 1612 """ 1613 vn = 'ws' 1614 CF3Dvars = ['ua', 'va'] 1615 for v3D in CF3Dvars: 1616 if not vars3D.has_key(v3D): 1617 print gen.errormsg 1618 print ' ' + fname + ": missing variable '" + v3D + \ 1619 "' attribution to compute '" + vn + "' !!" 1620 print ' Equivalence of 3D variables provided _______' 1621 gen.printing_dictionary(vars3D) 1622 quit(-1) 1623 1624 ua = ncobj.variables['U10'][:] 1625 va = ncobj.variables['V10'][:] 1626 1627 self.values = var_ws(ua, va) 1628 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1629 dictdims['lon']] 1630 self.units = ncobj.variables['U10'].units 1631 1632 elif Wdiag == 'zg': 1633 """ Computing geopotential 1634 """ 1635 vn = 'zg' 1636 1637 self.values = ncobj.variables['PHB'][:] + ncobj.variables['PH'][:] 1638 self.dims = [dictdims['time'], dictdims['plev'], dictdims['lat'], \ 1639 dictdims['lon']] 1640 self.units = ncobj.variables['PHB'].units 1641 1642 else: 1643 print gen.errormsg 1644 print ' ' + fname + ": variable '" + Wdiag + "' not ready !!" 1645 print ' available ones:', Wavailablediags 1646 quit(-1)
Note: See TracChangeset
for help on using the changeset viewer.