Changeset 1068 for trunk/UTIL
- Timestamp:
- Oct 14, 2013, 4:26:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r1067 r1068 1263 1263 self.dim_x = None ; self.dim_y = None ; self.dim_z = None ; self.dim_t = None 1264 1264 self.field_x = None ; self.field_y = None ; self.field_z = None ; self.field_t = None 1265 self.tabtime = None 1265 1266 self.dimplot = 0 1266 1267 self.nplot = 1 … … 1397 1398 try: 1398 1399 # 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] 1400 1401 # (consider the case where tabtime is not dim 1) 1401 1402 # (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] 1405 1406 # (now proceed) (the +0. just ensures this is a number) 1406 dafirst = tabtime[0] + 0.1407 dafirst = self.tabtime[0] + 0. 1407 1408 if self.dim_t == 1: 1408 1409 self.field_t = np.array([dafirst]) 1409 1410 else: 1410 daint = tabtime[1] - dafirst1411 daint = self.tabtime[1] - dafirst 1411 1412 dalast = dafirst + (self.dim_t-1)*daint 1412 1413 self.field_t = np.linspace(dafirst,dalast,num=self.dim_t) 1413 1414 if self.verbose: 1414 1415 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] 1417 1418 except: 1418 1419 # ... or if a problem encountered, define a simple time axis … … 1442 1443 ### options added by A. Spiga 1443 1444 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 1447 1447 dalast = dafirst + (self.dim_t-1)*daint 1448 1448 year = 0. 1449 1449 add = np.linspace(dafirst,dalast,num=self.dim_t) ; add[0] = 0. 1450 1450 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. 1452 1452 add[iii] = year*360. 1453 self.field_t = add + tabtime1453 self.field_t = add + self.tabtime 1454 1454 elif "mars_meso" in self.changetime: 1455 1455 if 'Times' not in self.f.variables.keys():
Note: See TracChangeset
for help on using the changeset viewer.