Changeset 25028
- Timestamp:
- 06/12/20 09:29:22 (5 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.m
r25025 r25028 31 31 self.stddev=getfieldvalue(options,'stddev'); 32 32 33 %if the variable is scaled, a partition vector should have been supplied, and34 % that partition vector should have as many partitions as the mean and stddev35 % vectors:33 %if the variable is scaled, a partition vector should have been 34 %supplied, and that partition vector should have as many partitions 35 %as the mean and stddev vectors: 36 36 if self.isscaled(), 37 37 self.partition=getfieldvalue(options,'partition'); -
issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.m
r25025 r25028 32 32 33 33 %if the variable is scaled, a partition vector should have been 34 %supplied, and that partition vector should have as many35 % partitionsas the lower and upper vectors:34 %supplied, and that partition vector should have as many partitions 35 %as the lower and upper vectors: 36 36 if self.isscaled(), 37 37 self.partition=getfieldvalue(options,'partition'); … … 80 80 error('uniform_uncertain error message: row size of lower and partition size should be identical'); 81 81 end 82 %we need as steps in stddev and meanas there are time steps:82 %we need as steps in upper and lower as there are time steps: 83 83 if size(self.upper,2)~=self.nsteps, 84 84 error('uniform_uncertain error message: col size of upper and number of time steps should be identical'); -
issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.py
r24873 r25028 6 6 from pairoptions import pairoptions 7 7 from partition_npart import * 8 from qmupart2npart import qmupart2npart 8 9 9 10 … … 43 44 self.upper = np.Inf 44 45 self.partition = [] 46 self.nsteps = 0 45 47 46 48 @staticmethod … … 67 69 68 70 #initialize fields: 69 uuv.descriptor = options.getfieldvalue('descriptor' , '')70 uuv.lower = options.getfieldvalue('lower' , -np.Inf)71 uuv.upper = options.getfieldvalue('upper' , np.Inf)71 uuv.descriptor = options.getfieldvalue('descriptor') 72 uuv.lower = options.getfieldvalue('lower') 73 uuv.upper = options.getfieldvalue('upper') 72 74 73 75 #if the variable is scaled, a partition vector should have been … … 76 78 if uuv.isscaled(): 77 79 uuv.partition = options.getfieldvalue('partition') 78 npart = partition_npart(uuv.partition) 79 if npart != len(uuv.upper): 80 nuv.nsteps = options.getfieldvalue('nsteps', 1) 81 npart = qmupart2npart(uuv.partition) 82 if npart != nuv.upper.shape[0]: 80 83 raise RuntimeError("uniform_uncertain constructor: for the scaled variable %s the upper field is not currently a vector of values for all the partitions described in the partition vector" % uuv.descriptor) 81 if npart != len(uuv.lower):84 if npart != nuv.lower.shape[0]: 82 85 raise RuntimeError("uniform_uncertain constructor: for the scaled variable %s the lower field is not currently a vector of values for all the partitions described in the partition vector" % uuv.descriptor) 86 if nuv.nsteps != nuv.upper.shape[1]: 87 raise RuntimeError("uniform_uncertain constructor: for the scaled variable %s the col size of the upper field should be identical to the number of time steps" % nuv.descriptor) 88 if nuv.nsteps != nuv.lower.shape[1]: 89 raise RuntimeError("uniform_uncertain constructor: for the scaled variable %s the col size of the lower field should be identical to the number of time steps" % nuv.descriptor) 83 90 84 91 return [uuv] # Always return a list, so we have something akin to a MATLAB single row matrix … … 91 98 if self.partition != []: 92 99 string = "%s\n%s" % (string, fielddisplay(self, 'partition', 'partition vector defining where sampling will occur')) 100 string = "%s\n%s" % (string, fielddisplay(self, 'nsteps', 'number of time steps')) 101 93 102 return string 94 103 #}}} … … 107 116 if self.partition == []: 108 117 raise RuntimeError("uniform_uncertain is a scaled variable, but it's missing a partition vector") 109 #better have a partition vector that has as many partitions as upper and lower's size: 110 if len(self.upper) != partition_npart(self.partititon): 111 raise RuntimeError("uniform_uncertain error message: upper and partition should be vectors of identical size") 112 if len(self.lower) != partition_npart(self.partition): 113 raise RuntimeError("uniform_uncertain error message: lower and partition should be vectors of identical size") 118 #better have a partition vector that has as many partitions as 119 #upper and lower's size: 120 if self.upper.shape[0] != partition_npart(self.partititon): 121 raise RuntimeError("uniform_uncertain error message: row size of upper and partition size should be identical") 122 if self.lower.shape[0] != partition_npart(self.partition): 123 raise RuntimeError("uniform_uncertain error message: row size of lower and partition size should be identical") 124 #we need as steps in upper and lower as there are time steps 125 if self.stddev.shape[1] != self.nsteps: 126 raise RuntimeError("uniform_uncertain error message: col size of upper and partition size should be identical") 127 if self.mean.shape[1] != self.nsteps: 128 raise RuntimeError("uniform_uncertain error message: col size of lower and partition size should be identical") 114 129 md = checkfield(md, 'field', self.partition, 'fieldname', 'uniform_uncertain.partition', 'NaN', 1, 'Inf', 1, '>=', -1, 'numel', [md.mesh.numberofvertices, md.mesh.numberofvertices]) 115 130 if self.partition.shape[1] > 1: -
issm/trunk-jpl/src/m/qmu/setupdesign/QmuSetupVariables.m
r25025 r25028 24 24 nlower=length(variables.lower,2); 25 25 nupper=length(variables.upper,2); 26 if (n stddev ~= nt || nmean ~=nt),26 if (nlower ~= nt || nupper ~= nt), 27 27 error('QmuSetupVariables error message: upper and lower fields should have the same number of cols as the number of time steps'); 28 28 end -
issm/trunk-jpl/src/m/qmu/setupdesign/QmuSetupVariables.py
r25022 r25028 26 26 27 27 if isinstance(variables, uniform_uncertain): 28 nlower = len(variables.lower)29 nupper = len(variables.upper)28 nlower = variables.lower.shape[0] 29 nupper = variables.upper.shape[0] 30 30 if nlower != npart or nupper != npart: 31 raise RuntimeError('QmuSetupVariables error message: upper and lower fields should be same size as the number of partitions') 31 raise RuntimeError('QmuSetupVariables error message: upper and lower fields should have the same number of rows as the number of partitions') 32 nlower = variables.lower.shape[1] 33 nupper = variables.upper.shape[1] 34 if nlower != npart or nupper != npart: 35 raise RuntimeError('QmuSetupVariables error message: upper and lower fields should have the same number of cols as the number of time steps') 32 36 elif isinstance(variables, normal_uncertain): 33 37 nstddev = variables.stddev.shape[0] … … 38 42 nmean = variables.mean.shape[1] 39 43 if nstddev != nt or nmean != nt: 40 raise RuntimeError('QmuSetupVariables error message: stddev and mean fields should have the same number of cols as the number of partitions')44 raise RuntimeError('QmuSetupVariables error message: stddev and mean fields should have the same number of cols as the number of time steps') 41 45 42 46 #ok, dealing with semi-discrete distributed variable. Distribute according to how many
Note:
See TracChangeset
for help on using the changeset viewer.