- Timestamp:
- Feb 16, 2018, 3:17:02 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r1776 r1777 911 911 912 912 913 def Forcompute_zwind(ua, va, z sl, uas, vas, hgt, sina, cosa, zval, dimns, dimvns):913 def Forcompute_zwind(ua, va, z, uas, vas, sina, cosa, zval, dimns, dimvns): 914 914 """ Function to compute the wind at a given height following the power law method 915 915 Forcompute_zwind(ua, va, zsl, uas, vas, hgt, sina, cosa, zval, dimns, dimvns) 916 916 [ua]= x-component of unstaggered 3D wind (assuming [[t],z,y,x]) [ms-1] 917 917 [va]= y-component of unstaggered 3D wind (assuming [[t],z,y,x]) [ms-1] 918 [z sl]= height above sea level[m]918 [z]= height above surface [m] 919 919 [uas]= x-component of unstaggered 10 m wind (assuming [[t],z,y,x]) [ms-1] 920 920 [vas]= y-component of unstaggered 10 m wind (assuming [[t],z,y,x]) [ms-1] 921 [hgt]= topographical height (assuming [m]922 921 [sina]= local sine of map rotation [1.] 923 922 [cosa]= local cosine of map rotation [1.] … … 944 943 945 944 pvar1, pvar2= fdin.module_fordiagnostics.compute_zwind4d(ua=ua.transpose(), \ 946 va=va[:].transpose(), z sl=zsl[:].transpose(), uas=uas.transpose(),\947 vas=vas.transpose(), hgt=hgt.transpose(), sina=sina.transpose(),\948 cosa=cosa.transpose(),zextrap=zval, d1=dx, d2=dy, d3=dz, d4=dt)945 va=va[:].transpose(), z=z[:].transpose(), uas=uas.transpose(), \ 946 vas=vas.transpose(), sina=sina.transpose(), cosa=cosa.transpose(), \ 947 zextrap=zval, d1=dx, d2=dy, d3=dz, d4=dt) 949 948 var1 = pvar1.transpose() 950 949 var2 = pvar2.transpose() -
trunk/tools/diagnostics.inf
r1776 r1777 34 34 ua, WRFua, U@V@SINALPHA@COSALPHA 35 35 va, WRFva, U@V@SINALPHA@COSALPHA 36 uavaz, WRFzwind, U@V@WRF geop@U10@V10@HGT@SINALPHA@COSALPHA@z=100.36 uavaz, WRFzwind, U@V@WRFz@U10@V10@SINALPHA@COSALPHA@z=100. 37 37 wa, OMEGAw, vitw@pres@temp 38 38 wds, TSwds, u@v -
trunk/tools/diagnostics.py
r1776 r1777 6 6 # ciclad: f2py --f90flags="-fPIC" --f90exec=/usr/bin/gfortran -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -L/usr/lib64/ -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -m module_ForDiagnostics -c module_generic.F90 module_ForDiagnosticsVars.F90 module_ForDiagnostics.F90 >& run_f2py.log 7 7 8 ## e.g. # diagnostics.py -d 'Time@ time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' -v 'clt|CLDFRA,cllmh|CLDFRA@WRFp,RAINTOT|RAINC@RAINNC@XTIME' -f WRF_LMDZ/NPv31/wrfout_d01_1980-03-01_00:00:008 ## e.g. # diagnostics.py -d 'Time@WRFtime,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' -v 'clt|CLDFRA,cllmh|CLDFRA@WRFp,RAINTOT|RAINC@RAINNC@XTIME' -f WRF_LMDZ/NPv31/wrfout_d01_1980-03-01_00:00:00 9 9 ## e.g. # diagnostics.py -f /home/lluis/PY/diagnostics.inf -d variable_combo -v WRFprc 10 10 … … 90 90 'WRFp', 'WRFtd', \ 91 91 'WRFpos', 'WRFprc', 'WRFprls', 'WRFrh', 'LMDZrh', 'LMDZrhs', 'WRFrhs', 'WRFrvors', \ 92 'WRFt', 'WRFtime', 'WRFua', 'WRFva', 'WRFwds', 'WRFwss', 'WRFheight' ]92 'WRFt', 'WRFtime', 'WRFua', 'WRFva', 'WRFwds', 'WRFwss', 'WRFheight', 'WRFz'] 93 93 94 94 NONchkvardims = ['WRFtime'] … … 124 124 WRFpos_compute = False 125 125 WRFtime_compute = False 126 WRFz_compute = False 126 127 127 128 # File creation … … 147 148 if dnv == 'WRFpos': WRFpos_compute = True 148 149 if dnv == 'WRFtime': WRFtime_compute = True 150 if dnv == 'WRFz':WRFz_compute = True 149 151 150 152 # diagnostics to compute … … 163 165 if depvars == 'WRFpos': WRFpos_compute = True 164 166 if depvars == 'WRFtime': WRFtime_compute = True 167 if depvars == 'WRFz': WRFz_compute = True 165 168 else: 166 169 depvars = diags[idiag].split('|')[1].split('@') … … 173 176 if gen.searchInlist(depvars, 'WRFpos'): WRFpos_compute = True 174 177 if gen.searchInlist(depvars, 'WRFtime'): WRFtime_compute = True 178 if gen.searchInlist(depvars, 'WRFz'): WRFz_compute = True 175 179 176 180 # Dictionary with the new computed variables to be able to add them … … 325 329 dictcompvars['WRFtime'] = {'name': 'time', 'standard_name': 'time', \ 326 330 'long_name': 'time', 'units': tunits, 'calendar': 'gregorian'} 331 332 if WRFz_compute: 333 print ' ' + main + ': Retrieving z: height above surface value from WRF as ' + \ 334 'unstagger(PH + PHB)/9.8-hgt' 335 dimv = ncobj.variables['PH'].shape 336 WRFzg = (ncobj.variables['PH'][:] + ncobj.variables['PHB'][:])/9.8 337 338 unzgd = (dimv[0], dimv[1]-1, dimv[2], dimv[3]) 339 unzg = np.zeros(unzgd, dtype=np.float) 340 unzg = 0.5*(WRFzg[:,0:dimv[1]-1,:,:] + WRFzg[:,1:dimv[1],:,:]) 341 342 WRFz = np.zeros(unzgd, dtype=np.float) 343 for iz in range(dimv[1]-1): 344 WRFz[:,iz,:,:] = unzg[:,iz,:,:] - ncobj.variables['HGT'][:] 345 346 # Attributes of the variable 347 Vvals = gen.variables_values('WRFz') 348 dictcompvars['WRFz'] = {'name': Vvals[0], 'standard_name': Vvals[1], \ 349 'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]} 327 350 328 351 ### ## # … … 1123 1146 ncvar.insert_variable(ncobj, 'zmla', diagout, diagoutd, diagoutvd, newnc) 1124 1147 1125 # WRFzwind wind extrapolation at a given hieght computation from WRF U, V, WRF geop,1126 # U10, V10, HGT,SINALPHA, COSALPHA, z=[zval]1148 # WRFzwind wind extrapolation at a given hieght computation from WRF U, V, WRFz, 1149 # U10, V10, SINALPHA, COSALPHA, z=[zval] 1127 1150 elif diagn == 'WRFzwind': 1128 1151 var0 = ncobj.variables[depvars[0]][:] 1129 1152 var1 = ncobj.variables[depvars[1]][:] 1130 dimz = var0.shape[1] 1131 var2 = WRFgeop[:,1:dimz+1,:,:]/9.8 1153 var2 = WRFz 1132 1154 var3 = ncobj.variables[depvars[3]][:] 1133 1155 var4 = ncobj.variables[depvars[4]][:] 1134 1156 var5 = ncobj.variables[depvars[5]][0,:,:] 1135 1157 var6 = ncobj.variables[depvars[6]][0,:,:] 1136 var7 = ncobj.variables[depvars[7]][0,:,:] 1137 var8 = np.float(depvars[8].split('=')[1]) 1158 var7 = np.float(depvars[7].split('=')[1]) 1138 1159 1139 1160 # un-staggering 3D winds … … 1146 1167 1147 1168 diagout1, diagout2, diagoutd, diagoutvd = diag.Forcompute_zwind(unvar0, \ 1148 unvar1, var2, var3, var4, var5, var6, var7, var8,dnames, dvnames)1169 unvar1, var2, var3, var4, var5, var6, var7, dnames, dvnames) 1149 1170 1150 1171 # Removing the nonChecking variable-dimensions from the initial list -
trunk/tools/module_ForDiagnostics.f90
r1776 r1777 643 643 END SUBROUTINE compute_zmla_generic4D 644 644 645 SUBROUTINE compute_zwind4D(ua, va, z sl, uas, vas, hgt, sina, cosa, zextrap, uaz, vaz, d1, d2, d3, d4)645 SUBROUTINE compute_zwind4D(ua, va, z, uas, vas, sina, cosa, zextrap, uaz, vaz, d1, d2, d3, d4) 646 646 ! Subroutine to compute extrapolate the wind at a given height following the 'power law' methodology 647 647 … … 649 649 650 650 INTEGER, INTENT(in) :: d1, d2, d3, d4 651 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: ua, va, z sl651 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: ua, va, z 652 652 REAL(r_k), DIMENSION(d1,d2,d4), INTENT(in) :: uas, vas 653 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: hgt,sina, cosa653 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: sina, cosa 654 654 REAL(r_k), INTENT(in) :: zextrap 655 655 REAL(r_k), DIMENSION(d1,d2,d4), INTENT(out) :: uaz, vaz … … 661 661 ! tpot: potential air temperature [K] 662 662 ! qratio: water vapour mixing ratio [kgkg-1] 663 ! z: height above sea level [m] 664 ! hgt: terrain height [m] 663 ! z: height above surface [m] 665 664 ! sina, cosa: local sine and cosine of map rotation [1.] 666 665 ! zmla3D: boundary layer height from surface [m] … … 671 670 DO j=1, d2 672 671 DO it=1, d4 673 CALL var_zwind(d3, ua(i,j,:,it), va(i,j,:,it), z sl(i,j,:,it), uas(i,j,it), vas(i,j,it),&674 hgt(i,j),sina(i,j), cosa(i,j), zextrap, uaz(i,j,it), vaz(i,j,it))672 CALL var_zwind(d3, ua(i,j,:,it), va(i,j,:,it), z(i,j,:,it), uas(i,j,it), vas(i,j,it), & 673 sina(i,j), cosa(i,j), zextrap, uaz(i,j,it), vaz(i,j,it)) 675 674 END DO 676 675 END DO -
trunk/tools/module_ForDiagnosticsVars.f90
r1776 r1777 1027 1027 END SUBROUTINE var_zmla_generic 1028 1028 1029 SUBROUTINE var_zwind(d1, u, v, z, u10, v10, sa, ca, topo,newz, unewz, vnewz)1029 SUBROUTINE var_zwind(d1, u, v, z, u10, v10, sa, ca, newz, unewz, vnewz) 1030 1030 ! Subroutine to extrapolate the wind at a given height following the 'power law' methodology 1031 1031 ! wss[newz] = wss[z1]*(newz/z1)**alpha … … 1039 1039 INTEGER, INTENT(in) :: d1 1040 1040 REAL(r_k), DIMENSION(d1), INTENT(in) :: u,v,z 1041 REAL(r_k), INTENT(in) :: u10, v10, topo,sa, ca, newz1041 REAL(r_k), INTENT(in) :: u10, v10, sa, ca, newz 1042 1042 REAL(r_k), INTENT(out) :: unewz, vnewz 1043 1043 … … 1049 1049 !!!!!!! Variables 1050 1050 ! u,v: vertical wind components [ms-1] 1051 ! z: height above surface [m]1051 ! z: height above surface on half-mass levels [m] 1052 1052 ! u10,v10: 10-m wind components [ms-1] 1053 ! topo: topographical height [m]1054 1053 ! sa, ca: local sine and cosine of map rotation [1.] 1055 1054 ! newz: desired height above grpund of extrapolation … … 1058 1057 fname = 'var_zwind' 1059 1058 1060 PRINT *,' ilev zaground newz z[ilev+1] z[ilev+2] _______'1059 !PRINT *,' ilev zaground newz z[ilev+1] z[ilev+2] _______' 1061 1060 IF (z(1) < newz ) THEN 1062 1061 DO inear = 1,d1-2 1063 1062 zaground = z(inear+2) 1064 PRINT *, inear, z(inear), newz, z(inear+1), z(inear+2)1063 !PRINT *, inear, z(inear), newz, z(inear+1), z(inear+2) 1065 1064 IF ( zaground >= newz) EXIT 1066 1065 END DO 1067 1066 ELSE 1068 PRINT *, 1, z(1), newz, z(2), z(3), ' z(1) > newz'1067 !PRINT *, 1, z(1), newz, z(2), z(3), ' z(1) > newz' 1069 1068 inear = d1 - 2 1070 1069 END IF … … 1083 1082 v2(1) = u(inear+1) 1084 1083 v2(2) = v(inear+1) 1085 zz(1) = z(inear) - topo1086 zz(2) = z(inear+1) - topo1084 zz(1) = z(inear) 1085 zz(2) = z(inear+1) 1087 1086 END IF 1088 1087 1089 1088 ! Computing for each component 1090 1089 alpha = (LOG(ABS(v2))-LOG(ABS(v1)))/(LOG(zz(2))-LOG(zz(1))) 1091 PRINT *,' Computing with v1:', v1, ' ms-1 v2:', v2, ' ms-1'1092 PRINT *,' z1:', zz(1), 'm z2:', zz(2), ' m'1093 PRINT *,' alhpa u:', alpha(1), ' alpha 2:', alpha(2)1090 !PRINT *,' Computing with v1:', v1, ' ms-1 v2:', v2, ' ms-1' 1091 !PRINT *,' z1:', zz(1), 'm z2:', zz(2), ' m' 1092 !PRINT *,' alhpa u:', alpha(1), ' alpha 2:', alpha(2) 1094 1093 1095 1094 uvnewz = v1*(newz/zz(1))**alpha … … 1098 1097 vnewz = uvnewz(1)*sa + uvnewz(2)*ca 1099 1098 1100 PRINT *,' result vz:', uvnewz1099 !PRINT *,' result vz:', uvnewz 1101 1100 1102 1101 !STOP -
trunk/tools/variables_values.dat
r1776 r1777 643 643 Y, y, y, 0., 100., y, -, Blues 644 644 z, z, z, 0., 100., z, -, Greens 645 WRFz, z, height, 0., 80000., height|above|surface, m, rainbow 645 646 Z, z, z, 0., 100., z, -, Greens 646 647 zhgt, zhgt, height, 0., 50000., sea|level|altitude, m, rainbow
Note: See TracChangeset
for help on using the changeset viewer.