Changeset 25591
- Timestamp:
- 09/24/20 00:18:02 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/io/loadvars.py ¶
r25532 r25591 30 30 filename = '' 31 31 nvdict = {} 32 debug = True #print messages if true32 debug = False #print messages if true 33 33 34 34 if len(args) >= 1 and isinstance(args[0], str): … … 94 94 if debug: 95 95 print("===> {} is of class {}".format(mod, classtype[mod][0])) 96 if classtype[mod][0] == 'results' and 'Time' in NCFile.dimensions: #Treating results 96 if classtype[mod][0] == 'results' and 'Time' in NCFile.dimensions: #Treating results {{{ 97 97 keylist = [key for key in curclass.groups] 98 98 # this is related to the old structure of NC files where every steps of results had its own group … … 133 133 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)() for i in range(max(1, len(NCFile.dimensions['Time'])))] 134 134 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]][:] 135 elif classtype[mod][0] == 'list': #Treating the old style of results 135 #}}} 136 elif classtype[mod][0] == 'list': #Treating the old style of results {{{ 136 137 keylist = [key for key in curclass.groups] 137 138 # this is related to the old structure of NC files where every steps of results had its own group … … 159 160 else: 160 161 print("WARNING: we don't get the expected format, there might be an issue somewhere") 161 elif classtype[mod][0] == 'massfluxatgate': #this is for output definitions 162 # }}} 163 elif classtype[mod][0] == 'massfluxatgate': #this is for output definitions {{{ 162 164 defname = split('Output|[0-9]+', classtree[mod][1])[1] + 's' 163 165 defindex = int(findall('[0-9]+', classtree[mod][1])[0]) 164 166 nvdict['md'].__dict__[classtree[mod][0]].__dict__[defname].append(getattr(classtype[mod][1], classtype[mod][0])()) 165 167 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[defname][defindex - 1] 166 168 #}}} 167 169 else: 168 170 if debug: … … 207 209 if incomplete: 208 210 chosendim = varval.dimensions[0] 209 indexlist = np.arange(0, len(NCFile.dimensions[chosendim]))211 timelist = np.arange(0, len(NCFile.dimensions[chosendim])) 210 212 print('WARNING, {} is not present on every times, we chose {}({}) as the dimension to write it with'.format(var, chosendim, len(NCFile.dimensions[chosendim]))) 211 213 else: 212 indexlist = np.arange(0, len(NCFile.dimensions['Time']))213 for t in indexlist:214 timelist = np.arange(0, len(NCFile.dimensions['Time'])) 215 for t in timelist: 214 216 if vardim == 0: 215 217 Tree[t].__dict__[str(var)] = varval[:].data … … 303 305 if attr == 'VARNAME': 304 306 attribute = 'name' 305 if type(Tree) == list: 307 if type(Tree) == list and NewFormat: 308 if debug: 309 print("printing with index 0") 310 if listtype == 'dict': 311 Tree[0][attribute] = str(listclass.getncattr(attr)) 312 else: 313 Tree[0].__dict__[attribute] = str(listclass.getncattr(attr)) 314 elif type(Tree) == list: 306 315 t = int(indexlist[i]) 316 if debug: 317 print("printing with index {]".format(t)) 307 318 if listtype == 'dict': 308 319 Tree[t][attribute] = str(listclass.getncattr(attr))
Note:
See TracChangeset
for help on using the changeset viewer.