Changeset 1068 for trunk/UTIL


Ignore:
Timestamp:
Oct 14, 2013, 4:26:38 PM (11 years ago)
Author:
aslmd
Message:

planetoplot. corrected a bug with option changetime correctls

File:
1 edited

Legend:

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

    r1067 r1068  
    12631263        self.dim_x = None ; self.dim_y = None ; self.dim_z = None ; self.dim_t = None
    12641264        self.field_x = None ; self.field_y = None ; self.field_z = None ; self.field_t = None
     1265        self.tabtime = None
    12651266        self.dimplot = 0
    12661267        self.nplot = 1
     
    13971398          try:
    13981399            # speed up: only get first value, last one.
    1399             tabtime = self.f.variables[self.name_t]
     1400            self.tabtime = self.f.variables[self.name_t]
    14001401            # (consider the case where tabtime is not dim 1)
    14011402            # (time is most often the first dimension)
    1402             if tabtime.ndim == 2: tabtime = tabtime[:,0]
    1403             elif tabtime.ndim == 3: tabtime = tabtime[:,0,0]
    1404             elif tabtime.ndim == 4: tabtime = tabtime[:,0,0,0]
     1403            if self.tabtime.ndim == 2: self.tabtime = self.tabtime[:,0]
     1404            elif self.tabtime.ndim == 3: self.tabtime = self.tabtime[:,0,0]
     1405            elif self.tabtime.ndim == 4: self.tabtime = self.tabtime[:,0,0,0]
    14051406            # (now proceed) (the +0. just ensures this is a number)
    1406             dafirst = tabtime[0] + 0.
     1407            dafirst = self.tabtime[0] + 0.
    14071408            if self.dim_t == 1:
    14081409                self.field_t = np.array([dafirst])
    14091410            else:
    1410                 daint = tabtime[1] - dafirst
     1411                daint = self.tabtime[1] - dafirst
    14111412                dalast = dafirst + (self.dim_t-1)*daint
    14121413                self.field_t = np.linspace(dafirst,dalast,num=self.dim_t)
    14131414                if self.verbose:
    14141415                    print "!! WARNING !! WARNING !! Time axis is supposed to be equally spaced !!"
    1415                     if dalast != tabtime[self.dim_t-1]:
    1416                         print "!! WARNING !! Time axis has been recast to be monotonic",dalast,tabtime[self.dim_t-1]
     1416                    if dalast != self.tabtime[self.dim_t-1]:
     1417                        print "!! WARNING !! Time axis has been recast to be monotonic",dalast,self.tabtime[self.dim_t-1]
    14171418          except:
    14181419            # ... or if a problem encountered, define a simple time axis
     
    14421443            ### options added by A. Spiga
    14431444            elif self.changetime == "correctls":
    1444                 # not regularly spaced + handle modulo 360. in files
    1445                 dafirst = tabtime[0] + 0.
    1446                 daint = tabtime[1] - dafirst
     1445                dafirst = self.tabtime[0] + 0.
     1446                daint = self.tabtime[1] - dafirst
    14471447                dalast = dafirst + (self.dim_t-1)*daint
    14481448                year = 0.
    14491449                add = np.linspace(dafirst,dalast,num=self.dim_t) ; add[0] = 0.
    14501450                for iii in range(1,self.dim_t):
    1451                   if tabtime[iii] - tabtime[iii-1] < 0: year = year+1.
     1451                  if self.tabtime[iii] - self.tabtime[iii-1] < 0: year = year+1.
    14521452                  add[iii] = year*360.
    1453                 self.field_t = add + tabtime
     1453                self.field_t = add + self.tabtime
    14541454            elif "mars_meso" in self.changetime:
    14551455                if 'Times' not in self.f.variables.keys():
Note: See TracChangeset for help on using the changeset viewer.