Changeset 19348
- Timestamp:
- 05/07/15 22:40:01 (10 years ago)
- Location:
- issm/trunk-jpl/src/m/solve
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.m
r19343 r19348 61 61 end 62 62 results(index).step=result.step; 63 if result.time~=-9999,64 results(index).time=result.time;65 end66 63 results(index).(result.fieldname)=result.field; 67 64 -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py
r19336 r19348 34 34 raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename) 35 35 36 #initialize results: 36 37 results=[] 38 results.append(None) 37 39 38 40 #Read fields until the end of the file. 39 41 result=ReadData(fid) 40 while result: 41 print result['step'] 42 if result['step'] > len(results): 43 for i in xrange(len(results),result['step']-1): 42 43 counter=0 44 check_nomoresteps=0 45 step=result['step'] 46 47 while result: 48 49 if check_nomoresteps: 50 #check that the new result does not add a step, which would be an error: 51 if result['step']>=1: 52 raise TypeError("parsing results for a steady-state core, which incorporates transient results!") 53 54 #Check step, increase counter if this is a new step 55 if(step!=result['step'] and result['step']>1): 56 counter = counter + 1 57 step = result['step'] 58 59 #Add result 60 if result['step']==-1: 61 #specialty case, put this result at the beginning of the structure 62 index = 0 63 result['step']=0 64 elif result['step']==0: 65 #if we have a step = 0, this is a steady state solutoin, don't expect more steps. 66 index = 0; 67 check_nomoresteps=1 68 69 elif result['step']==1: 70 index = 0 71 else: 72 index = counter; 73 74 if index > len(results)-1: 75 for i in xrange(len(results)-1,index-1): 44 76 results.append(None) 45 77 results.append(resultsclass.results()) 46 elif results[result['step']-1] is None: 47 results[result['step']-1]=resultsclass.results() 78 79 elif results[index] is None: 80 results[index]=resultsclass.results() 81 82 if index==0 and step==3: 83 print result 84 48 85 #Get time and step 49 setattr(results[ result['step']-1],'step',result['step'])50 setattr(results[ result['step']-1],'time',result['time'])86 setattr(results[index],'step',result['step']) 87 setattr(results[index],'time',result['time']) 51 88 52 89 #Add result 53 if hasattr(results[ result['step']-1],result['fieldname']) and not m.strcmp(result['fieldname'],'SolutionType'):54 setattr(results[ result['step']-1],result['fieldname'],numpy.vstack((getattr(results[result['step']-1],result['fieldname']),result['field'])))55 else: 56 setattr(results[ result['step']-1],result['fieldname'],result['field'])90 if hasattr(results[index],result['fieldname']) and not m.strcmp(result['fieldname'],'SolutionType'): 91 setattr(results[index],result['fieldname'],numpy.vstack((getattr(results[index],result['fieldname']),result['field']))) 92 else: 93 setattr(results[index],result['fieldname'],result['field']) 57 94 58 95 #read next result
Note:
See TracChangeset
for help on using the changeset viewer.