Changeset 25346 for issm/trunk-jpl/src/m/io/loadvars.py
- Timestamp:
- 08/05/20 00:25:08 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/io/loadvars.py
r25125 r25346 15 15 16 16 17 def loadvars(*args, OL):18 '''17 def loadvars(*args, **kwargs): 18 """ 19 19 LOADVARS - function to load variables from a file. 20 20 … … 30 30 nvdict = loadvars('shelve.dat', {'a':None, 'b':None}) 31 31 nvdict = loadvars('shelve.dat') 32 '''32 """ 33 33 34 34 filename = '' … … 55 55 else: 56 56 raise TypeError("Unrecognized input arguments.") 57 58 onlylast = False 59 60 for key, value in kwargs.items(): 61 if key == 'onlylast': 62 onlylast = value 57 63 58 64 if whichdb(filename): #We used python pickle for the save … … 110 116 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [OrderedDict() for i in range(max(1, len(curclass.groups)))] 111 117 else: 112 if OL: #we load only the last result to save on time and memory118 if onlylast: #we load only the last result to save on time and memory 113 119 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()] 114 120 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] … … 126 132 if AllHaveTime: 127 133 #Time dimension is in all the variables so we take that as stepnumber for the results 128 if OL: #we load only the last result to save on time and memory134 if onlylast: #we load only the last result to save on time and memory 129 135 nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()] 130 136 Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] … … 166 172 NewFormat = 'Time' in NCFile.dimensions 167 173 if type(Tree) == list and NewFormat: 168 if OL:174 if onlylast: 169 175 if vardim == 1: 170 176 Tree[0].__dict__[str(var)] = varval[-1].data
Note:
See TracChangeset
for help on using the changeset viewer.