Ignore:
Timestamp:
Apr 22, 2013, 8:31:47 PM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. fixed bug with minimum close to 0. number of ticks in 1D plots can be set with self.div. better labelling (actual values). better handling of time in case this is Ls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r934 r936  
    710710                        plobj.label = ""
    711711                        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])
    717717                    # specific 2d plot stuff
    718718                    if dp == 2:
     
    11741174          self.name_t = "nothing"
    11751175          for c in glob_listt:
    1176             if c in self.f.dimensions.keys():
     1176            if c in self.f.variables.keys():
    11771177             self.name_t = c
     1178             if self.verbose: print "**** OK. Found time variable: ",c
    11781179          try:
    11791180            # 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)
    11841197          except:
    11851198            # ... or if a problem encountered, define a simple time axis
Note: See TracChangeset for help on using the changeset viewer.