Index: ../trunk-jpl/src/m/io/loadvars.py =================================================================== --- ../trunk-jpl/src/m/io/loadvars.py (revision 25531) +++ ../trunk-jpl/src/m/io/loadvars.py (revision 25532) @@ -29,7 +29,7 @@ filename = '' nvdict = {} - debug = False #print messages if true + debug = True #print messages if true if len(args) >= 1 and isinstance(args[0], str): filename = args[0] @@ -51,7 +51,7 @@ else: raise TypeError("Unrecognized input arguments.") - onlylast = False + onlylast = True for key, value in kwargs.items(): if key == 'onlylast': @@ -132,7 +132,32 @@ else: nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)() for i in range(max(1, len(NCFile.dimensions['Time'])))] Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]][:] - + elif classtype[mod][0] == 'list': #Treating the old style of results + keylist = [key for key in curclass.groups] + # this is related to the old structure of NC files where every steps of results had its own group + if len(keylist) > 0: + #this is kept for compatibility + #and treatment of list of dicts?? + try: + #group are named after their step + steplist = [int(key) for key in curclass.groups] + except ValueError: + #or a number is appended at the end of the name + steplist = [int(findall(r'\d + ', key)[0]) for key in keylist] + indexlist = [int(index * (len(curclass.groups) - 1) / max(1, max(steplist))) for index in steplist] + listtype = curclass.groups[keylist[0]].classtype + #discriminate between dict and results + if listtype == 'dict': + nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [OrderedDict() for i in range(max(1, len(curclass.groups)))] + else: + if onlylast: #we load only the last result to save on time and memory + nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()] + Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] + else: + nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)() for i in range(max(1, len(curclass.groups)))] + Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]][:] + else: + print("WARNING: we don't get the expected format, there might be an issue somewhere") elif classtype[mod][0] == 'massfluxatgate': #this is for output definitions defname = split('Output|[0-9]+', classtree[mod][1])[1] + 's' defindex = int(findall('[0-9]+', classtree[mod][1])[0])