source:
issm/oecreview/Archive/24684-25833/ISSM-25531-25532.diff
Last change on this file was 25834, checked in by , 4 years ago | |
---|---|
File size: 3.3 KB |
-
../trunk-jpl/src/m/io/loadvars.py
29 29 30 30 filename = '' 31 31 nvdict = {} 32 debug = False #print messages if true32 debug = True #print messages if true 33 33 34 34 if len(args) >= 1 and isinstance(args[0], str): 35 35 filename = args[0] … … 51 51 else: 52 52 raise TypeError("Unrecognized input arguments.") 53 53 54 onlylast = False54 onlylast = True 55 55 56 56 for key, value in kwargs.items(): 57 57 if key == 'onlylast': … … 132 132 else: 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 135 elif classtype[mod][0] == 'list': #Treating the old style of results 136 keylist = [key for key in curclass.groups] 137 # this is related to the old structure of NC files where every steps of results had its own group 138 if len(keylist) > 0: 139 #this is kept for compatibility 140 #and treatment of list of dicts?? 141 try: 142 #group are named after their step 143 steplist = [int(key) for key in curclass.groups] 144 except ValueError: 145 #or a number is appended at the end of the name 146 steplist = [int(findall(r'\d + ', key)[0]) for key in keylist] 147 indexlist = [int(index * (len(curclass.groups) - 1) / max(1, max(steplist))) for index in steplist] 148 listtype = curclass.groups[keylist[0]].classtype 149 #discriminate between dict and results 150 if listtype == 'dict': 151 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [OrderedDict() for i in range(max(1, len(curclass.groups)))] 152 else: 153 if onlylast: #we load only the last result to save on time and memory 154 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()] 155 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] 156 else: 157 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)() for i in range(max(1, len(curclass.groups)))] 158 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]][:] 159 else: 160 print("WARNING: we don't get the expected format, there might be an issue somewhere") 136 161 elif classtype[mod][0] == 'massfluxatgate': #this is for output definitions 137 162 defname = split('Output|[0-9]+', classtree[mod][1])[1] + 's' 138 163 defindex = int(findall('[0-9]+', classtree[mod][1])[0])
Note:
See TracBrowser
for help on using the repository browser.