Changeset 25698
- Timestamp:
- 10/20/20 19:29:01 (4 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/qmustatistics.py
r25688 r25698 85 85 for f in range(len(m['fields'])): 86 86 if not isinstance(m['fields'][f], str): 87 raise Exception('qmustatistics consistency check error: qmu.statistics.method[{}][\'fields\' [{}] is not a string!'.format(i, f))87 raise Exception('qmustatistics consistency check error: qmu.statistics.method[{}][\'fields\'][{}] is not a string!'.format(i, f)) 88 88 for s in range(len(m['steps'])): 89 89 if m['steps'][s] <= 0: 90 raise Exception('qmustatistics consistency check error: qmu.statistics.method[{}][\'steps\' [{}] should be > 0!'.format(i, s))90 raise Exception('qmustatistics consistency check error: qmu.statistics.method[{}][\'steps\'][{}] should be > 0!'.format(i, s)) 91 91 if m['steps'][s] > md.mesh.numberofvertices: 92 raise Exception('qmustatistics consistency check error: qmu.statistics.method[{}][\'steps\' [{}] should be < md.mesh.numberofvertices!'.format(i, s))92 raise Exception('qmustatistics consistency check error: qmu.statistics.method[{}][\'steps\'][{}] should be < md.mesh.numberofvertices!'.format(i, s)) 93 93 #}}} 94 94 -
issm/trunk-jpl/src/m/classes/results.py
r25688 r25698 2 2 3 3 4 class results(object): 4 class results(object): #{{{ 5 5 """RESULTS class definition 6 6 7 7 Usage: 8 results = results() 9 10 TODO: 11 - Modify output so that it matches that of 12 13 disp(md.results.<<solutionstring>>) 14 15 where <<solutionstring>> is one of the values from solve.m 8 md.results = results() 16 9 """ 17 10 18 def __init__(self, *args): #{{{11 def __init__(self, *args): #{{{ 19 12 pass 20 # 13 #}}} 21 14 22 def __repr__(self): # {{{ 23 s = " Model results:\n" 24 15 def __repr__(self): #{{{ 16 s = '' 25 17 if 'step' in self.__dict__: 26 s += "%s\n" % fielddisplay(self, 'step', "step number")18 s += '{}\n'.format(fielddisplay(self, 'step', "step number")) 27 19 if 'time' in self.__dict__: 28 s += "%s\n" % fielddisplay(self, 'time', "time value")20 s += '{}\n'.format(fielddisplay(self, 'time', "time value")) 29 21 if 'SolutionType' in self.__dict__: 30 s += "%s\n" % fielddisplay(self, 'SolutionType', "solution type")22 s += '{}\n'.format(fielddisplay(self, 'SolutionType', "solution type")) 31 23 32 24 for name in list(self.__dict__.keys()): 33 25 if name not in ['step', 'time', 'SolutionType', 'errlog', 'outlog']: 34 26 if isinstance(getattr(self, name), list): 35 s += "%s\n" % fielddisplay(self, name, "model results list")27 s += '{}\n'.format(fielddisplay(self, name, "model results list")) 36 28 elif isinstance(getattr(self, name), results): 37 s += "%s\n" % fielddisplay(self, name, "model results case")29 s += '{}\n'.format(fielddisplay(self, name, "model results case")) 38 30 else: 39 s += "%s\n" % fielddisplay(self, name, "")31 s += '{}\n'.format(fielddisplay(self, name, "")) 40 32 41 33 if 'errlog' in self.__dict__: 42 s += "%s\n" % fielddisplay(self, 'errlog', "error log file")34 s += '{}\n'.format(fielddisplay(self, 'errlog', "error log file")) 43 35 if 'outlog' in self.__dict__: 44 s += "%s\n" % fielddisplay(self, 'outlog', "output log file")36 s += '{}\n'.format(fielddisplay(self, 'outlog', "output log file")) 45 37 46 38 return s 47 # 39 #}}} 48 40 49 def setdefaultparameters(self): #{{{41 def setdefaultparameters(self): #{{{ 50 42 #do nothing 51 43 return self 52 # 44 #}}} 53 45 54 def checkconsistency(self, md, solution, analyses): #{{{46 def checkconsistency(self, md, solution, analyses): #{{{ 55 47 return md 56 # 48 #}}} 57 49 58 def marshall(self, prefix, md, fid): #{{{50 def marshall(self, prefix, md, fid): #{{{ 59 51 pass 60 # }}} 52 #}}} 53 #}}} 54 55 class resultselement(object): #{{{ 56 """RESULTSELEMENT class definition - Value of attribute of results 57 58 Usage: 59 setattr(md.results, '<solution_type>', resultselement()) 60 """ 61 62 def __init__(self, *args): #{{{ 63 self.elements = [result()] 64 #}}} 65 66 def __repr__(self): #{{{ 67 s = ' 1x{} struct array with fields:\n'.format(len(self.elements)) 68 s += '\n' 69 70 if len(self.elements) >= 1: 71 for name in list(self.elements[0].__dict__.keys()): 72 s += ' {}\n'.format(name) 73 74 return s 75 #}}} 76 77 def __len__(self): #{{{ 78 return len(self.elements) 79 #}}} 80 81 def __getitem__(self, index): #{{{ 82 while True: 83 try: 84 return self.elements[index] 85 except: 86 self.elements.append(result()) 87 #}}} 88 89 def __setitem__(self, index, value): #{{{ 90 while True: 91 try: 92 self.elements[index] = value 93 break 94 except: 95 self.elements.append(result()) 96 #}}} 97 98 def setdefaultparameters(self): #{{{ 99 return self 100 #}}} 101 102 def checkconsistency(self, md, solution, analyses): #{{{ 103 return md 104 #}}} 105 106 def marshall(self, prefix, md, fid): #{{{ 107 pass 108 #}}} 109 #}}} 110 111 class result(object): #{{{ 112 """RESULT class definition - Element of resultselement::elements 113 114 Usage: 115 resultselement.elements.append(result()) 116 """ 117 118 def __init__(self, *args): #{{{ 119 pass 120 #}}} 121 122 def setdefaultparameters(self): #{{{ 123 return self 124 #}}} 125 126 def checkconsistency(self, md, solution, analyses): #{{{ 127 return md 128 #}}} 129 130 def marshall(self, prefix, md, fid): #{{{ 131 pass 132 #}}} 133 #}}} -
issm/trunk-jpl/src/m/solve/loadresultsfromdisk.m
r25688 r25698 65 65 end 66 66 67 %post processes qmu results if necessary67 %postprocess qmu results if necessary 68 68 else 69 69 md=postqmu(md); -
issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py
r25688 r25698 3 3 import numpy as np # Remove: used temporarily for debugging 4 4 5 from helpers import fieldnames 5 from helpers import fieldnames, struct 6 6 from parseresultsfromdisk import parseresultsfromdisk 7 7 from postqmu import postqmu … … 34 34 raise OSError(err_msg) 35 35 36 # Initialize md.results if not a structure yet37 if not isinstance(md.results, results):36 # # Initialize md.results if not a structure yet 37 if not isinstance(md.results, struct): 38 38 md.results = results() 39 39 … … 73 73 setattr(md.results, structure[0].SolutionType, structure[0]) 74 74 75 # Post processes QMU results if necessary75 # Postprocess QMU results if necessary 76 76 else: 77 77 md = postqmu(md) -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py
r25694 r25698 4 4 import numpy as np 5 5 6 import results as resultsclass 6 from results import resultselement 7 7 8 8 … … 25 25 saveres = [] 26 26 27 #if we have done split I /O, ie, we have results that are fragmented across patches,27 #if we have done split I/O, ie, we have results that are fragmented across patches, 28 28 #do a first pass, and figure out the structure of results 29 29 loadres = ReadDataDimensions(fid) … … 83 83 except IOError as e: 84 84 raise IOError("parseresultsfromdisk error message: could not open {} for binary reading".format(filename)) 85 85 86 86 # Collect all results in a list 87 87 allresults = [] … … 108 108 109 109 # Ok, now construct structure 110 results = [] 111 for i in range(len(allsteps)): 112 results.append(resultsclass.results()) 110 results = resultselement() 113 111 for i in range(numresults): 114 112 result = allresults[i] -
issm/trunk-jpl/test/NightlyRun/test2006.m
r25688 r25698 182 182 md=solve(md,'Transient'); 183 183 184 disp(mds.results.StatisticsSolution)185 186 184 %compare statistics with our own here: 187 svalues=mds.results.StatisticsSolution(end).SealevelSamples; %all values at locations. 185 svalues=mds.results.StatisticsSolution(end).SealevelSamples; %all values at locations. 188 186 189 187 dvalues=zeros(md.qmu.method.params.samples,length(locations)); … … 191 189 dvalues(i,:)=md.results.dakota.modelresults{i}.TransientSolution(end).Sealevel(locations); 192 190 end 193 194 disp(dvalues)195 disp(size(dvalues))196 191 197 192 samplesnorm=norm(dvalues-svalues,'fro'); -
issm/trunk-jpl/test/NightlyRun/test2006.py
r25688 r25698 135 135 md.qmu.variables.surfaceload = qmuvar.surfaceload 136 136 137 locations = [1, 5, 10, 15, 20]137 locations = np.array([1, 5, 10, 15, 20]) 138 138 139 139 # Responses #{{{ … … 208 208 md.qmu.statistics.method[2]['fields'] = ['Sealevel', 'BslrIce'] 209 209 md.qmu.statistics.method[2]['steps'] = np.arange(1, 10 + 1).reshape(1, -1) 210 md.qmu.statistics.method[2]['indices'] = np.asarray(locations).reshape(1, -1)210 md.qmu.statistics.method[2]['indices'] = locations.reshape(1, -1) 211 211 #}}} 212 212 … … 219 219 220 220 # Compare statistics with our own here 221 # 222 # TODO: SealevelSamples should be an attribute of mds.results.StatisticsSolution[-1] (see test2006.m) 223 # 224 svalues = mds.results.StatisticsSolution[0].SealevelSamples # all values at locations 221 svalues = mds.results.StatisticsSolution[-1].SealevelSamples # all values at locations 225 222 226 223 dvalues = np.zeros((md.qmu.method.params.samples, len(locations))) 227 228 224 for i in range(md.qmu.method.params.samples): 229 dvalues[i, :] = md.results.dakota.modelresults[i].TransientSolution[-1].Sealevel[locations ].flatten()225 dvalues[i, :] = md.results.dakota.modelresults[i].TransientSolution[-1].Sealevel[locations - 1].flatten() 230 226 231 227 samplesnorm = np.linalg.norm(dvalues - svalues, 'fro')
Note:
See TracChangeset
for help on using the changeset viewer.