Changeset 25097
- Timestamp:
- 06/22/20 11:19:30 (5 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/array/MatlabArray.py
r24873 r25097 1 1 from copy import deepcopy 2 from functools import reduce 3 2 4 import numpy as np 5 6 from helpers import * 3 7 from MatlabFuncs import * 4 #move this later5 from helpers import *6 from functools import reduce7 8 8 9 … … 167 168 such that: given the array / matrix a, 168 169 idim is the linear index of an element in a, 169 return the x / y / z / w /... coordinates of idim in n dimensions170 return the x/y/z/w/... coordinates of idim in n dimensions 170 171 171 172 ex. a = [1 2 3 -
issm/trunk-jpl/src/m/classes/qmu/histogram_bin_uncertain.m
r25090 r25097 59 59 end 60 60 end % }}} 61 %virtual functions needed by qmu processing algorithms: 62 %implemented: 61 63 function [desc]=prop_desc(hbu,dstr) % {{{ 62 64 desc=cell(1,numel(hbu)); … … 74 76 desc=allempty(desc); 75 77 end %}}} 76 function [initpt]=prop_initpt(hbu) % {{{ 77 initpt=[]; 78 function [mean]=prop_mean(hbu) % {{{ 79 mean=[]; 80 end % }}} 81 function [stddev]=prop_stddev(hbu) % {{{ 82 stddev=[]; 78 83 end % }}} 79 84 function [lower]=prop_lower(hbu) % {{{ … … 82 87 function [upper]=prop_upper(hbu) % {{{ 83 88 upper=[]; 84 end % }}}85 function [mean]=prop_mean(hbu) % {{{86 mean=[];87 end % }}}88 function [stddev]=prop_stddev(hbu) % {{{89 stddev=[];90 end % }}}91 function [initst]=prop_initst(hbu) % {{{92 initst=[];93 end % }}}94 function [stype]=prop_stype(hbu) % {{{95 stype={};96 end % }}}97 function [scale]=prop_scale(hbu) % {{{98 scale=[];99 89 end % }}} 100 90 function [abscissas]=prop_abscissas(hbu) % {{{ … … 119 109 counts=allequal(counts,-Inf); 120 110 end % }}} 111 function [initpt]=prop_initpt(hbu) % {{{ 112 initpt=[]; 113 end % }}} 114 function [initst]=prop_initst(hbu) % {{{ 115 initst=[]; 116 end % }}} 117 function [stype]=prop_stype(hbu) % {{{ 118 stype={}; 119 end % }}} 120 function [scale]=prop_scale(hbu) % {{{ 121 scale=[]; 122 end % }}} 121 123 function scaled=isscaled(self) % {{{ 122 124 if strncmp(self.descriptor,'scaled_',7), -
issm/trunk-jpl/src/m/classes/qmu/histogram_bin_uncertain.py
r25090 r25097 1 1 import numpy as np 2 3 from MatlabArray import string_dim 2 4 3 5 … … 65 67 else: 66 68 raise Exception("Construction of histogram_bin_uncertain class object requires either (1) no arguments, (2) a histogram_bin_uncertain instance to copy from, or (3) a descriptor and pairs per variable, abscissas, and counts lists") 69 70 @staticmethod 71 def __repr__(hbu): #{{{ 72 s = "" 73 for i in range(len(hbu)): 74 s += "class {} object {} = \n".format(hbu.__class__.__name__, string_dim(hbu, i)) 75 s = "{}\n{}".format(s, fielddisplay(self, 'descriptor', 'name tag')) 76 s = "{}\n{}".format(s, fielddisplay(self, 'pairs_per_variable', 'pairs per variable')) 77 s = "{}\n{}".format(s, fielddisplay(self, 'abscissas', 'abscissas')) 78 s = "{}\n{}".format(s, fielddisplay(self, 'counts', 'counts')) 79 80 return s 81 #}}} 82 83 def checkconsistency(self, md, solution, analyses): #{{{ 84 return 85 #}}} 86 87 #virtual functions needed by qmu processing algorithms 88 #implemented: 89 90 @staticmethod 91 def prop_desc(hbu, dstr): #{{{ 92 desc = ['' for i in range(np.size(hbu))] 93 for i in range(np.size(hbu)): 94 if hbu[i].descriptor != '' or type(hbu[i].descriptor) != str: 95 desc[i] = str(hbu[i].descriptor) 96 elif dstr != '': 97 desc[i] = str(dstr) + str(string_dim(hbu, i, 'vector')) 98 else: 99 desc[i] = 'hbu' + str(string_dim(hbu, i, 'vector')) 100 101 desc = allempty(desc) 102 103 return desc 104 #}}} 105 106 @staticmethod 107 def prop_mean(hbu): #{{{ 108 mean = np.zeros(np.size(hbu)) 109 for i in range(np.size(hbu)): 110 mean[i] = hbu[i].mean 111 return mean 112 #}}} 113 114 @staticmethod 115 def prop_stddev(hbu): #{{{ 116 stddev = np.zeros(np.size(hbu)) 117 for i in range(np.size(hbu)): 118 stddev[i] = hbu[i].stddev 119 return stddev 120 #}}} 121 122 @staticmethod 123 def prop_lower(hbu): #{{{ 124 lower = [] 125 return 126 #}}} 127 128 @staticmethod 129 def prop_upper(hbu): #{{{ 130 upper = [] 131 return upper 132 #}}} 133 134 #default 135 @staticmethod 136 def prop_abscissas(hbu): #{{{ 137 abscissas = [] 138 for i in range(len(hbu)): 139 abscissas.extend(hbu[i].abscissas) 140 abscissas = allequal(abscissas, -np.inf) 141 return abscissas 142 #}}} 143 144 @staticmethod 145 def prop_pairs_per_variable(hbu): #{{{ 146 pairs_per_variable = np.zeros((1, len(hbu))) 147 for i in range(len(hbu)): 148 pairs_per_variable[i] = hbu[i].pairs_per_variable 149 abscissas = allequal(pairs_per_variable, -np.inf) 150 return pairs_per_variable 151 #}}} 152 153 @staticmethod 154 def prop_counts(hbu): #{{{ 155 counts = [] 156 for i in range(len(hbu)): 157 counts.extend(hbu[i].counts) 158 counts = allequal(counts, -np.inf) 159 return counts 160 #}}} 161 162 @staticmethod 163 def prop_initpt(hbu): #{{{ 164 initpt = [] 165 return initpt 166 #}}} 167 168 @staticmethod 169 def prop_initst(hbu): #{{{ 170 inist = [] 171 return inist 172 #}}} 173 174 @staticmethod 175 def prop_stype(hbu): #{{{ 176 stype = [] 177 return stype 178 #}}} 179 180 @staticmethod 181 def prop_scale(hbu): #{{{ 182 scale = [] 183 return scale 184 #}}} 185 186 #new methods: 187 def isscaled(self): #{{{ 188 if strncmp(self.descriptor, 'scaled_', 7): 189 return True 190 else: 191 return False 192 #}}} 193 194 @staticmethod 195 def dakota_write(fidi, dvar): 196 # possible namespace pollution, the above import seems not to work 197 from vlist_write import vlist_write 198 # collect only the variables of the appropriate class 199 hbu = deepcopy(dvar) 200 fields = fieldnames(hbu) 201 for field in fields: 202 if getattr(hbu, field)[0].__class__.__name__ != 'histogram_bin_uncertain': 203 delattr(hbu, field) 204 if len(hbu) > 0: 205 vlist_write(fidi, 'histogram_bin_uncertain', 'hbu', hbu) 206 #}}} -
issm/trunk-jpl/src/m/classes/qmu/linear_inequality_constraint.py
r24261 r25097 13 13 where the required args are: 14 14 matrix (double row, variable coefficients, float('NaN')) 15 lower (double vector, lower bounds, -np. Inf)15 lower (double vector, lower bounds, -np.inf) 16 16 upper (double vector, upper bounds, 0.) 17 17 and the optional args and defaults are: … … 25 25 def __init__(self): 26 26 self.matrix = np.array([[float('NaN')]]) 27 self.lower = -np. Inf27 self.lower = -np.inf 28 28 self.upper = 0. 29 29 self.scale_type = 'none' … … 131 131 lower[i] = lic[i].lower 132 132 133 lower = allequal(lower, -np. Inf)133 lower = allequal(lower, -np.inf) 134 134 135 135 return lower -
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.m
r25088 r25097 133 133 end 134 134 end % }}} 135 %default 135 function [lower]=prop_lower(nuv) % {{{ 136 lower=[]; 137 end % }}} 138 function [upper]=prop_upper(nuv) % {{{ 139 upper=[]; 140 end % }}} 136 141 function [abscissas]=prop_abscissas(hbu) % {{{ 137 142 abscissas=[]; … … 145 150 function [initpt]=prop_initpt(nuv) % {{{ 146 151 initpt=[]; 147 end % }}}148 function [lower]=prop_lower(nuv) % {{{149 lower=[];150 end % }}}151 function [upper]=prop_upper(nuv) % {{{152 upper=[];153 152 end % }}} 154 153 function [initst]=prop_initst(nuv) % {{{ -
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.py
r25090 r25097 41 41 def __init__(self): #{{{ 42 42 self.descriptor = '' 43 self.mean = np. NaN44 self.stddev = np. NaN43 self.mean = np.nan 44 self.stddev = np.nan 45 45 self.partition = [] 46 46 self.nsteps = 0 … … 176 176 #}}} 177 177 178 @staticmethod 179 def prop_lower(nuv): #{{{ 180 lower = [] 181 return lower 182 #}}} 183 184 @staticmethod 185 def prop_upper(nuv): #{{{ 186 upper = [] 187 return upper 188 #}}} 189 178 190 #default 179 191 @staticmethod … … 184 196 185 197 @staticmethod 198 def prop_pairs_per_variable(hbu): #{{{ 199 pairs_per_variable = [] 200 return pairs_per_variable 201 #}}} 202 203 @staticmethod 186 204 def prop_counts(hbu): #{{{ 187 205 counts = [] 188 206 return counts 189 207 #}}} 190 191 @staticmethod192 def prop_pairs_per_variable(hbu): #{{{193 pairs_per_variable = []194 return pairs_per_variable195 #}}}196 197 208 @staticmethod 198 209 def prop_initpt(nuv): #{{{ 199 210 initpt = [] 200 211 return initpt 201 #}}}202 203 @staticmethod204 def prop_lower(nuv): #{{{205 lower = []206 return lower207 #}}}208 209 @staticmethod210 def prop_upper(nuv): #{{{211 upper = []212 return upper213 212 #}}} 214 213 … … 244 243 from vlist_write import vlist_write 245 244 # collect only the variables of the appropriate class 246 # nuv = [struc_class(i, 'normal_uncertain', 'nuv') for i in dvar]247 245 nuv = deepcopy(dvar) 248 246 fields = fieldnames(nuv) -
issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.py
r25090 r25097 41 41 def __init__(self): #{{{ 42 42 self.descriptor = '' 43 self.lower = -np. Inf44 self.upper = np. Inf43 self.lower = -np.inf 44 self.upper = np.inf 45 45 self.partition = [] 46 46 self.nsteps = 0 … … 162 162 163 163 @staticmethod 164 def prop_stddev(uuv): #{{{ 165 stddev = [] 166 return stddev 167 #}}} 168 169 @staticmethod 170 def prop_mean(uuv): #{{{ 171 mean = [] 172 return mean 173 #}}} 174 175 @staticmethod 164 176 def prop_lower(uuv): #{{{ 165 177 lower = np.zeros(np.size(uuv)) … … 167 179 lower[i] = uuv[i].lower 168 180 169 lower = allequal(lower, -np. Inf)181 lower = allequal(lower, -np.inf) 170 182 171 183 return lower … … 178 190 upper[i] = uuv[i].upper 179 191 180 #upper = allequal(upper, np.Inf)192 upper = allequal(upper, np.inf) 181 193 182 194 return upper … … 184 196 185 197 @staticmethod 186 def prop_stddev(uuv): #{{{ 187 stddev = [] 188 return stddev 189 #}}} 190 191 @staticmethod 192 def prop_mean(uuv): #{{{ 193 mean = [] 194 return mean 198 def prop_abscissas(hbu): #{{{ 199 abscissas = [] 200 return abscissas 201 #}}} 202 203 @staticmethod 204 def prop_pairs_per_variable(hbu): #{{{ 205 pairs_per_variable = [] 206 return pairs_per_variable 207 #}}} 208 209 @staticmethod 210 def prop_counts(hbu): #{{{ 211 counts = [] 212 return counts 195 213 #}}} 196 214 … … 217 235 scale = [] 218 236 return scale 219 #}}}220 221 @staticmethod222 def prop_abscissas(hbu): #{{{223 abscissas = []224 return abscissas225 #}}}226 227 @staticmethod228 def prop_counts(hbu): #{{{229 counts = []230 return counts231 #}}}232 233 @staticmethod234 def prop_pairs_per_variable(hbu): #{{{235 pairs_per_variable = []236 return pairs_per_variable237 237 #}}} 238 238 … … 249 249 # possible namespace pollution, the above import seems not to work 250 250 from vlist_write import vlist_write 251 # # collect only the variables of the appropriate class 252 # uuv = [struc_class(i, 'uniform_uncertain', 'uuv') for i in dvar] 251 # collect only the variables of the appropriate class 253 252 uuv = deepcopy(dvar) 254 253 fields = fieldnames(uuv)
Note:
See TracChangeset
for help on using the changeset viewer.