Changeset 516 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 19, 2015, 12:27:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r515 r516 1120 1120 return 1121 1121 1122 def getting_ValidationValues(okind, dimt 0, ds, trjpos, ovs, ovo, tvalues, oFill, Ng, kvals):1122 def getting_ValidationValues(okind, dimt, ds, trjpos, ovs, ovo, tvalues, oFill, Ng, kvals): 1123 1123 """ Function to get the values to validate accroding to the type of observation 1124 1124 okind= observational kind 1125 dimt 0= initial number of values to retrieve1125 dimt= initial number of values to retrieve 1126 1126 ds= dictionary with the names of the dimensions (sim, obs) 1127 1127 trjpos= positions of the multi-stations (t, Y, X) or trajectory ([Z], Y, X) … … 1147 1147 1148 1148 if kvals == 'instantaneous': 1149 dimt = dimt01149 dimtf = dimt 1150 1150 elif kvals == 'tbackwardSmean': 1151 1151 print ' ' + fname + ':',kvals,'!!' 1152 1152 uniqt = np.unique(tvalues[:,3]) 1153 dimt = len(uniqt) 1154 print ' initially we got',dimt0,'values which will become',dimt 1153 dimtf = len(uniqt) 1154 print ' initially we got',dimt,'values which will become',dimtf 1155 postf = {} 1156 for it in range(dimtf): 1157 if it == 0: 1158 postf[uniqt[it]] = [0,0] 1159 else: 1160 posprev = postf[uniqt[it-1]][1] 1161 posit = tvalues[:,3].index(uniqt[it]) 1162 postf[uniqt[it]] = [posprev, posit] 1163 print postf 1155 1164 quit() 1156 1165 elif kvals == 'tbackwardOmean': 1157 1166 print ' ' + fname + ':',kvals,'!!' 1158 1167 uniqt = np.unique(tvalues[:,2]) 1159 dimt = len(uniqt)1160 print ' initially we got',dimt 0,'values which will become',dimt1168 dimtf = len(uniqt) 1169 print ' initially we got',dimt,'values which will become',dimtf 1161 1170 else: 1162 1171 print errormsg … … 1166 1175 # Simulated values spatially around 1167 1176 if ds.has_key('Z'): 1168 soSvalues = np.zeros((dimt, Ng*2+1, Ng*2+1, Ng*2+1), \ 1169 dtype = np.float) 1177 soSvalues = np.zeros((dimt, Ng*2+1, Ng*2+1, Ng*2+1), dtype = np.float) 1170 1178 if okind == 'trajectory': 1171 1179 trjs = np.zeros((4,dimt), dtype=int) … … 1187 1195 if okind == 'multi-points': 1188 1196 for it in range(dimt): 1189 slicev = ds['X'][0] + ':' + str(trjpos[2,it]) + '|' + \ 1190 ds['Y'][0]+ ':' + str(trjpos[1,it]) + '|' + \ 1191 ds['T'][0]+ ':' + str(tvalues[it][0]) 1197 slicev = ds['X'][0] + ':' + str(trjpos[2,it]) + '|' + ds['Y'][0] + \ 1198 ':' + str(trjpos[1,it]) + '|' + ds['T'][0]+ ':' + str(tvalues[it][0]) 1192 1199 slicevar, dimslice = slice_variable(ovs, slicev) 1193 1200 sovalues.append([ slicevar, ovo[tvalues[it][1]]]) 1194 slicev = ds['X'][0] + ':' + str(trjpos[2,it]-Ng) + '@' + \1195 str(trjpos[2,it]+Ng) + '|' + ds['Y'][0] + ':' + \1196 str(trjpos[1,it]-Ng) + '@' + str(trjpos[1,it]+Ng) + '|' + \1201 slicev = ds['X'][0] + ':' + str(trjpos[2,it]-Ng) + '@' + \ 1202 str(trjpos[2,it]+Ng) + '|' + ds['Y'][0] + ':' + \ 1203 str(trjpos[1,it]-Ng) + '@' + str(trjpos[1,it]+Ng) + '|' + \ 1197 1204 ds['T'][0]+':'+str(tvalues[it][0]) 1198 1205 slicevar, dimslice = slice_variable(ovs, slicev) … … 1203 1210 ito = int(tvalues[it,1]) 1204 1211 if valdimsim.has_key('X') and valdimsim.has_key('Y'): 1205 slicev = ds['X'][0] + ':' + str(stationpos[1]) + '|' + \1206 ds['Y'][0] + ':' + str(stationpos[0]) + '|' + \1212 slicev = ds['X'][0] + ':' + str(stationpos[1]) + '|' + \ 1213 ds['Y'][0] + ':' + str(stationpos[0]) + '|' + \ 1207 1214 ds['T'][0] + ':' + str(int(tvalues[it][0])) 1208 1215 else: … … 1216 1223 sovalues.append([ slicevar, ovo[int(ito)]]) 1217 1224 if valdimsim.has_key('X') and valdimsim.has_key('Y'): 1218 slicev = ds['X'][0] + ':' + str(stationpos[1]-Ng) + '@' + \1219 str(stationpos[1]+Ng+1) + '|' + ds['Y'][0] + ':' + \1220 str(stationpos[0]-Ng) + '@' + str(stationpos[0]+Ng+1) + '|' + \1225 slicev = ds['X'][0] + ':' + str(stationpos[1]-Ng) + '@' + \ 1226 str(stationpos[1]+Ng+1) + '|' + ds['Y'][0] + ':' + \ 1227 str(stationpos[0]-Ng) + '@' + str(stationpos[0]+Ng+1) + '|' + \ 1221 1228 ds['T'][0] + ':' + str(int(tvalues[it,0])) 1222 1229 else: … … 1250 1257 ito = int(tvalues[it,1]) 1251 1258 if notfound[ito] == 0: 1252 trjpos[2,ito] = index_mat(valdimsim['Z'][tvalues[it,0],:, \1259 trjpos[2,ito] = index_mat(valdimsim['Z'][tvalues[it,0],:, \ 1253 1260 trjpos[1,ito],trjpos[0,ito]], valdimobs['Z'][ito]) 1254 slicev = ds['X'][0]+':'+str(trjpos[0,ito]) + '|' + \1255 ds['Y'][0]+':'+str(trjpos[1,ito]) + '|' + \1256 ds['Z'][0]+':'+str(trjpos[2,ito]) + '|' + \1261 slicev = ds['X'][0]+':'+str(trjpos[0,ito]) + '|' + \ 1262 ds['Y'][0]+':'+str(trjpos[1,ito]) + '|' + \ 1263 ds['Z'][0]+':'+str(trjpos[2,ito]) + '|' + \ 1257 1264 ds['T'][0]+':'+str(int(tvalues[it,0])) 1258 1265 slicevar, dimslice = slice_variable(ovs, slicev) … … 1265 1272 maxz = np.min([trjpos[2,ito]+Ng+1,ovs.shape[1]]) 1266 1273 1267 slicev = ds['X'][0] + ':' + str(minx) + '@' + str(maxx) + '|' + \1268 ds['Y'][0] + ':' + str(miny) + '@' + str(maxy) + '|' + \1269 ds['Z'][0] + ':' + str(minz) + '@' + str(maxz) + '|' + \1274 slicev = ds['X'][0] + ':' + str(minx) + '@' + str(maxx) + '|' + \ 1275 ds['Y'][0] + ':' + str(miny) + '@' + str(maxy) + '|' + \ 1276 ds['Z'][0] + ':' + str(minz) + '@' + str(maxz) + '|' + \ 1270 1277 ds['T'][0] + ':' + str(int(tvalues[it,0])) 1271 1278 slicevar, dimslice = slice_variable(ovs, slicev) … … 1285 1292 else: 1286 1293 sovalues.append([fillValueF, fillValueF]) 1287 soSvalues[it,:,:,:]= np.ones((Ng*2+1,Ng*2+1,Ng*2+1), \1294 soSvalues[it,:,:,:]= np.ones((Ng*2+1,Ng*2+1,Ng*2+1), \ 1288 1295 dtype = np.float)*fillValueF 1289 1296 # 2D trajectory … … 1292 1299 if notfound[it] == 0: 1293 1300 ito = tvalues[it,1] 1294 slicev = ds['X'][0]+':'+str(trjpos[2,ito]) + '|' + \1295 ds['Y'][0]+':'+str(trjpos[1,ito]) + '|' + \1301 slicev = ds['X'][0]+':'+str(trjpos[2,ito]) + '|' + \ 1302 ds['Y'][0]+':'+str(trjpos[1,ito]) + '|' + \ 1296 1303 ds['T'][0]+':'+str(tvalues[ito,0]) 1297 1304 slicevar, dimslice = slice_variable(ovs, slicev) 1298 1305 sovalues.append([ slicevar, ovo[tvalues[it,1]]]) 1299 slicev = ds['X'][0] + ':' + str(trjpos[0,it]-Ng) + '@' + \1300 str(trjpos[0,it]+Ng) + '|' + ds['Y'][0] + ':' + \1301 str(trjpos[1,it]-Ng) + '@' + str(trjpos[1,it]+Ng) + \1306 slicev = ds['X'][0] + ':' + str(trjpos[0,it]-Ng) + '@' + \ 1307 str(trjpos[0,it]+Ng) + '|' + ds['Y'][0] + ':' + \ 1308 str(trjpos[1,it]-Ng) + '@' + str(trjpos[1,it]+Ng) + \ 1302 1309 '|' + ds['T'][0] + ':' + str(tvalues[it,0]) 1303 1310 slicevar, dimslice = slice_variable(ovs, slicev) … … 1305 1312 else: 1306 1313 sovalues.append([fillValue, fillValue]) 1307 soSvalues[it,:,:] = np.ones((Ng*2+1,Ng*2+1), \1314 soSvalues[it,:,:] = np.ones((Ng*2+1,Ng*2+1), \ 1308 1315 dtype = np.float)*fillValueF 1309 1316 print sovalues[varsimobs][:][it] … … 1312 1319 print ' ' + fname + ": observatino kind '" + okind + "' not ready!!" 1313 1320 quit(-1) 1321 1322 # Re-arranging final values 1323 ## 1324 if kvals == 'instantaneous': 1325 return sovalues, soSvalues, soTvalues, soTtvalues, trjs 1326 1327 elif kvals == 'tbackwardSmean': 1328 fsovalues = [] 1329 if ds.has_key('Z'): 1330 fsoSvalues = np.zeros((dimtf, Ng*2+1, Ng*2+1, Ng*2+1), dtype = np.float) 1331 if okind == 'trajectory': 1332 ftrjs = np.zeros((4,dimtf), dtype=int) 1333 else: 1334 ftrjs = None 1335 else: 1336 fsoSvalues = np.zeros((dimtf, Ng*2+1, Ng*2+1), dtype = np.float) 1337 if okind == 'trajectory': 1338 ftrjs = np.zeros((3,dimtf), dtype=int) 1339 else: 1340 ftrjs = None 1341 1342 if okind == 'single-station': 1343 fsoTvalues = {} 1344 fsoTtvalues = np.zeros((dimtf,2), dtype=np.float) 1345 else: 1346 None 1347 1348 for it in range(dimtf): 1349 tv = uniqt(it) 1350 1351 1352 elif kvals == 'tbackwardOmean': 1353 print ' ' + fname + ':',kvals,'!!' 1354 uniqt = np.unique(tvalues[:,2]) 1355 dimtf = len(uniqt) 1356 print ' initially we got',dimt,'values which will become',dimtf 1314 1357 1315 1358
Note: See TracChangeset
for help on using the changeset viewer.