Changeset 981 for trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
- Timestamp:
- Jun 7, 2013, 1:22:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r978 r981 572 572 obj.changetime = self.changetime 573 573 obj.performtimechange() 574 # get strides 575 obj.stridex = self.stridex ; obj.stridey = self.stridey 576 obj.stridez = self.stridez ; obj.stridet = self.stridet 574 577 ### get index 575 obj.getindextime(dalist=st,ind=t ,stride=self.stridet)576 obj.getindexvert(dalist=sz,ind=z ,stride=self.stridez)577 obj.getindexhori(dalistx=sx,dalisty=sy,indx=x,indy=y ,stridex=self.stridex,stridey=self.stridey)578 obj.getindextime(dalist=st,ind=t) 579 obj.getindexvert(dalist=sz,ind=z) 580 obj.getindexhori(dalistx=sx,dalisty=sy,indx=x,indy=y) 578 581 # change status 579 582 self.status = "defined" … … 1191 1194 self.compute = None 1192 1195 self.changetime = None 1196 self.stridex = 1 ; self.stridey = 1 ; self.stridez = 1 ; self.stridet = 1 1193 1197 1194 1198 # open a file. for now it is netcdf. TBD for other formats. … … 1364 1368 ### TBD: il faudrait ne prendre que les indices qui correspondent a l interieur d un plot (dans all) 1365 1369 # ------------------------------- 1366 def getindextime(self,dalist=None,ind=None ,stride=1):1370 def getindextime(self,dalist=None,ind=None): 1367 1371 if self.method_t == "free": 1368 self.index_t = np.arange(0,self.dim_t,s tride)1372 self.index_t = np.arange(0,self.dim_t,self.stridet) 1369 1373 if self.dim_t > 1: 1370 1374 self.dimplot = self.dimplot + 1 … … 1376 1380 start = np.argmin( np.abs( self.field_t - dalist[ind][0] ) ) 1377 1381 stop = np.argmin( np.abs( self.field_t - dalist[ind][1] ) ) 1378 self.index_t = np.arange(start,stop,s tride)1382 self.index_t = np.arange(start,stop,self.stridet) 1379 1383 if self.verbose: print "**** OK. t values. comp over interval ",self.field_t[start],self.field_t[stop]," nvalues=",self.index_t.size 1380 1384 elif self.method_t == "fixed": … … 1388 1392 ### TBD: il faudrait ne prendre que les indices qui correspondent a l interieur d un plot (dans all) 1389 1393 # ------------------------------- 1390 def getindexvert(self,dalist=None,ind=None ,stride=1):1394 def getindexvert(self,dalist=None,ind=None): 1391 1395 if self.method_z == "free": 1392 self.index_z = np.arange(0,self.dim_z,s tride)1396 self.index_z = np.arange(0,self.dim_z,self.stridez) 1393 1397 if self.dim_z > 1: 1394 1398 self.dimplot = self.dimplot + 1 … … 1400 1404 start = np.argmin( np.abs( self.field_z - dalist[ind][0] ) ) 1401 1405 stop = np.argmin( np.abs( self.field_z - dalist[ind][1] ) ) 1402 self.index_z = np.arange(start,stop,s tride)1406 self.index_z = np.arange(start,stop,self.stridez) 1403 1407 if self.verbose: print "**** OK. z values. comp over interval",self.field_z[start],self.field_z[stop]," nvalues=",self.index_z.size 1404 1408 elif self.method_z == "fixed": … … 1416 1420 ### TBD: il faudrait ne prendre que les indices qui correspondent a l interieur d un plot (dans all) 1417 1421 # ------------------------------- 1418 def getindexhori(self,dalistx=None,dalisty=None,indx=None,indy=None ,stridex=1,stridey=1):1422 def getindexhori(self,dalistx=None,dalisty=None,indx=None,indy=None): 1419 1423 ## get what is the method over x and y axis 1420 1424 test = self.method_x+self.method_y … … 1425 1429 ## - LON IS COMP AND LAT IS FREE 1426 1430 if self.method_x == "free" or test in ["compfree","compcomp"]: 1427 self.index_x = range(0,self.dim_x,s tridex)1431 self.index_x = range(0,self.dim_x,self.stridex) 1428 1432 if self.dim_x > 1: 1429 1433 if self.method_x == "free": self.dimplot = self.dimplot + 1 … … 1433 1437 if self.verbose: print "**** OK. no x dimension." 1434 1438 if self.method_y == "free" or test in ["freecomp","compcomp"]: 1435 self.index_y = range(0,self.dim_y,s tridey)1439 self.index_y = range(0,self.dim_y,self.stridey) 1436 1440 if self.dim_y > 1: 1437 1441 if self.method_y == "free": self.dimplot = self.dimplot + 1 … … 1565 1569 self.field_x = self.field_x[self.index_y2d, self.index_x2d] 1566 1570 self.field_y = self.field_y[self.index_y2d, self.index_x2d] 1571 # ... there are special cases with strides 1572 # ... some other fixes will be needed probably TBD 1573 if self.method_x == "free" and self.stridex != 1: 1574 self.field_x = self.field_x[self.index_x] 1575 if self.method_y == "free" and self.stridey != 1: 1576 self.field_y = self.field_y[self.index_y] 1567 1577 self.field_z = self.field_z[self.index_z] 1568 1578 self.field_t = self.field_t[self.index_t] … … 1573 1583 pass 1574 1584 elif test in ["fixedfree","fixedcomp"] or test in ["freefixed","compfixed"]: 1585 if self.stridex == 1 and self.stridey == 1: 1575 1586 time0 = timelib.time() 1576 1587 # now have to obtain the new indexes which correspond to the extracted self.field … … 1606 1617 if what_I_am_supposed_to_do == "keepx": self.field = self.field[:,:,0,:] ; ny = 1 ; self.field = np.reshape(self.field,(nt,nz,ny,nx)) 1607 1618 elif what_I_am_supposed_to_do == "keepy": self.field = self.field[:,:,:,0] ; nx = 1 ; self.field = np.reshape(self.field,(nt,nz,ny,nx)) 1619 else: 1620 # there is a problem above if stride != 1. a fix must be found. rewrite might be necessary. TBD 1621 pass 1608 1622 # make a mask in case there are non-NaN missing values. (what about NaN missing values?) 1609 1623 # ... this is important for computations below (see ppcompute)
Note: See TracChangeset
for help on using the changeset viewer.