Changeset 24819
- Timestamp:
- 05/07/20 22:44:24 (5 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.m
r24436 r24819 1 %NORMAL_UNCERTAIN class definition 1 2 % 2 % definition for the normal_uncertain class. 3 % 4 % [nuv]=normal_uncertain(varargin) 5 % 6 % where the required varargin are: 7 % descriptor (char, description, '') 8 % mean (double, mean, NaN) 9 % stddev (double, standard deviation, NaN) 10 % and the optional varargin and defaults are: 11 % lower (double, lower bound, -Inf) 12 % upper (double, upper bound, Inf) 13 % 14 % note that zero arguments constructs a default instance; one 15 % argument of the class copies the instance; and three or more 16 % arguments constructs a new instance from the arguments. 17 % 18 % "Copyright 2009, by the California Institute of Technology. 19 % ALL RIGHTS RESERVED. United States Government Sponsorship 20 % acknowledged. Any commercial use must be negotiated with 21 % the Office of Technology Transfer at the California Institute 22 % of Technology. (J. Schiermeier, NTR 47078) 23 % 24 % This software may be subject to U.S. export control laws. 25 % By accepting this software, the user agrees to comply with 26 % all applicable U.S. export laws and regulations. User has the 27 % responsibility to obtain export licenses, or other export 28 % authority as may be required before exporting such information 29 % to foreign countries or providing access to foreign persons." 30 % 3 % Usage: 4 % nuv=normal_uncertain('descriptor',descriptor,'mean',mean,'stddev',stddev,'partition',partition); 5 % where nuv is the normal_uncertain object returned by the constructor, mean and stddev are self 6 % explanatory. partition is the partition vector for distributed variables. Can be a partition 7 % vector over elements or vertices. 8 % 9 % Example: 10 % md.qmu.variables.rheology=normal_uncertain('descriptor','RheologyBBar','mean',1,'stddev',.05); 11 % md.qmu.variables.rheology=normal_uncertain('descriptor','scaled_RheologyBBar','mean',1,'stddev',.05,'partition',vpartition); 12 % 13 31 14 classdef normal_uncertain 32 15 properties … … 34 17 mean = NaN; 35 18 stddev = NaN; 36 lower =-Inf; 37 upper = Inf; 19 partition = []; 38 20 end 21 methods 22 function self=normal_uncertain(varargin) %constructor {{{ 39 23 40 methods 41 function [nuv]=normal_uncertain(varargin) 24 %recover options: 25 options = pairoptions(varargin{:}); 42 26 43 switch nargin 27 %initialize fields: 28 self.descriptor=getfieldvalue(options,'descriptor'); 29 self.mean=getfieldvalue(options,'mean'); 30 self.stddev=getfieldvalue(options,'stddev'); 44 31 45 % create a default object 46 47 case 0 48 49 % copy the object 50 51 case 1 52 if isa(varargin{1},'normal_uncertain') 53 nuv=varargin{1}; 54 else 55 error('Object ''%s'' is a ''%s'' class object, not ''%s''.',... 56 inputname(1),class(varargin{1}),'normal_uncertain'); 57 end 58 59 % not enough arguments 60 61 case 2 62 error('Construction of ''%s'' class object requires at least %d inputs.',... 63 'normal_uncertain',3) 64 65 % create the object from the input 66 67 otherwise 68 asizec=num2cell(array_size(varargin{1:min(nargin,5)})); 69 nuv(asizec{:})=normal_uncertain; 70 clear asizec 71 72 if ischar(varargin{1}) 73 varargin{1}=cellstr(varargin{1}); 74 end 75 for i=1:numel(nuv) 76 if (numel(varargin{1}) > 1) 77 nuv(i).descriptor=varargin{1}{i}; 78 else 79 if numel(nuv)==1, 80 nuv(i).descriptor=char(varargin{1}); 81 else 82 nuv(i).descriptor=[char(varargin{1}) num2str(i)]; 83 end 84 end 85 if (numel(varargin{2}) > 1) 86 nuv(i).mean =varargin{2}(i); 87 else 88 nuv(i).mean =varargin{2}; 89 end 90 if (numel(varargin{3}) > 1) 91 nuv(i).stddev =varargin{3}(i); 92 else 93 nuv(i).stddev =varargin{3}; 94 end 95 end 96 97 if (nargin >= 4) 98 for i=1:numel(nuv) 99 if (numel(varargin{4}) > 1) 100 nuv(i).lower =varargin{4}(i); 101 else 102 nuv(i).lower =varargin{4}; 103 end 104 end 105 if (nargin >= 5) 106 for i=1:numel(nuv) 107 if (numel(varargin{5}) > 1) 108 nuv(i).upper =varargin{5}(i); 109 else 110 nuv(i).upper =varargin{5}; 111 end 112 end 113 if (nargin > 5) 114 warning('normal_uncertain:extra_arg',... 115 'Extra arguments for object of class ''%s''.',... 116 class(nuv)); 117 end 118 end 119 end 120 end 121 122 end 123 124 function []=disp(nuv) 32 end %}}} 33 function []=disp(nuv) % {{{ 125 34 126 35 % display the object … … 133 42 disp(sprintf(' mean: %g' ,nuv(i).mean)); 134 43 disp(sprintf(' stddev: %g' ,nuv(i).stddev)); 135 disp(sprintf(' lower: %g' ,nuv(i).lower));136 disp(sprintf(' upper: %g\n' ,nuv(i).upper));137 44 end 138 45 139 end 140 141 function [desc] =prop_desc(nuv,dstr) 46 end 47 %}}} 48 function [desc] =prop_desc(nuv,dstr) % {{{ 142 49 desc=cell(1,numel(nuv)); 143 50 for i=1:numel(nuv) … … 153 60 end 154 61 desc=allempty(desc); 155 end 156 function [initpt]=prop_initpt(nuv) 157 initpt=[]; 158 end 159 function [lower] =prop_lower(nuv) 160 lower=zeros(1,numel(nuv)); 161 for i=1:numel(nuv) 162 lower(i)=nuv(i).lower; 163 end 164 lower=allequal(lower,-Inf); 165 end 166 function [upper] =prop_upper(nuv) 167 upper=zeros(1,numel(nuv)); 168 for i=1:numel(nuv) 169 upper(i)=nuv(i).upper; 170 end 171 upper=allequal(upper, Inf); 172 end 173 function [mean] =prop_mean(nuv) 62 end %}}} 63 function [mean] =prop_mean(nuv) % {{{ 174 64 mean=zeros(1,numel(nuv)); 175 65 for i=1:numel(nuv) 176 66 mean(i)=nuv(i).mean; 177 67 end 178 end 179 function [stddev]=prop_stddev(nuv) 68 end % }}} 69 function [stddev]=prop_stddev(nuv) % {{{ 180 70 stddev=zeros(1,numel(nuv)); 181 71 for i=1:numel(nuv) 182 72 stddev(i)=nuv(i).stddev; 183 73 end 184 end 185 function [initst]=prop_initst(nuv) 186 initst=[]; 187 end 188 function [stype] =prop_stype(nuv) 189 stype={}; 190 end 191 function [scale] =prop_scale(nuv) 192 scale=[]; 193 end 74 end % }}} 75 76 %virtual functions needed by qmu processing algorithms: 194 77 function [abscissas] =prop_abscissas(hbu) % {{{ 195 78 abscissas=[]; … … 201 84 pairs_per_variable=[]; 202 85 end % }}} 203 86 function [initpt]=prop_initpt(nuv) % {{{ 87 initpt=[]; 88 end % }}} 89 function [lower] =prop_lower(nuv) % {{{ 90 lower=[]; 91 end % }}} 92 function [upper] =prop_upper(nuv) % {{{ 93 upper=[]; 94 end % }}} 95 function [initst]=prop_initst(nuv) % {{{ 96 initst=[]; 97 end % }}} 98 function [stype] =prop_stype(nuv) % {{{ 99 stype={}; 100 end % }}} 101 function [scale] =prop_scale(nuv) % {{{ 102 scale=[]; 103 end % }}} 204 104 end 205 206 105 methods (Static) 207 function []=dakota_write(fidi,dvar) 208 209 % collect only the variables of the appropriate class 210 211 nuv=struc_class(dvar,'normal_uncertain'); 212 213 % write variables 214 106 function []=dakota_write(fidi,dvar) % {{{ 107 % collect only the variables of the appropriate class 108 nuv=struc_class(dvar,'normal_uncertain'); 109 % write variables 215 110 vlist_write(fidi,'normal_uncertain','nuv',nuv); 216 end 111 end % }}} 217 112 end 218 113 end -
issm/trunk-jpl/test/NightlyRun/test2085.m
r23017 r24819 36 36 %loading love numbers 37 37 field_names = {'LoveH_loading_elastic','LoveK_loading_elastic','LoveL_loading_elastic','LoveKernels_degree1','LoveKernels_degree2'}; 38 field_tolerances={1e-10,1e-10,1e-10, 1e-10,1e-10};38 field_tolerances={1e-10,1e-10,1e-10,4e-10,1e-10}; 39 39 field_values={... 40 40 (md.results.LoveSolution.LoveHr(:,1)),... -
issm/trunk-jpl/test/NightlyRun/test218.m
r24174 r24819 60 60 61 61 %variables 62 md.qmu.variables.rheology_B=normal_uncertain(' scaled_MaterialsRheologyB',1,.05);62 md.qmu.variables.rheology_B=normal_uncertain('descriptor','scaled_MaterialsRheologyB','mean',1,'stddev',.05); 63 63 64 64 %responses -
issm/trunk-jpl/test/NightlyRun/test234.m
r24174 r24819 27 27 28 28 %variables 29 md.qmu.variables.surface_mass_balance=normal_uncertain(' scaled_SmbMassBalance',1,0.1);29 md.qmu.variables.surface_mass_balance=normal_uncertain('descriptor','scaled_SmbMassBalance','mean',1,'stddev',.1); 30 30 31 31 %responses -
issm/trunk-jpl/test/NightlyRun/test235.m
r24174 r24819 27 27 28 28 %variables 29 md.qmu.variables.surface_mass_balance=normal_uncertain(' scaled_SmbMassBalance',1,100);29 md.qmu.variables.surface_mass_balance=normal_uncertain('descriptor','scaled_SmbMassBalance','mean',1,'stddev',100); 30 30 31 31 %responses -
issm/trunk-jpl/test/NightlyRun/test244.m
r24174 r24819 51 51 52 52 %variables 53 md.qmu.variables.surface_mass_balanceC=normal_uncertain('scaled_SmbC',1,0.5); 53 md.qmu.variables.surface_mass_balanceC=normal_uncertain('descriptor','scaled_SmbC','mean',1,'stddev',.5); 54 54 55 Tmin=273; 55 56 telms=min(md.smb.Ta(1:end-1,:),[],2); -
issm/trunk-jpl/test/NightlyRun/test250.m
r24174 r24819 27 27 28 28 %variables 29 md.qmu.variables.surface_mass_balance=normal_uncertain(' scaled_SmbMassBalance',1,0.1);29 md.qmu.variables.surface_mass_balance=normal_uncertain('descriptor','scaled_SmbMassBalance','mean',1,'stddev',.1); 30 30 31 31 %responses -
issm/trunk-jpl/test/NightlyRun/test251.m
r24174 r24819 27 27 28 28 %variables 29 md.qmu.variables.surface_mass_balance=normal_uncertain(' scaled_SmbMassBalance',1,100);29 md.qmu.variables.surface_mass_balance=normal_uncertain('descriptor','scaled_SmbMassBalance','mean',1,'stddev',100); 30 30 31 31 %responses -
issm/trunk-jpl/test/NightlyRun/test412.m
r24174 r24819 19 19 20 20 %variables 21 md.qmu.variables.rho_ice=normal_uncertain('MaterialsRhoIce',md.materials.rho_ice,0.01); 22 md.qmu.variables.drag_coefficient=normal_uncertain('scaled_FrictionCoefficient',1,0.01); 21 md.qmu.variables.rho_ice=normal_uncertain('descriptor','MaterialsRhoIce','mean',1,'stddev',.01); 22 md.qmu.variables.drag_coefficient=normal_uncertain('descriptor','scaled_FrictionCoefficient','mean',1,'stddev',.01); 23 23 24 24 25 %responses -
issm/trunk-jpl/test/NightlyRun/test413.m
r24174 r24819 17 17 18 18 %variables 19 md.qmu.variables.rho_ice=normal_uncertain('MaterialsRhoIce',md.materials.rho_ice,0.01); 20 md.qmu.variables.drag_coefficient=normal_uncertain('scaled_FrictionCoefficient',1,0.01); 19 md.qmu.variables.rho_ice=normal_uncertain('descriptor','MaterialsRhoIce','mean',1,'stddev',.01); 20 md.qmu.variables.drag_coefficient=normal_uncertain('descriptor','scaled_FrictionCoefficient','mean',1,'stddev',.01); 21 21 22 22 23 %responses -
issm/trunk-jpl/test/NightlyRun/test414.m
r24174 r24819 25 25 26 26 %variables 27 md.qmu.variables.drag_coefficient=normal_uncertain(' scaled_FrictionCoefficient',1,0.01);27 md.qmu.variables.drag_coefficient=normal_uncertain('descriptor','scaled_FrictionCoefficient','mean',1,'stddev',.01); 28 28 29 29 %responses -
issm/trunk-jpl/test/NightlyRun/test417.m
r24174 r24819 19 19 version=IssmConfig('_DAKOTA_VERSION_'); version=version(1:3); version=str2num(version); 20 20 21 md.qmu.variables.drag_coefficient=normal_uncertain(' scaled_FrictionCoefficient',1,0.01);21 md.qmu.variables.drag_coefficient=normal_uncertain('descriptor','scaled_FrictionCoefficient','mean',1,'stddev',.01); 22 22 23 23 md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]); -
issm/trunk-jpl/test/NightlyRun/test420.m
r24174 r24819 18 18 19 19 %variables 20 md.qmu.variables.rho_ice=normal_uncertain(' MaterialsRhoIce',md.materials.rho_ice,0.01);20 md.qmu.variables.rho_ice=normal_uncertain('descriptor','MaterialsRhoIce','mean',1,'stddev',.01); 21 21 22 22 %responses -
issm/trunk-jpl/test/NightlyRun/test440.m
r24174 r24819 18 18 19 19 %variables 20 md.qmu.variables.rho_ice=normal_uncertain(' MaterialsRhoIce',md.materials.rho_ice,0.01);20 md.qmu.variables.rho_ice=normal_uncertain('descriptor','MaterialsRhoIce','mean',1,'stddev',.01); 21 21 22 22 %responses -
issm/trunk-jpl/test/NightlyRun/test444.m
r24174 r24819 49 49 version=IssmConfig('_DAKOTA_VERSION_'); version=version(1:3); version=str2num(version); 50 50 51 md.qmu.variables.drag_coefficient=normal_uncertain(' scaled_BasalforcingsFloatingiceMeltingRate',1,0.1);51 md.qmu.variables.drag_coefficient=normal_uncertain('descriptor','scaled_BasalforcingsFloatingiceMeltingRate','mean',1,'stddev',.1); 52 52 53 53 md.qmu.responses.IceMass1=response_function('Outputdefinition5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]); -
issm/trunk-jpl/test/NightlyRun/test445.m
r24174 r24819 19 19 20 20 %variables 21 md.qmu.variables.neff=normal_uncertain(' scaled_FrictionEffectivePressure',1,.05);22 md.qmu.variables. geoflux=normal_uncertain('scaled_BasalforcingsGeothermalflux',1,.05);21 md.qmu.variables.neff=normal_uncertain('descriptor','scaled_FrictionEffectivePressure','mean',1,'stddev',.05); 22 md.qmu.variables.neff=normal_uncertain('descriptor','scaled_BasalforcingsGeothermalflux','mean',1,'stddev',.05); 23 23 24 24 %responses
Note:
See TracChangeset
for help on using the changeset viewer.