Changeset 981 for trunk/UTIL/PYTHON
- Timestamp:
- Jun 7, 2013, 1:22:11 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/pp.py
r977 r981 48 48 parser.add_option('-c','--contour',action='store',dest='contour',type="string",default=None,help="one 'variable' for contour") 49 49 parser.add_option('-i','--vecx',action='store',dest='vecx',type="string",default=None,help="one 'variable' for wind vector x component") 50 parser.add_option('-j','--vecy',action='store',dest='vecy',type="string",default=None,help="one 'variable' for wind vector xcomponent")50 parser.add_option('-j','--vecy',action='store',dest='vecy',type="string",default=None,help="one 'variable' for wind vector y component") 51 51 parser.add_option('-m','--mult',action='store',dest='mult',type="float",default=None,help="multiplicative factor on field") 52 52 parser.add_option('-a','--add',action='store',dest='add',type="float",default=None,help="additive factor on field") … … 55 55 parser.add_option('-s','--changetime',action='store',dest='changetime',type="string",default=None,\ 56 56 help="transformation on time axis : [None] | mars_sol2ls | mars_meso_ls | mars_meso_sol | mars_meso_utc | mars_meso_lt ") 57 parser.add_option('--stridex',action='store',dest='stridex',type="int",default=1,help="Load data every stridex grid points over x dimension") 58 parser.add_option('--stridey',action='store',dest='stridey',type="int",default=1,help="Load data every stridex grid points over y dimension") 59 parser.add_option('--stridez',action='store',dest='stridez',type="int",default=1,help="Load data every stridex grid points over z dimension") 60 parser.add_option('--stridet',action='store',dest='stridet',type="int",default=1,help="Load data every stridex grid points over t dimension") 57 61 # plot --> upper case 58 62 # -- generic … … 125 129 user.compute = opt.compute 126 130 user.changetime = opt.changetime 131 user.stridex = opt.stridex 132 user.stridey = opt.stridey 133 user.stridez = opt.stridez 134 user.stridet = opt.stridet 127 135 # define field 128 136 user.define() -
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) -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r977 r981 476 476 ax.set_ybound(lower=y1,upper=y2) 477 477 ## set with .div the number of ticks. (is it better than automatic?) 478 ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) 478 if not self.logx: 479 ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) 480 else: 481 print "!! WARNING. in logx mode, ticks are set automatically." 479 482 480 483 ################################ … … 727 730 ### not expecting NaN in self.addvecx and self.addvecy. masked arrays is just enough. 728 731 stride = 3 729 #stride = 1 730 if self.addvecx is not None and self.addvecy is not None and self.mapmode: 731 ### for metwinds only ??? 732 [vecx,vecy] = m.rotate_vector(self.addvecx,self.addvecy,self.absc,self.ordi) 733 #vecx,vecy = self.addvecx,self.addvecy 732 stride = 1 ## no need to stride. done with data. except if you want to stride wind and not field TBD. 733 if self.addvecx is not None and self.addvecy is not None: 734 if self.mapmode: [vecx,vecy] = m.rotate_vector(self.addvecx,self.addvecy,self.absc,self.ordi) # for metwinds only ? 735 else: vecx,vecy = self.addvecx,self.addvecy ; x,y = np.meshgrid(x,y) 734 736 # reference vector is scaled 735 737 if self.wscale is None: self.wscale = ppcompute.mean(np.sqrt(self.addvecx*self.addvecx+self.addvecy*self.addvecy)) 736 738 # make vector field 737 q = m.quiver( x[::stride,::stride],y[::stride,::stride],\ 738 vecx[::stride,::stride],vecy[::stride,::stride],\ 739 angles='xy',color=self.colorvec,pivot='middle',\ 740 scale=self.wscale*reducevec,width=widthvec ) 739 if self.mapmode: 740 q = m.quiver( x[::stride,::stride],y[::stride,::stride],\ 741 vecx[::stride,::stride],vecy[::stride,::stride],\ 742 angles='xy',color=self.colorvec,pivot='tail',\ 743 scale=self.wscale*reducevec,width=widthvec ) 744 else: 745 q = mpl.quiver( x[::stride,::stride],y[::stride,::stride],\ 746 vecx[::stride,::stride],vecy[::stride,::stride],\ 747 angles='xy',color=self.colorvec,pivot='tail',\ 748 scale=self.wscale*reducevec,width=widthvec ) 741 749 # make vector key. 742 750 #keyh = 1.025 ; keyv = 1.05 # upper right corner over colorbar -
trunk/UTIL/PYTHON/planetoplot_v2/set_ppclass.txt
r977 r981 10 10 # z-axis: possible names to search for. add in the line with a separating ; 11 11 # 12 altitude;Alt;vert;presnivs;bottom_top;altitude_abg 12 altitude;Alt;vert;presnivs;bottom_top;altitude_abg;lev 13 13 # t-axis: possible names to search for. add in the line with a separating ; 14 14 #
Note: See TracChangeset
for help on using the changeset viewer.