Changeset 936 for trunk/UTIL
- Timestamp:
- Apr 22, 2013, 8:31:47 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r934 r936 710 710 plobj.label = "" 711 711 if self.nfin > 1: plobj.label = plobj.label + " file #"+str(i+1) 712 if self.nvin > 1: plobj.label = plobj.label + " var #"+str(j+1)713 if self.nplott > 1: plobj.label = plobj.label + " t #"+str(t+1)714 if self.nplotz > 1: plobj.label = plobj.label + " z #"+str(z+1)715 if self.nploty > 1: plobj.label = plobj.label + " y #"+str(y+1)716 if self.nplotx > 1: plobj.label = plobj.label + " x #"+str(x+1)712 if self.nvin > 1: plobj.label = plobj.label + " var "+plobj.var 713 if self.nplott > 1: plobj.label = plobj.label + " t="+str(self.t[t]) 714 if self.nplotz > 1: plobj.label = plobj.label + " z="+str(self.z[z]) 715 if self.nploty > 1: plobj.label = plobj.label + " y="+str(self.y[y]) 716 if self.nplotx > 1: plobj.label = plobj.label + " x="+str(self.x[x]) 717 717 # specific 2d plot stuff 718 718 if dp == 2: … … 1174 1174 self.name_t = "nothing" 1175 1175 for c in glob_listt: 1176 if c in self.f. dimensions.keys():1176 if c in self.f.variables.keys(): 1177 1177 self.name_t = c 1178 if self.verbose: print "**** OK. Found time variable: ",c 1178 1179 try: 1179 1180 # speed up: only get first value, last one. 1180 dafirst = self.f.variables[self.name_t][0] 1181 dalast = self.f.variables[self.name_t][self.dim_t-1] 1182 self.field_t = np.linspace(dafirst,dalast,num=self.dim_t) 1183 if dafirst == dalast: self.field_t = np.array([dafirst]) 1181 tabtime = self.f.variables[self.name_t] 1182 # (consider the case where tabtime is not dim 1) 1183 # (time is most often the first dimension) 1184 if tabtime.ndim == 2: tabtime = tabtime[:,0] 1185 elif tabtime.ndim == 3: tabtime = tabtime[:,0,0] 1186 elif tabtime.ndim == 4: tabtime = tabtime[:,0,0,0] 1187 # (now proceed) 1188 dafirst = tabtime[0] 1189 if self.dim_t == 1: 1190 self.field_t = np.array([dafirst]) 1191 else: 1192 daint = tabtime[1] - dafirst 1193 dalast = dafirst + (self.dim_t-1)*daint 1194 if dalast != tabtime[self.dim_t-1] and self.verbose: 1195 print "!! WARNING !! Time axis has been recast to be monotonic",dalast,tabtime[self.dim_t-1] 1196 self.field_t = np.linspace(dafirst,dalast,num=self.dim_t) 1184 1197 except: 1185 1198 # ... or if a problem encountered, define a simple time axis -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r933 r936 12 12 from matplotlib.cm import get_cmap 13 13 from mpl_toolkits.basemap import Basemap 14 from matplotlib.ticker import FormatStrFormatter 14 from matplotlib.ticker import FormatStrFormatter,MaxNLocator 15 15 # personal librairies 16 16 import ppcompute … … 219 219 amin = ppcompute.min(field) 220 220 amax = ppcompute.max(field) 221 cmin = 100.*np.abs((amin - zevmin)/amin) 221 if np.abs(amin) < 1.e-15: 222 zevmin = 0. 223 cmin = 0. 224 else: 225 cmin = 100.*np.abs((amin - zevmin)/amin) 222 226 cmax = 100.*np.abs((amax - zevmax)/amax) 223 227 if cmin > 150. or cmax > 150.: … … 430 434 ax = mpl.gca() 431 435 # format labels 432 if self.swap: ax. get_xaxis().set_major_formatter(FormatStrFormatter(self.fmt))433 else: ax. get_yaxis().set_major_formatter(FormatStrFormatter(self.fmt))436 if self.swap: ax.xaxis.set_major_formatter(FormatStrFormatter(self.fmt)) 437 else: ax.yaxis.set_major_formatter(FormatStrFormatter(self.fmt)) 434 438 # plot limits: ensure that no curve would be outside the window 435 439 # x-axis … … 447 451 if ymax > y2: y2 = ymax 448 452 ax.set_ybound(lower=y1,upper=y2) 449 ## set with .div the number of ticks. less good than automatic. 450 #ticks = self.div + 1 451 #ax.get_xaxis().set_ticks(np.linspace(x1,x2,ticks/2+1)) 453 ## set with .div the number of ticks. (is it better than automatic?) 454 ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) 452 455 453 456 ################################ … … 586 589 wlon, wlat = area[self.area] 587 590 # -- settings for meridians and parallels 588 steplon = abs(wlon[1]-wlon[0])/6. 589 steplat = abs(wlat[1]-wlat[0])/3. 590 mertab = np.r_[wlon[0]:wlon[1]:steplon] ; merlab = [0,0,0,1] 591 partab = np.r_[wlat[0]:wlat[1]:steplat] ; parlab = [1,0,0,0] 591 steplon = int(abs(wlon[1]-wlon[0])/6.) 592 steplat = int(abs(wlat[1]-wlat[0])/3.) 593 #mertab = np.r_[wlon[0]:wlon[1]:steplon] ; merlab = [0,0,0,1] 594 #partab = np.r_[wlat[0]:wlat[1]:steplat] ; parlab = [1,0,0,0] 595 mertab = np.r_[-360.:360.:steplon] ; merlab = [0,0,0,1] 596 partab = np.r_[-90.:90.:steplat] ; parlab = [1,0,0,0] 592 597 format = '%.1f' 593 598 # -- center of domain and bounding lats -
trunk/UTIL/PYTHON/planetoplot_v2/set_ppclass.txt
r921 r936 13 13 # t-axis: possible names to search for. add in the line with a separating ; 14 14 # 15 Times;time;Time;time_counter 15 Times;time;Time;time_counter;Ls 16 16 # area: possible names to search for. add in the line with a separating ; 17 17 #
Note: See TracChangeset
for help on using the changeset viewer.