Changeset 25817
- Timestamp:
- 12/03/20 05:46:39 (4 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/qmustatistics.py
r25698 r25817 13 13 14 14 def __init__(self, *args): #{{{ 15 self.nfiles_per_directory = 5# Number of files per output directory16 self.ndirectories = 50# Number of output directories; should be < numcpus15 self.nfiles_per_directory = 5 # Number of files per output directory 16 self.ndirectories = 50 # Number of output directories; should be < numcpus 17 17 18 18 self.method = [{}] … … 60 60 def setdefaultparameters(self): # {{{ 61 61 self.method[0]['name'] = 'None' 62 self.nfiles_per_directory = 5# Number of files per output directory63 self.ndirectories = 50# Number of output directories; should be < numcpus62 self.nfiles_per_directory = 5 # Number of files per output directory 63 self.ndirectories = 50 # Number of output directories; should be < numcpus 64 64 return self 65 65 #}}} -
issm/trunk-jpl/src/m/classes/results.py
r25780 r25817 1 1 from copy import deepcopy 2 2 3 import numpy as np 4 5 from fielddisplay import fielddisplay 6 7 8 class results(object): #{{{ 3 4 class results(object): #{{{ 9 5 """RESULTS class definition 10 6 … … 13 9 14 10 TODO: 15 - Rework so that a solution of arbitrary length (normal or transient) can 11 - Rework so that a solution of arbitrary length (normal or transient) can 16 12 initialized from one call to the results class constructor. 17 13 """ 18 14 19 def __init__(self): #{{{20 pass 21 #}}} 22 23 def __repr__(self): #{{{15 def __init__(self): #{{{ 16 pass 17 #}}} 18 19 def __repr__(self): #{{{ 24 20 s = '' 25 21 for key, value in self.__dict__.items(): … … 27 23 lengthvalue = 1 28 24 else: 29 lengthvalue = len(value) 25 try: 26 lengthvalue = len(value) 27 except TypeError: 28 lengthvalue = 1 30 29 s += ' {}: [1x{} struct]\n'.format(key, lengthvalue) 31 30 … … 33 32 #}}} 34 33 35 def setdefaultparameters(self): #{{{34 def setdefaultparameters(self): #{{{ 36 35 #do nothing 37 36 return self 38 37 #}}} 39 38 40 def checkconsistency(self, md, solution, analyses): #{{{ 41 return md 42 #}}} 43 44 def marshall(self, prefix, md, fid): #{{{ 45 pass 46 #}}} 47 #}}} 48 49 class resultsdakota(object): #{{{ 50 """RESULTSDAKOTA class definition - Used to store results from a run of 39 def checkconsistency(self, md, solution, analyses): #{{{ 40 return md 41 #}}} 42 43 def marshall(self, prefix, md, fid): #{{{ 44 pass 45 #}}} 46 #}}} 47 48 49 class resultsdakota(object): #{{{ 50 """RESULTSDAKOTA class definition - Used to store results from a run of 51 51 Dakota. 52 52 … … 57 57 """ 58 58 59 def __init__(self): #{{{60 pass 61 #}}} 62 63 def __repr__(self): #{{{59 def __init__(self): #{{{ 60 pass 61 #}}} 62 63 def __repr__(self): #{{{ 64 64 s = '' 65 65 for key, value in self.__dict__.items(): … … 73 73 #}}} 74 74 75 def __len__(self): #{{{75 def __len__(self): #{{{ 76 76 return len(self.__dict__.keys()) 77 77 #}}} 78 78 79 def setdefaultparameters(self): #{{{79 def setdefaultparameters(self): #{{{ 80 80 #do nothing 81 81 return self 82 82 #}}} 83 83 84 def checkconsistency(self, md, solution, analyses): #{{{ 85 return md 86 #}}} 87 88 def marshall(self, prefix, md, fid): #{{{ 89 pass 90 #}}} 91 #}}} 92 93 class solution(object): #{{{ 94 """SOLUTION class definition - Value of an attribute (which should be 84 def checkconsistency(self, md, solution, analyses): #{{{ 85 return md 86 #}}} 87 88 def marshall(self, prefix, md, fid): #{{{ 89 pass 90 #}}} 91 #}}} 92 93 94 class solution(object): #{{{ 95 """SOLUTION class definition - Value of an attribute (which should be 95 96 a string representing a solution type) of an instance of results class 96 97 … … 102 103 NOTE: 103 104 - Under MATLAB, this is implemented as a structure array 104 - Only when this instance of solution represents a transient solution 105 - Only when this instance of solution represents a transient solution 105 106 should self.steps have more than one element 106 107 """ 107 108 108 def __init__(self, *args): #{{{109 def __init__(self, *args): #{{{ 109 110 self.steps = None 110 111 if len(args) == 1: … … 118 119 #}}} 119 120 120 def __deepcopy__(self, memo): #{{{121 def __deepcopy__(self, memo): #{{{ 121 122 return solution(deepcopy(self.steps, memo)) 122 123 #}}} 123 124 124 def __repr__(self): #{{{125 def __repr__(self): #{{{ 125 126 s = '' 126 127 numsteps = len(self.steps) … … 137 138 #}}} 138 139 139 def __len__(self): #{{{140 def __len__(self): #{{{ 140 141 return len(self.steps) 141 142 #}}} 142 143 143 def __getattr__(self, key): #{{{144 def __getattr__(self, key): #{{{ 144 145 if len(self.steps) == 1: 145 146 return getattr(self.steps[0], key) … … 148 149 #}}} 149 150 150 def __getitem__(self, index): #{{{151 def __getitem__(self, index): #{{{ 151 152 while True: 152 153 try: … … 158 159 #}}} 159 160 160 def setdefaultparameters(self): #{{{ 161 return self 162 #}}} 163 164 def checkconsistency(self, md, solution, analyses): #{{{ 165 return md 166 #}}} 167 168 def marshall(self, prefix, md, fid): #{{{ 169 pass 170 #}}} 171 #}}} 172 173 class solutionstep(object): #{{{ 161 def setdefaultparameters(self): #{{{ 162 return self 163 #}}} 164 165 def checkconsistency(self, md, solution, analyses): #{{{ 166 return md 167 #}}} 168 169 def marshall(self, prefix, md, fid): #{{{ 170 pass 171 #}}} 172 #}}} 173 174 175 class solutionstep(object): #{{{ 174 176 """SOLUTIONSTEP class definition - Single element of <solution>.steps 175 177 … … 178 180 """ 179 181 180 def __init__(self, *args): #{{{181 pass 182 #}}} 183 184 def __repr__(self): #{{{182 def __init__(self, *args): #{{{ 183 pass 184 #}}} 185 186 def __repr__(self): #{{{ 185 187 s = '' 186 188 width = self.getlongestfieldname() … … 191 193 #}}} 192 194 193 def getfieldnames(self): #{{{195 def getfieldnames(self): #{{{ 194 196 return self.__dict__.keys() 195 197 #}}} 196 198 197 def getlongestfieldname(self): #{{{199 def getlongestfieldname(self): #{{{ 198 200 maxlength = 0 199 201 for key in self.__dict__.keys(): … … 205 207 #}}} 206 208 207 def setdefaultparameters(self): #{{{208 return self 209 #}}} 210 211 def checkconsistency(self, md, solution, analyses): #{{{212 return md 213 #}}} 214 215 def marshall(self, prefix, md, fid): #{{{216 pass 217 #}}} 218 #}}} 209 def setdefaultparameters(self): #{{{ 210 return self 211 #}}} 212 213 def checkconsistency(self, md, solution, analyses): #{{{ 214 return md 215 #}}} 216 217 def marshall(self, prefix, md, fid): #{{{ 218 pass 219 #}}} 220 #}}} -
issm/trunk-jpl/src/m/classes/solidearthsettings.py
r25806 r25817 13 13 """ 14 14 15 def __init__(self, *args): #{{{15 def __init__(self, *args): #{{{ 16 16 self.reltol = 0 17 17 self.abstol = 0 -
issm/trunk-jpl/src/m/os/issmscpout.py
r24252 r25817 17 17 #if hostname and host are the same, do a simple copy 18 18 19 if m.strcmpi(host, hostname):19 if host == hostname: 20 20 for package in packages: 21 21 here = os.getcwd() -
issm/trunk-jpl/src/m/solve/loadresultfromdisk.py
r25718 r25817 2 2 import numpy as np 3 3 4 def loadresultfromdisk(filename, step, name, *args): # {{{ 4 5 def loadresultfromdisk(filename, step, name, *args): # {{{ 5 6 """ 6 LOADRESULTFROMDISK - load specific result of solution sequence from disk 7 LOADRESULTFROMDISK - load specific result of solution sequence from disk 7 8 file "filename" 8 9 … … 18 19 try: 19 20 fid = open(filename, 'rb') 20 except IOError as e:21 except IOError: 21 22 raise IOError("loadresultsfromdisk error message: could not open {} for binary reading".format(filename)) 22 23 … … 36 37 rstep = struct.unpack('i', fid.read(struct.calcsize('i')))[0] 37 38 38 # TODO: Check number of characters unpacked and break if need be (see 39 # TODO: Check number of characters unpacked and break if need be (see 39 40 # src/m/solve/loadresultfromdisk.py) 40 41 41 42 if (rstep == step) and (fieldname == name): 42 43 # ok, go read the result really -
issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py
r25688 r25817 1 1 import os 2 import platform3 2 import socket 4 3 … … 15 14 print(('WARNING: ' + filename + ' does not exist')) 16 15 16 17 17 def loadresultsfromcluster(md, *args): 18 18 """LOADRESULTSFROMCLUSTER - load results of solution sequence from cluster 19 19 20 20 Usage: 21 md = loadresultsfromcluster(md, runtimename) 21 md = loadresultsfromcluster(md) 22 md = loadresultsfromcluster(md, 'runtimename', runtimename) 22 23 """ 23 24 -
issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py
r25726 r25817 1 1 import os 2 3 2 from helpers import fieldnames, struct 4 3 from parseresultsfromdisk import parseresultsfromdisk … … 8 7 9 8 def loadresultsfromdisk(md, filename): 10 """LOADRESULTSFROMDISK - load results of solution sequence from disk file 9 """LOADRESULTSFROMDISK - load results of solution sequence from disk file 11 10 "filename" 12 11 … … 23 22 # Check that file exists 24 23 if not os.path.exists(filename): 25 err_msg 24 err_msg = '============================================================\n' 26 25 err_msg += ' Binary file {} not found \n'.format(filename) 27 26 err_msg += ' \n' -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py
r25726 r25817 1 1 from collections import OrderedDict 2 2 import struct 3 4 3 import numpy as np 5 6 4 from results import solution 7 5 8 6 9 def parseresultsfromdisk(md, filename, iosplit): #{{{7 def parseresultsfromdisk(md, filename, iosplit): #{{{ 10 8 if iosplit: 11 9 saveres = parseresultsfromdiskiosplit(md, filename) … … 16 14 #}}} 17 15 16 18 17 def parseresultsfromdiskiosplit(md, filename): # {{{ 19 18 #Open file 20 19 try: 21 20 fid = open(filename, 'rb') 22 except IOError as e:21 except IOError: 23 22 raise IOError("parseresultsfromdisk error message: could not open '{}' for binary reading.".format(filename)) 24 23 … … 89 88 result = ReadData(fid, md) 90 89 91 if result ==None:90 if result is None: 92 91 if allresults == []: 93 92 raise Exception('no results found in binary file ' + filename)
Note:
See TracChangeset
for help on using the changeset viewer.