Changeset 529 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 22, 2015, 5:08:08 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r528 r529 1145 1145 1146 1146 1147 def getting_ValidationValues(okind, d imt, ds, trjpos, ovs, ovo, tvalues, oFill, Ng, kvals):1147 def getting_ValidationValues(okind, dt, ds, trjpos, ovs, ovo, tvalues, oFill, Ng, kvals): 1148 1148 """ Function to get the values to validate accroding to the type of observation 1149 1149 okind= observational kind 1150 d imt= initial number of values to retrieve1150 dt= initial number of values to retrieve 1151 1151 ds= dictionary with the names of the dimensions (sim, obs) 1152 1152 trjpos= positions of the multi-stations (t, Y, X) or trajectory ([Z], Y, X) … … 1171 1171 1172 1172 if kvals == 'instantaneous': 1173 d imtf = dimt1173 dtf = dt 1174 1174 elif kvals == 'tbackwardSmean': 1175 1175 print ' ' + fname + ':',kvals,'!!' 1176 1176 uniqt = np.unique(tvalues[:,3]) 1177 d imtf = len(uniqt)1178 print ' initially we got',d imt,'values which will become',dimtf1177 dtf = len(uniqt) 1178 print ' initially we got',dt,'values which will become',dtf 1179 1179 postf = {} 1180 for it in range(d imtf):1180 for it in range(dtf): 1181 1181 if it == 0: 1182 1182 postf[uniqt[it]] = [0,0] … … 1192 1192 print ' ' + fname + ':',kvals,'!!' 1193 1193 uniqt = np.unique(tvalues[:,2]) 1194 d imtf = len(uniqt)1195 print ' initially we got',d imt,'values which will become',dimtf1194 dtf = len(uniqt) 1195 print ' initially we got',dt,'values which will become',dtf 1196 1196 print ' ==== NOT READY === ' 1197 1197 quit(-1) … … 1203 1203 # Simulated values spatially around 1204 1204 if ds.has_key('Z'): 1205 soSvalues = np.zeros((d imt, Ng*2+1, Ng*2+1, Ng*2+1), dtype = np.float)1205 soSvalues = np.zeros((dt, Ng*2+1, Ng*2+1, Ng*2+1), dtype = np.float) 1206 1206 if okind == 'trajectory': 1207 trjs = np.zeros((4,d imt), dtype=int)1207 trjs = np.zeros((4,dt), dtype=int) 1208 1208 else: 1209 1209 trjs = None 1210 1210 else: 1211 soSvalues = np.zeros((d imt, Ng*2+1, Ng*2+1), dtype = np.float)1211 soSvalues = np.zeros((dt, Ng*2+1, Ng*2+1), dtype = np.float) 1212 1212 if okind == 'trajectory': 1213 trjs = np.zeros((3,d imt), dtype=int)1213 trjs = np.zeros((3,dt), dtype=int) 1214 1214 else: 1215 1215 trjs = None 1216 1216 1217 1217 if okind == 'single-station': 1218 soTtvalues = np.zeros((d imt,2), dtype=np.float)1218 soTtvalues = np.zeros((dt,2), dtype=np.float) 1219 1219 else: 1220 1220 None 1221 1221 1222 1222 if okind == 'multi-points': 1223 for it in range(d imt):1223 for it in range(dt): 1224 1224 slicev = ds['X'][0] + ':' + str(trjpos[2,it]) + '|' + ds['Y'][0] + \ 1225 1225 ':' + str(trjpos[1,it]) + '|' + ds['T'][0]+ ':' + str(tvalues[it][0]) … … 1234 1234 1235 1235 elif okind == 'single-station': 1236 for it in range(d imt):1236 for it in range(dt): 1237 1237 ito = int(tvalues[it,1]) 1238 1238 if valdimsim.has_key('X') and valdimsim.has_key('Y'): … … 1262 1262 itoi = 0 1263 1263 itof = int(tvalues[it,1]) / 2 1264 elif it == d imt-1:1264 elif it == dt-1: 1265 1265 itoi = int( (ito + int(tvalues[it-1,1])) / 2) 1266 1266 itof = int(tvalues[it,1]) … … 1276 1276 elif okind == 'trajectory': 1277 1277 if ds.has_key('Z'): 1278 for it in range(d imt):1278 for it in range(dt): 1279 1279 ito = int(tvalues[it,1]) 1280 1280 if notfound[ito] == 0: … … 1318 1318 # 2D trajectory 1319 1319 else: 1320 for it in range(d imt):1320 for it in range(dt): 1321 1321 if notfound[it] == 0: 1322 1322 ito = tvalues[it,1] … … 1350 1350 fsovalues = [] 1351 1351 if ds.has_key('Z'): 1352 fsoSvalues = np.zeros((d imtf, Ng*2+1, Ng*2+1, Ng*2+1), dtype = np.float)1352 fsoSvalues = np.zeros((dtf, Ng*2+1, Ng*2+1, Ng*2+1), dtype = np.float) 1353 1353 if okind == 'trajectory': 1354 ftrjs = np.zeros((4,d imtf), dtype=int)1354 ftrjs = np.zeros((4,dtf), dtype=int) 1355 1355 else: 1356 1356 ftrjs = None 1357 1357 else: 1358 fsoSvalues = np.zeros((d imtf, Ng*2+1, Ng*2+1), dtype = np.float)1358 fsoSvalues = np.zeros((dtf, Ng*2+1, Ng*2+1), dtype = np.float) 1359 1359 if okind == 'trajectory': 1360 ftrjs = np.zeros((3,d imtf), dtype=int)1360 ftrjs = np.zeros((3,dtf), dtype=int) 1361 1361 else: 1362 1362 ftrjs = None 1363 1363 1364 1364 if okind == 'single-station': 1365 fsoTtvalues = np. zeros((dimtf,2), dtype=np.float)1365 fsoTtvalues = np.ones((dtf,2), dtype=np.float)*fillValueF 1366 1366 else: 1367 1367 None 1368 1368 1369 for it in range(1,d imtf):1369 for it in range(1,dtf): 1370 1370 tv = uniqt[it] 1371 1371 intv = postf[tv] … … 1405 1405 print ' ' + fname + ':',kvals,'!!' 1406 1406 uniqt = np.unique(tvalues[:,2]) 1407 d imtf = len(uniqt)1408 print ' initially we got',d imt,'values which will become',dimtf1407 dtf = len(uniqt) 1408 print ' initially we got',dt,'values which will become',dtf 1409 1409 1410 1410 return … … 1940 1940 1941 1941 for kst in range(Nstsim): 1942 simobsvalues = [] 1943 1942 1944 timedn = prestdescsim[kst] + 'time' 1945 timeobsdn = prestdescsim[kst] + 'obstime' 1943 1946 print ' ' + prestdescsim[kst] + ' ...' 1944 1947 … … 1990 1993 if ivar == 0: 1991 1994 vname = prestdescsim[kst] + 'time' 1992 newvar = onewnc.createVariable(vname,'f8', (timedn)) 1995 newvar = onewnc.createVariable(vname,'f8', (timedn), \ 1996 fill_value = fillValueF) 1993 1997 basicvardef(newvar, vname, 'simulation time between observations', \ 1994 obstunits 1998 obstunits) 1995 1999 set_attribute(newvar, 'calendar', 'standard') 1996 2000 set_attribute(newvar, 'bounds', 'time_bnds') … … 2106 2110 # Statistics around sim values 2107 2111 aroundstats = np.zeros((5,dimt), dtype=np.float) 2108 print 'Lluis dimt:',dimt,simobsSvalues.shape2109 2112 for it in range(dimt): 2110 2113 aroundstats[0,it] = np.min(simobsSvalues[it,]) … … 2123 2126 2124 2127 # obs Values to netCDF 2125 newvar = onewnc.createVariable(valvars[ivar][1] + '_' + stdescsim[kst] + \ 2128 if stdescsim[kst] != 'E': 2129 newvar = onewnc.createVariable(valvars[ivar][1] + '_' + stdescsim[kst] + \ 2130 'obs', 'f', (timeobsdn), fill_value=fillValueF) 2131 else: 2132 newvar = onewnc.createVariable(valvars[ivar][1] + '_' + stdescsim[kst] + \ 2126 2133 'obs', 'f', (timedn), fill_value=fillValueF) 2127 descvar = prestdescsim[kst] + ' time simulated: ' + valvars[ivar][1] 2134 2135 descvar = prestdescsim[kst] + ' time observed: ' + valvars[ivar][1] 2128 2136 basicvardef(newvar, valvars[ivar][1], descvar, ovobs.getncattr('units')) 2129 2137 newvar[:] = arrayvals[:,1] … … 2150 2158 2151 2159 2152 # around sim Statistics between2160 # around sim Statistics 2153 2161 if not searchInlist(onewnc.variables,prestdescsim[kst] + valvars[ivar][0] + \ 2154 2162 'staround'):
Note: See TracChangeset
for help on using the changeset viewer.