- Timestamp:
- Mar 1, 2018, 12:48:27 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r1783 r1784 34 34 # Forcompute_zmla_gen: Function to compute the boundary layer height following a generic method with Fortran 35 35 # Forcompute_zwind: Function to compute the wind at a given height following the power law method 36 # Forcompute_zwind_log: Function to compute the wind at a given height following the logarithmic law method 36 37 # Forcompute_zwindMO: Function to compute the wind at a given height following the Monin-Obukhov theory 37 38 # W_diagnostic: Class to compute WRF diagnostics variables … … 948 949 vas=vas.transpose(), sina=sina.transpose(), cosa=cosa.transpose(), \ 949 950 zextrap=zval, d1=dx, d2=dy, d3=dz, d4=dt) 951 var1 = pvar1.transpose() 952 var2 = pvar2.transpose() 953 else: 954 print errormsg 955 print ' ' + fname + ': rank', len(ua.shape), 'not ready !!' 956 print ' it only computes 4D [t,z,y,x] rank values' 957 quit(-1) 958 959 return var1, var2, vardims, varvdims 960 961 def Forcompute_zwind_log(ua, va, z, uas, vas, sina, cosa, zval, dimns, dimvns): 962 """ Function to compute the wind at a given height following the logarithmic law method 963 Forcompute_zwind(ua, va, zsl, uas, vas, hgt, sina, cosa, zval, dimns, dimvns) 964 [ua]= x-component of unstaggered 3D wind (assuming [[t],z,y,x]) [ms-1] 965 [va]= y-component of unstaggered 3D wind (assuming [[t],z,y,x]) [ms-1] 966 [z]= height above surface [m] 967 [uas]= x-component of unstaggered 10 m wind (assuming [[t],z,y,x]) [ms-1] 968 [vas]= y-component of unstaggered 10 m wind (assuming [[t],z,y,x]) [ms-1] 969 [sina]= local sine of map rotation [1.] 970 [cosa]= local cosine of map rotation [1.] 971 [zval]= desired height for winds [m] 972 [dimns]= list of the name of the dimensions of [ua] 973 [dimvns]= list of the name of the variables with the values of the 974 dimensions of [ua] 975 """ 976 fname = 'Forcompute_zwind_log' 977 978 vardims = dimns[:] 979 varvdims = dimvns[:] 980 981 if len(ua.shape) == 4: 982 var1= np.zeros((ua.shape[0],ua.shape[2],ua.shape[3]), dtype=np.float) 983 var2= np.zeros((ua.shape[0],ua.shape[2],ua.shape[3]), dtype=np.float) 984 985 dx = ua.shape[3] 986 dy = ua.shape[2] 987 dz = ua.shape[1] 988 dt = ua.shape[0] 989 vardims.pop(1) 990 varvdims.pop(1) 991 992 pvar1, pvar2= fdin.module_fordiagnostics.compute_zwind_log4d( \ 993 ua=ua.transpose(), va=va[:].transpose(), z=z[:].transpose(), \ 994 uas=uas.transpose(), vas=vas.transpose(), sina=sina.transpose(), \ 995 cosa=cosa.transpose(), zextrap=zval, d1=dx, d2=dy, d3=dz, d4=dt) 950 996 var1 = pvar1.transpose() 951 997 var2 = pvar2.transpose() -
trunk/tools/diagnostics.inf
r1783 r1784 35 35 va, WRFva, U@V@SINALPHA@COSALPHA 36 36 uavaz, WRFzwind, U@V@WRFz@U10@V10@SINALPHA@COSALPHA@z=100. 37 uavaz, WRFzwind_log, U@V@WRFz@U10@V10@SINALPHA@COSALPHA@z=100. 37 38 uavaz, WRFzwindMO, UST@ZNT@RMOL@U10@V10@SINALPHA@COSALPHA@z=100. 38 39 wa, OMEGAw, vitw@pres@temp -
trunk/tools/diagnostics.py
r1783 r1784 81 81 'WRFmrso', 'WRFp', \ 82 82 'WRFpsl_ptarget', 'WRFrvors', 'WRFslw', 'ws', 'wds', 'wss', 'WRFheight', \ 83 'WRFheightrel', 'WRFua', 'WRFva', 'WRFzwind', 'WRFzwind MO']83 'WRFheightrel', 'WRFua', 'WRFva', 'WRFzwind', 'WRFzwind_log', 'WRFzwindMO'] 84 84 85 85 methods = ['accum', 'deaccum'] … … 1146 1146 ncvar.insert_variable(ncobj, 'zmla', diagout, diagoutd, diagoutvd, newnc) 1147 1147 1148 # WRFzwind wind extrapolation at a given h ieght computation from WRF U, V, WRFz,1149 # U 10, V10, SINALPHA, COSALPHA, z=[zval]1148 # WRFzwind wind extrapolation at a given height using power law computation from WRF 1149 # U, V, WRFz, U10, V10, SINALPHA, COSALPHA, z=[zval] 1150 1150 elif diagn == 'WRFzwind': 1151 1151 var0 = ncobj.variables[depvars[0]][:] … … 1178 1178 ncvar.insert_variable(ncobj, 'vaz', diagout2, diagoutd, diagoutvd, newnc) 1179 1179 1180 # WRFzwind wind extrapolation at a given hieght using logarithmic law computation 1181 # from WRF U, V, WRFz, U10, V10, SINALPHA, COSALPHA, z=[zval] 1182 elif diagn == 'WRFzwind_log': 1183 var0 = ncobj.variables[depvars[0]][:] 1184 var1 = ncobj.variables[depvars[1]][:] 1185 var2 = WRFz 1186 var3 = ncobj.variables[depvars[3]][:] 1187 var4 = ncobj.variables[depvars[4]][:] 1188 var5 = ncobj.variables[depvars[5]][0,:,:] 1189 var6 = ncobj.variables[depvars[6]][0,:,:] 1190 var7 = np.float(depvars[7].split('=')[1]) 1191 1192 # un-staggering 3D winds 1193 unstgdims = [var0.shape[0], var0.shape[1], var0.shape[2], var0.shape[3]-1] 1194 va = np.zeros(tuple(unstgdims), dtype=np.float) 1195 unvar0 = np.zeros(tuple(unstgdims), dtype=np.float) 1196 unvar1 = np.zeros(tuple(unstgdims), dtype=np.float) 1197 unvar0 = 0.5*(var0[:,:,:,0:var0.shape[3]-1] + var0[:,:,:,1:var0.shape[3]]) 1198 unvar1 = 0.5*(var1[:,:,0:var1.shape[2]-1,:] + var1[:,:,1:var1.shape[2],:]) 1199 1200 diagout1, diagout2, diagoutd, diagoutvd = diag.Forcompute_zwind_log(unvar0, \ 1201 unvar1, var2, var3, var4, var5, var6, var7, dnames, dvnames) 1202 1203 # Removing the nonChecking variable-dimensions from the initial list 1204 varsadd = [] 1205 for nonvd in NONchkvardims: 1206 if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd) 1207 varsadd.append(nonvd) 1208 1209 ncvar.insert_variable(ncobj, 'uaz', diagout1, diagoutd, diagoutvd, newnc) 1210 ncvar.insert_variable(ncobj, 'vaz', diagout2, diagoutd, diagoutvd, newnc) 1211 1180 1212 # WRFzwindMO wind extrapolation at a given height computation using Monin-Obukhow 1181 1213 # theory from WRF UST, ZNT, RMOL, U10, V10, SINALPHA, COSALPHA, z=[zval] 1214 # NOTE: only useful for [zval] < 80. m 1182 1215 elif diagn == 'WRFzwindMO': 1183 1216 var0 = ncobj.variables[depvars[0]][:] -
trunk/tools/module_ForDiagnostics.f90
r1783 r1784 29 29 ! compute_zmla_generic4D: Subroutine to compute pbl-height following a generic method 30 30 ! compute_zwind4D: Subroutine to compute extrapolate the wind at a given height following the 'power law' methodology 31 ! compute_zwind_log4D: Subroutine to compute extrapolate the wind at a given height following the 'logarithmic law' methodology 31 32 ! compute_zwindMCO3D: Subroutine to compute extrapolate the wind at a given height following the 'power law' methodolog 32 33 … … 681 682 END SUBROUTINE compute_zwind4D 682 683 684 SUBROUTINE compute_zwind_log4D(ua, va, z, uas, vas, sina, cosa, zextrap, uaz, vaz, d1, d2, d3, d4) 685 ! Subroutine to compute extrapolate the wind at a given height following the 'logarithmic law' methodology 686 687 IMPLICIT NONE 688 689 INTEGER, INTENT(in) :: d1, d2, d3, d4 690 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: ua, va, z 691 REAL(r_k), DIMENSION(d1,d2,d4), INTENT(in) :: uas, vas 692 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: sina, cosa 693 REAL(r_k), INTENT(in) :: zextrap 694 REAL(r_k), DIMENSION(d1,d2,d4), INTENT(out) :: uaz, vaz 695 696 ! Local 697 INTEGER :: i, j, it 698 699 !!!!!!! Variables 700 ! tpot: potential air temperature [K] 701 ! qratio: water vapour mixing ratio [kgkg-1] 702 ! z: height above surface [m] 703 ! sina, cosa: local sine and cosine of map rotation [1.] 704 ! zmla3D: boundary layer height from surface [m] 705 706 fname = 'compute_zwind_log4D' 707 708 DO i=1, d1 709 DO j=1, d2 710 DO it=1, d4 711 CALL var_zwind_log(d3, ua(i,j,:,it), va(i,j,:,it), z(i,j,:,it), uas(i,j,it), vas(i,j,it), & 712 sina(i,j), cosa(i,j), zextrap, uaz(i,j,it), vaz(i,j,it)) 713 END DO 714 END DO 715 END DO 716 717 RETURN 718 719 END SUBROUTINE compute_zwind_log4D 720 683 721 SUBROUTINE compute_zwindMO3D(d1, d2, d3, ust, znt, rmol, uas, vas, sina, cosa, newz, uznew, vznew) 684 722 ! Subroutine to compute extrapolate the wind at a given height following the 'power law' methodology 723 ! NOTE: only usefull for newz < 80. m 685 724 686 725 IMPLICIT NONE -
trunk/tools/module_ForDiagnosticsVars.f90
r1783 r1784 30 30 ! var_zmla_generic: Subroutine to compute pbl-height following a generic method 31 31 ! var_zwind: Subroutine to extrapolate the wind at a given height following the 'power law' methodology 32 ! var_zwind_log: Subroutine to extrapolate the wind at a given height following the 'logarithmic law' methodology 32 33 ! var_zwind_MOtheor: Subroutine of wind extrapolation following Moin-Obukhov theory 33 34 ! VirtualTemp1D: Function for 1D calculation of virtual temperaure … … 1111 1112 END SUBROUTINE var_zwind 1112 1113 1114 SUBROUTINE var_zwind_log(d1, u, v, z, u10, v10, sa, ca, newz, unewz, vnewz) 1115 ! Subroutine to extrapolate the wind at a given height following the 'logarithmic law' methodology 1116 ! wss[newz] = wss[z1]*(newz/z1)**alpha 1117 ! alpha = (ln(wss[z2])-ln(wss[z1]))/(ln(z2)-ln(z1)) 1118 ! AFTER: Phd Thesis: 1119 ! Benedicte Jourdier. Ressource eolienne en France metropolitaine : methodes dâevaluation du 1120 ! potentiel, variabilite et tendances. Climatologie. Ecole Doctorale Polytechnique, 2015. French 1121 ! 1122 IMPLICIT NONE 1123 1124 INTEGER, INTENT(in) :: d1 1125 REAL(r_k), DIMENSION(d1), INTENT(in) :: u,v,z 1126 REAL(r_k), INTENT(in) :: u10, v10, sa, ca, newz 1127 REAL(r_k), INTENT(out) :: unewz, vnewz 1128 1129 ! Local 1130 INTEGER :: inear 1131 REAL(r_k) :: zaground 1132 REAL(r_k), DIMENSION(2) :: v1, v2, zz, logz0, uvnewz 1133 1134 !!!!!!! Variables 1135 ! u,v: vertical wind components [ms-1] 1136 ! z: height above surface on half-mass levels [m] 1137 ! u10,v10: 10-m wind components [ms-1] 1138 ! sa, ca: local sine and cosine of map rotation [1.] 1139 ! newz: desired height above grpund of extrapolation 1140 ! unewz,vnewz: Wind compoonents at the given height [ms-1] 1141 1142 fname = 'var_zwind_log' 1143 1144 !PRINT *,' ilev zaground newz z[ilev+1] z[ilev+2] _______' 1145 IF (z(1) < newz ) THEN 1146 DO inear = 1,d1-2 1147 ! L. Fita, CIMA. Feb. 2018 1148 !! Choose between extra/inter-polate. Maybe better interpolate? 1149 ! Here we extrapolate from two closest lower levels 1150 !zaground = z(inear+2) 1151 zaground = z(inear+1) 1152 !PRINT *, inear, z(inear), newz, z(inear+1), z(inear+2) 1153 IF ( zaground >= newz) EXIT 1154 END DO 1155 ELSE 1156 !PRINT *, 1, z(1), newz, z(2), z(3), ' z(1) > newz' 1157 inear = d1 - 2 1158 END IF 1159 1160 IF (inear == d1-2) THEN 1161 ! No vertical pair of levels is below newz, using 10m wind as first value and the first level as the second 1162 v1(1) = u10 1163 v1(2) = v10 1164 v2(1) = u(1) 1165 v2(2) = v(1) 1166 zz(1) = 10. 1167 zz(2) = z(1) 1168 ELSE 1169 v1(1) = u(inear) 1170 v1(2) = v(inear) 1171 v2(1) = u(inear+1) 1172 v2(2) = v(inear+1) 1173 zz(1) = z(inear) 1174 zz(2) = z(inear+1) 1175 END IF 1176 1177 ! Computing for each component 1178 logz0 = (v2*LOG(zz(1))-v1*LOG(zz(2)))/(v2-v1) 1179 1180 uvnewz = v2*(LOG(newz)-logz0)/(LOG(zz(2))-logz0) 1181 ! Earth-rotation 1182 unewz = uvnewz(1)*ca - uvnewz(2)*sa 1183 vnewz = uvnewz(1)*sa + uvnewz(2)*ca 1184 1185 !PRINT *,' result vz:', uvnewz 1186 1187 !STOP 1188 1189 RETURN 1190 1191 END SUBROUTINE var_zwind_log 1192 1113 1193 SUBROUTINE var_zwind_MOtheor(ust, znt, rmol, u10, v10, sa, ca, newz, uznew, vznew) 1114 1194 ! Subroutine of wind extrapolation following Moin-Obukhov theory R. B. Stull, 1988, 1115 1195 ! Springer (p376-383) 1196 ! Only usefull for newz < 80. m 1116 1197 1117 1198 IMPLICIT NONE
Note: See TracChangeset
for help on using the changeset viewer.