Changeset 517 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 19, 2015, 3:21:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r516 r517 1120 1120 return 1121 1121 1122 class Quantiles(object): 1123 """ Class to provide quantiles from a given arrayof values 1124 """ 1125 1126 def __init__(self, values, Nquants): 1127 import numpy.ma as ma 1128 1129 if values is None: 1130 self.quantilesv = None 1131 1132 else: 1133 self.quantilesv = [] 1134 1135 vals0 = values.flatten() 1136 Nvalues = len(vals0) 1137 vals = ma.masked_equal(vals0, None) 1138 Nvals=len(vals.compressed()) 1139 1140 sortedvals = sorted(vals.compressed()) 1141 for iq in range(Nquants): 1142 self.quantilesv.append(sortedvals[int((Nvals-1)*iq/Nquants)]) 1143 1144 self.quantilesv.append(sortedvals[Nvals-1]) 1145 1146 1122 1147 def getting_ValidationValues(okind, dimt, ds, trjpos, ovs, ovo, tvalues, oFill, Ng, kvals): 1123 1148 """ Function to get the values to validate accroding to the type of observation … … 1157 1182 if it == 0: 1158 1183 postf[uniqt[it]] = [0,0] 1184 elif it == 1: 1185 posprev = postf[uniqt[it-1]][1] 1186 posit = list(tvalues[:,3]).index(uniqt[it]) 1187 postf[uniqt[it]] = [posprev, posit+1] 1159 1188 else: 1160 1189 posprev = postf[uniqt[it-1]][1] 1161 posit = tvalues[:,3].index(uniqt[it]) 1162 postf[uniqt[it]] = [posprev, posit] 1163 print postf 1164 quit() 1190 posit = list(tvalues[:,3]).index(uniqt[it]) 1191 postf[uniqt[it]] = [posprev+1, posit+1] 1165 1192 elif kvals == 'tbackwardOmean': 1166 1193 print ' ' + fname + ':',kvals,'!!' … … 1346 1373 None 1347 1374 1348 for it in range(dimtf): 1349 tv = uniqt(it) 1350 1375 for it in range(1,dimtf): 1376 tv = uniqt[it] 1377 intv = postf[tv] 1378 1379 # Temporal statistics 1380 print sovalues[intv[0]:intv[1]] 1381 sovs = np.array(sovalues[intv[0]:intv[1]])[:,0] 1382 minv = np.min(sovs) 1383 maxv = np.max(sovs) 1384 meanv = np.mean(sovs) 1385 stdv = np.std(sovs) 1386 1387 fsovalues.append([meanv, np.array(sovalues[intv[0]:intv[1]])[0,1], minv, \ 1388 maxv, stdv]) 1389 print 'fsovalues:',fsovalues 1390 if ds.has_key('Z'): 1391 ftrjs[it, 1392 for iz in range(2*Ng+1): 1393 for iy in rangedd(2*Ng+1): 1394 for ix in rangedd(2*Ng+1): 1395 fsoSvalues[it,iz,iy,ix] = np.meanv(soSvalues[intv[0]: \ 1396 intv[1],iz,iy,ix]) 1351 1397 1352 1398 elif kvals == 'tbackwardOmean':
Note: See TracChangeset
for help on using the changeset viewer.