Changeset 925 for trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
- Timestamp:
- Apr 3, 2013, 12:18:48 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r923 r925 1356 1356 self.field_z = self.field_z[self.index_z] 1357 1357 self.field_t = self.field_t[self.index_t] 1358 # now have to obtain the new indexes which correspond to the extracted self.field1359 # for it to work with unique index, ensure that any index_* is a numpy array1360 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 EXPENSIVE1369 ## recast self.field with 2D horizontal arrays because we might have extracted1370 ## more than what is to be actually plot or computed, in particular for comps on 2D lat,lon coordinates1371 #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.shape1373 1358 # extract relevant horizontal points 1374 1359 # TBD: is compfree OK with computing on irregular grid? … … 1378 1363 elif test in ["fixedfree","fixedcomp"] or test in ["freefixed","compfixed"]: 1379 1364 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 1380 1378 # prepare the loop on all relevant horizontal points 1381 1379 if self.method_x in ["comp","free"]: … … 1389 1387 for iii in range(nnn): 1390 1388 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): 1393 1391 if what_I_am_supposed_to_do == "keepx": self.field[it,iz,0,ix] = self.field[it,iz,iy,ix] 1394 1392 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.