Changeset 339 in lmdz_wrf for trunk/tools/validation_sim.py
- Timestamp:
- Mar 1, 2015, 7:49:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r338 r339 2 2 # L. Fita, LMD-Jussieu. February 2015 3 3 ## e.g. sfcEneAvigon # validation_sim.py -d X@west_east@None,Y@south_north@None,T@Time@time -D X@XLONG@longitude,Y@XLAT@latitude,T@time@time -k single-station -l 4.878773,43.915876,12. -o /home/lluis/DATA/obs/HyMeX/IOP15/sfcEnergyBalance_Avignon/OBSnetcdf.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v HFX@H,LH@LE,GRDFLX@G 4 ## e.g. AIREP # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@time -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@alti,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/AIREP/2012/10/AIREP_121018.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFt@t 4 ## e.g. AIREP # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@time -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@alti,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/AIREP/2012/10/AIREP_121018.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFt@t,WRFtd@td,WRFws@u,WRFwd@dd 5 5 ## e.g. ATRCore # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@CFtime -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@altitude,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/ATRCore/V3/ATR_1Hz-HYMEXBDD-SOP1-v3_20121018_as120051.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFT@air_temperature@subc@273.15 6 6 ## e.g. BAMED # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@CFtime -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@altitude,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/BAMED/BAMED_SOP1_B12_TOT5.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFT@tas_north … … 577 577 'WRFrh': relative humidty fom WRF variables 578 578 'WRFt': temperature from WRF variables 579 'WRFtd': dew-point temperature from WRF variables 580 'WRFws': wind speed from WRF variables 581 'WRFwd': wind direction from WRF variables 579 582 'WRFz': height from WRF variables 580 583 """ … … 642 645 shape = ncobj.variables['P'].shape 643 646 644 645 647 elif varn == 'WRFt': 646 648 # print ' ' + main + ': computing temperature from WRF as inv_potT(T + 300) ...' … … 651 653 dimensions = ncobj.variables['T'].dimensions 652 654 shape = ncobj.variables['P'].shape 655 656 elif varn == 'WRFtd': 657 # print ' ' + main + ': computing dew-point temperature from WRF as inv_potT(T + 300) and Tetens...' 658 # tacking from: http://en.wikipedia.org/wiki/Dew_point 659 p0=100000. 660 p=ncobj.variables['P'][:] + ncobj.variables['PB'][:] 661 662 temp = (ncobj.variables['T'][:] + 300.)*(p/p0)**(2./7.) 663 664 qv = ncobj.variables['QVAPOR'][:] 665 666 tk = temp - 273.15 667 data1 = 10.*0.6112*np.exp(17.67*(tk-273.16)/(tk-29.65)) 668 data2 = 0.622*data1/(0.01*p-(1.-0.622)*data1) 669 670 rh = qv/data2 671 672 pa = rh * data1/100. 673 varNOcheckv = 257.44*np.log(pa/6.1121)/(18.678-np.log(pa/6.1121)) 674 675 dimensions = ncobj.variables['T'].dimensions 676 shape = ncobj.variables['P'].shape 677 678 elif varn == 'WRFws': 679 # print ' ' + main + ': computing wind speed from WRF as SQRT(U**2 + V**2) ...' 680 uwind = ncobj.variables['U'][:] 681 vwind = ncobj.variables['V'][:] 682 dx = uwind.shape[3] 683 dy = vwind.shape[2] 684 685 # de-staggering 686 ua = 0.5*(uwind[:,:,:,0:dx-1] + uwind[:,:,:,1:dx]) 687 va = 0.5*(vwind[:,:,0:dy-1,:] + vwind[:,:,1:dy,:]) 688 689 varNOcheckv = np.sqrt(ua*ua + va*va) 690 dimensions = tuple(['Time','bottom_top','south_north','west_east']) 691 shape = ua.shape 692 693 elif varn == 'WRFwd': 694 # print ' ' + main + ': computing wind direction from WRF as ATAN2PI(V,U) ...' 695 uwind = ncobj.variables['U'][:] 696 vwind = ncobj.variables['V'][:] 697 dx = uwind.shape[3] 698 dy = vwind.shape[2] 699 700 # de-staggering 701 ua = 0.5*(uwind[:,:,:,0:dx-1] + uwind[:,:,:,1:dx]) 702 va = 0.5*(vwind[:,:,0:dy-1,:] + vwind[:,:,1:dy,:]) 703 704 theta = np.arctan2(ua, va) 705 dimensions = tuple(['Time','bottom_top','south_north','west_east']) 706 shape = ua.shape 707 varNOcheckv = 360.*(1. + theta/(2.*np.pi)) 708 709 dimensions = ncobj.variables['U'].dimensions 710 shape = ncobj.variables['U'].shape 653 711 654 712 elif varn == 'WRFz': … … 660 718 661 719 else: 662 print erro msg720 print errormsg 663 721 print ' ' + fname + ": variable '" + varn + "' nor ready !!" 664 722 quit(-1) … … 685 743 '[constant] to variables values; divc,[constant]: divide by [constant] to ' + \ 686 744 'variables values' 687 varNOcheck = ['WRFdens', 'WRFght', 'WRFp', 'WRFrh', 'WRFt', 'WRFz'] 745 varNOcheck = ['WRFdens', 'WRFght', 'WRFp', 'WRFrh', 'WRFt', 'WRFtd', 'WRFws', \ 746 'WRFwd', 'WRFz'] 688 747 varNOcheckinf = "'WRFdens': air density from WRF variables; 'WRFght': geopotential"+ \ 689 748 " height from WRF variables; 'WRFp': pressure from WRF variables; 'WRFrh': " + \ 690 "relative humidty fom WRF variables; 'WRFt': temperature from WRF variables; " + \ 691 "'WRFz': height from WRF variables" 749 "relative humidty fom WRF variables; 'WRFt': temperature from WRF variables; " + \ 750 "'WRFtd': dew-point temperature from WRF variables; 'WRFws': wind speed from " + \ 751 "WRF variables; 'WRFwd': wind speed direction from WRF variables; 'WRFz': " + \ 752 "height from WRF variables" 692 753 693 754 dimshelp = "[DIM]@[simdim]@[obsdim] ',' list of couples of dimensions names from " + \ … … 1092 1153 dims['T'][0]+':'+str(coindtvalues[it][0]) 1093 1154 slicevar, dimslice = slice_variable(ovsim, slicev) 1094 simobsvalues.append([ slicevar, ovobs[coindtvalues[it,1]]])1095 1155 slicev = dims['X'][0] + ':' + str(trajpos[2,it]-Ngrid) + '@' + \ 1096 1156 str(trajpos[2,it]+Ngrid) + '|' + dims['Y'][0] + ':' + \ … … 1162 1222 print simobsvalues[varsimobs][:][it] 1163 1223 1224 arrayvals = np.array(simobsvalues) 1225 if len(valvars[ivar]) > 2: 1226 const=np.float(valvars[ivar][3]) 1227 if valvars[ivar][2] == 'sumc': 1228 simobsSvalues = simobsSvalues + const 1229 arrayvals[:,0] = arrayvals[:,0] + const 1230 elif valvars[ivar][2] == 'subc': 1231 simobsSvalues = simobsSvalues - const 1232 arrayvals[:,0] = arrayvals[:,0] - const 1233 elif valvars[ivar][2] == 'mulc': 1234 simobsSvalues = simobsSvalues * const 1235 arrayvals[:,0] = arrayvals[:,0] * const 1236 elif valvars[ivar][2] == 'divc': 1237 simobsSvalues = simobsSvalues / const 1238 arrayvals[:,0] = arrayvals[:,0] / const 1239 else: 1240 print errormsg 1241 print ' ' + fname + ": operation '" + valvars[ivar][2] + "' not ready!!" 1242 quit(-1) 1243 1164 1244 # Statistics around values 1165 1245 aroundstats = np.zeros((5,Ncoindt), dtype=np.float) … … 1178 1258 valvars[ivar][1] 1179 1259 basicvardef(newvar, varsimobs, descvar, ovobs.getncattr('units')) 1180 newvar[:] = np.array(simobsvalues)1260 newvar[:] = arrayvals 1181 1261 1182 1262 # Around values 1183 1263 if dims.has_key('Z'): 1184 newdim = onewnc.createDimension('zaround',Ngrid*2+1) 1264 if not onewnc.dimensions.has_key('zaround'): 1265 newdim = onewnc.createDimension('zaround',Ngrid*2+1) 1266 1185 1267 newvar = onewnc.createVariable(valvars[ivar][0] + 'around', 'f', \ 1186 1268 ('time','zaround','yaround','xaround'), fill_value=fillValueF)
Note: See TracChangeset
for help on using the changeset viewer.