Ignore:
Timestamp:
Apr 3, 2013, 12:18:48 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. performance impact for no reason on large time axis. corrected the problem.

File:
1 edited

Legend:

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

    r923 r925  
    13561356        self.field_z = self.field_z[self.index_z]
    13571357        self.field_t = self.field_t[self.index_t]
    1358         # now have to obtain the new indexes which correspond to the extracted self.field
    1359         # for it to work with unique index, ensure that any index_* is a numpy array
    1360         if not isinstance(self.index_x, np.ndarray): self.index_x = np.array([self.index_x])
    1361         if not isinstance(self.index_y, np.ndarray): self.index_y = np.array([self.index_y])
    1362         if not isinstance(self.index_z, np.ndarray): self.index_z = np.array([self.index_z])
    1363         if not isinstance(self.index_t, np.ndarray): self.index_t = np.array([self.index_t])
    1364         for val in self.index_x: self.index_x2d[np.where(self.index_x2d == val)] = np.where(self.index_x == val)[0]
    1365         for val in self.index_y: self.index_y2d[np.where(self.index_y2d == val)] = np.where(self.index_y == val)[0]
    1366         for val in self.index_z: self.index_z  [np.where(self.index_z   == val)] = np.where(self.index_z == val)[0]
    1367         for val in self.index_t: self.index_t  [np.where(self.index_t   == val)] = np.where(self.index_t == val)[0]
    1368                ##### VERY EXPENSIVE
    1369                ## recast self.field with 2D horizontal arrays because we might have extracted
    1370                ## more than what is to be actually plot or computed, in particular for comps on 2D lat,lon coordinates
    1371                #self.field = self.field[np.ix_(self.index_t,self.index_z,self.index_y2d,self.index_x2d)]
    1372                #(nt,nz,ny,nx) = self.field.shape       
    13731358        # extract relevant horizontal points
    13741359        # TBD: is compfree OK with computing on irregular grid?
     
    13781363        elif test in ["fixedfree","fixedcomp"] or test in ["freefixed","compfixed"]:
    13791364          time0 = timelib.time() 
     1365          # now have to obtain the new indexes which correspond to the extracted self.field
     1366          # for it to work with unique index, ensure that any index_* is a numpy array
     1367          if not isinstance(self.index_x, np.ndarray): self.index_x = np.array([self.index_x])
     1368          if not isinstance(self.index_y, np.ndarray): self.index_y = np.array([self.index_y])
     1369          if not isinstance(self.index_z, np.ndarray): self.index_z = np.array([self.index_z])
     1370          if not isinstance(self.index_t, np.ndarray): self.index_t = np.array([self.index_t])
     1371          for val in self.index_x: self.index_x2d[np.where(self.index_x2d == val)] = np.where(self.index_x == val)[0]
     1372          for val in self.index_y: self.index_y2d[np.where(self.index_y2d == val)] = np.where(self.index_y == val)[0]
     1373               ##### VERY EXPENSIVE
     1374               ## recast self.field with 2D horizontal arrays because we might have extracted
     1375               ## more than what is to be actually plot or computed, in particular for comps on 2D lat,lon coordinates
     1376               #self.field = self.field[np.ix_(self.index_t,self.index_z,self.index_y2d,self.index_x2d)]
     1377               #(nt,nz,ny,nx) = self.field.shape       
    13801378          # prepare the loop on all relevant horizontal points
    13811379          if self.method_x in ["comp","free"]:   
     
    13891387          for iii in range(nnn):
    13901388           ix = self.index_x2d[iii] ; iy = self.index_y2d[iii]
    1391            for iz in self.index_z:
    1392             for it in self.index_t:
     1389           for iz in range(self.index_z.size):
     1390            for it in range(self.index_t.size):
    13931391              if what_I_am_supposed_to_do == "keepx":    self.field[it,iz,0,ix] = self.field[it,iz,iy,ix]
    13941392              elif what_I_am_supposed_to_do == "keepy":  self.field[it,iz,iy,0] = self.field[it,iz,iy,ix]
Note: See TracChangeset for help on using the changeset viewer.