Changeset 24870


Ignore:
Timestamp:
05/17/20 17:15:00 (5 years ago)
Author:
jdquinn
Message:

CHG: Translated MATLAB changes to Python that allow for distributing variable over partition.

Location:
issm/trunk-jpl
Files:
1 added
35 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.m

    r24847 r24870  
    1313
    1414classdef normal_uncertain
    15     properties
    16         descriptor='';
    17         mean      = NaN;
    18         stddev    = NaN;
    19                 partition = [];
    20     end
    21     methods
     15        properties
     16                descriptor      = '';
     17                mean            = NaN;
     18                stddev          = NaN;
     19                partition       = [];
     20        end
     21        methods
    2222                function self=normal_uncertain(varargin) %constructor {{{
    2323
     
    4646
    4747                end %}}}
    48         function disp(self) % {{{
    49 
    50                 disp(sprintf('   normal uncertain variable: '));
    51                 fielddisplay(self,'descriptor','name tag');
    52                 fielddisplay(self,'mean','pdf mean');
    53                 fielddisplay(self,'stddev','pdf standard deviation');
    54                 if ~isempty(self.partition),
    55                         fielddisplay(self,'partition','partition vector defining where sampling will occur');
    56                 end
    57         end
    58         %}}}
    59         function md=checkconsistency(self,md,solution,analyses) % {{{
    60 
    61                 md = checkfield(md,'field',self.mean,'fieldname','normal_uncertain.mean','NaN',1,'Inf',1,'>=',0);
    62                 md = checkfield(md,'field',self.stddev,'fieldname','normal_uncertain.stddev','NaN',1,'Inf',1,'>=',0,'numel',length(self.mean));
    63                 if self.isscaled(),
    64                         if isempty(self.partition),
    65                                 error('normal_uncertain is a scaled variable, but it''s missing a partition vector');
    66                         end
    67                         %better have a partition vector that has as many partitions as stddev's size:
    68                         if length(self.stddev)~=partition_npart(self.partition),
    69                                 error('normal_uncertain error message: stddev and partition should be vectors of identical size');
    70                         end
    71                         if length(self.mean)~=partition_npart(self.partition),
    72                                 error('normal_uncertain error message: mean and partition should be vectors of identical size');
    73                         end
    74 
    75                         md = checkfield(md,'field',self.partition,'fieldname','normal_uncertain.partition','NaN',1,'Inf',1,'>=',-1,'numel',[md.mesh.numberofvertices,md.mesh.numberofelements]);
    76                         if size(self.partition,2)>1,
    77                                 error('normal_uncertain error message: partition should be a column vector');
    78                         end
    79                         partcheck=unique(self.partition);
    80                         partmin=min(partcheck);
    81                         partmax=max(partcheck);
    82                         if partmax<-1,
    83                                 error('normal_uncertain error message: partition vector''s min value should be -1 (for no partition), or start at 0');
    84                         end
    85                         nmax=max(md.mesh.numberofelements,md.mesh.numberofvertices);
    86                         if partmax>nmax,
    87                                 error('normal_uncertain error message: partition vector''s values cannot go over the number of vertices or elements');
     48                function disp(self) % {{{
     49                        disp(sprintf('   normal uncertain variable: '));
     50                        fielddisplay(self,'descriptor','name tag');
     51                        fielddisplay(self,'mean','pdf mean');
     52                        fielddisplay(self,'stddev','pdf standard deviation');
     53                        if ~isempty(self.partition),
     54                                fielddisplay(self,'partition','partition vector defining where sampling will occur');
    8855                        end
    8956                end
    90         end % }}}
    91         %virtual functions needed by qmu processing algorithms:
    92         %implemented:
    93         function [desc]  =prop_desc(nuv,dstr) % {{{
    94                 desc=cell(1,numel(nuv));
    95                 for i=1:numel(nuv)
    96                         if ~isempty(nuv(i).descriptor)
    97                                 desc(i)=cellstr(nuv(i).descriptor);
    98                         elseif ~isempty(inputname(1))
    99                                 desc(i)=cellstr([inputname(1) string_dim(nuv,i,'vector')]);
    100                         elseif exist('dstr','var')
    101                                 desc(i)=cellstr([dstr         string_dim(nuv,i,'vector')]);
     57                %}}}
     58                function md=checkconsistency(self,md,solution,analyses) % {{{
     59
     60                        md = checkfield(md,'field',self.mean,'fieldname','normal_uncertain.mean','NaN',1,'Inf',1,'>=',0);
     61                        md = checkfield(md,'field',self.stddev,'fieldname','normal_uncertain.stddev','NaN',1,'Inf',1,'>=',0,'numel',length(self.mean));
     62                        if self.isscaled(),
     63                                if isempty(self.partition),
     64                                        error('normal_uncertain is a scaled variable, but it''s missing a partition vector');
     65                                end
     66                                %better have a partition vector that has as many partitions as stddev's size:
     67                                if length(self.stddev)~=partition_npart(self.partition),
     68                                        error('normal_uncertain error message: stddev and partition should be vectors of identical size');
     69                                end
     70                                if length(self.mean)~=partition_npart(self.partition),
     71                                        error('normal_uncertain error message: mean and partition should be vectors of identical size');
     72                                end
     73
     74                                md = checkfield(md,'field',self.partition,'fieldname','normal_uncertain.partition','NaN',1,'Inf',1,'>=',-1,'numel',[md.mesh.numberofvertices,md.mesh.numberofelements]);
     75                                if size(self.partition,2)>1,
     76                                        error('normal_uncertain error message: partition should be a column vector');
     77                                end
     78                                partcheck=unique(self.partition);
     79                                partmin=min(partcheck);
     80                                partmax=max(partcheck);
     81                                if partmax<-1,
     82                                        error('normal_uncertain error message: partition vector''s min value should be -1 (for no partition), or start at 0');
     83                                end
     84                                nmax=max(md.mesh.numberofelements,md.mesh.numberofvertices);
     85                                if partmax>nmax,
     86                                        error('normal_uncertain error message: partition vector''s values cannot go over the number of vertices or elements');
     87                                end
     88                        end
     89                end % }}}
     90                %virtual functions needed by qmu processing algorithms:
     91                %implemented:
     92                function [desc]  =prop_desc(nuv,dstr) % {{{
     93                        desc=cell(1,numel(nuv));
     94                        for i=1:numel(nuv)
     95                                if ~isempty(nuv(i).descriptor)
     96                                        desc(i)=cellstr(nuv(i).descriptor);
     97                                elseif ~isempty(inputname(1))
     98                                        desc(i)=cellstr([inputname(1) string_dim(nuv,i,'vector')]);
     99                                elseif exist('dstr','var')
     100                                        desc(i)=cellstr([dstr         string_dim(nuv,i,'vector')]);
     101                                else
     102                                        desc(i)=cellstr(['nuv'        string_dim(nuv,i,'vector')]);
     103                                end
     104                        end
     105                        desc=allempty(desc);
     106                end %}}}
     107                function [mean]  =prop_mean(nuv) % {{{
     108                        mean=zeros(1,numel(nuv));
     109                        for i=1:numel(nuv)
     110                                mean(i)=nuv(i).mean;
     111                        end
     112                end % }}}
     113                function [stddev]=prop_stddev(nuv) % {{{
     114                        stddev=zeros(1,numel(nuv));
     115                        for i=1:numel(nuv)
     116                                stddev(i)=nuv(i).stddev;
     117                        end
     118                end % }}}
     119                %default
     120                function [abscissas] =prop_abscissas(hbu) % {{{
     121                        abscissas=[];
     122                end % }}}
     123                function [counts] =prop_counts(hbu) % {{{
     124                        counts=[];
     125                end % }}}
     126                function [pairs_per_variable] =prop_pairs_per_variable(hbu) % {{{
     127                        pairs_per_variable=[];
     128                end % }}}
     129                function [initpt]=prop_initpt(nuv) % {{{
     130                        initpt=[];
     131                end % }}}
     132                function [lower]  =prop_lower(nuv) % {{{
     133                        lower=[];
     134                end % }}}
     135                function [upper]  =prop_upper(nuv) % {{{
     136                        upper=[];
     137                end % }}}
     138                function [initst]=prop_initst(nuv) % {{{
     139                        initst=[];
     140                end % }}}
     141                function [stype] =prop_stype(nuv) % {{{
     142                        stype={};
     143                end % }}}
     144                function [scale] =prop_scale(nuv) % {{{
     145                        scale=[];
     146                end % }}}
     147                %new methods:
     148                function scaled =isscaled(self) % {{{
     149                        if strncmp(self.descriptor,'scaled_',7),
     150                                scaled=1;
    102151                        else
    103                                 desc(i)=cellstr(['nuv'        string_dim(nuv,i,'vector')]);
     152                                scaled=0;
    104153                        end
    105                 end
    106                 desc=allempty(desc);
    107         end %}}}
    108         function [mean]  =prop_mean(nuv) % {{{
    109                 mean=zeros(1,numel(nuv));
    110                 for i=1:numel(nuv)
    111                         mean(i)=nuv(i).mean;
    112                 end
    113         end % }}}
    114         function [stddev]=prop_stddev(nuv) % {{{
    115                 stddev=zeros(1,numel(nuv));
    116                 for i=1:numel(nuv)
    117                         stddev(i)=nuv(i).stddev;
    118                 end
    119         end % }}}
    120         %default
    121         function [abscissas] =prop_abscissas(hbu) % {{{
    122                 abscissas=[];
    123         end % }}}
    124         function [counts] =prop_counts(hbu) % {{{
    125                 counts=[];
    126         end % }}}
    127         function [pairs_per_variable] =prop_pairs_per_variable(hbu) % {{{
    128                 pairs_per_variable=[];
    129         end % }}}
    130         function [initpt]=prop_initpt(nuv) % {{{
    131                 initpt=[];
    132         end % }}}
    133         function [lower]  =prop_lower(nuv) % {{{
    134                 lower=[];
    135         end % }}}
    136         function [upper]  =prop_upper(nuv) % {{{
    137                 upper=[];
    138         end % }}}
    139         function [initst]=prop_initst(nuv) % {{{
    140                 initst=[];
    141         end % }}}
    142         function [stype] =prop_stype(nuv) % {{{
    143                 stype={};
    144         end % }}}
    145         function [scale] =prop_scale(nuv) % {{{
    146                 scale=[];
    147         end % }}}
    148         %new methods:
    149         function scaled =isscaled(self) % {{{
    150                 if strncmp(self.descriptor,'scaled_',7),
    151                         scaled=1;
    152                 else
    153                         scaled=0;
    154                 end
    155         end % }}}
     154                end % }}}
    156155        end
    157     methods (Static)
    158         function []=dakota_write(fidi,dvar) % {{{
     156        methods (Static)
     157                function []=dakota_write(fidi,dvar) % {{{
    159158                        %  collect only the variables of the appropriate class
    160159                        nuv=struc_class(dvar,'normal_uncertain');
    161160                        %  write variables
    162             vlist_write(fidi,'normal_uncertain','nuv',nuv);
    163         end % }}}
    164     end
     161                        vlist_write(fidi,'normal_uncertain','nuv',nuv);
     162                end % }}}
     163        end
    165164end
  • issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.py

    r24849 r24870  
    11import numpy as np
     2
    23from MatlabArray import *
     4from MatlabFuncs import *
     5from fielddisplay import fielddisplay
     6from pairoptions import pairoptions
     7from partition_npart import *
    38
    49
    510class normal_uncertain(object):
    611    '''
    7   definition for the normal_uncertain class.
    8 
    9   [nuv] = normal_uncertain.normal_uncertain(args)
    10    nuv = normal_uncertain()
    11 
    12   where the required args are:
    13     descriptor    (str, description, '')
    14     mean          (float, mean, float('NaN'))
    15     stddev        (float, standard deviation, float('NaN'))
    16   and the optional args and defaults are:
    17     lower         (float, lower bound, -np.Inf)
    18     upper         (float, upper bound, np.Inf)
    19 
    20   note that zero arguments constructs a default instance, one
    21   argument of the class copies the instance, and three or more
    22   arguments constructs a new instance from the arguments.
    23 '''
     12    NORMAL_UNCERTAIN class definition
     13
     14        Usage:
     15            nuv = normal_uncertain('descriptor',descriptor,'mean',mean,'stddev',stddev,'partition',partition)
     16            where nuv is the normal_uncertain object returned by the constructor, mean and stddev are self
     17            explanatory.  partition is the partition vector for distributed variables. Can be a partition
     18            vector over elements or vertices.
     19
     20        Example:
     21            md.qmu.variables.rheology=normal_uncertain(
     22                'descriptor','RheologyBBar',
     23                'mean',1,
     24                'stddev',.05
     25                )
     26            md.qmu.variables.rheology=normal_uncertain(
     27                'descriptor','scaled_RheologyBBar',
     28                'mean',1,
     29                'stddev',.05,
     30                'partition',vpartition
     31                )
     32    '''
    2433    def __init__(self):
    2534        self.descriptor = ''
    26         self.mean = float('NaN')
    27         self.stddev = float('NaN')
    28         self.lower = -np.Inf
    29         self.upper = np.Inf
    30 
    31     @staticmethod
    32     def normal_uncertain(*args):
     35        self.mean       = np.NaN
     36        self.stddev     = np.NaN
     37        self.partition  = []
     38
     39    @staticmethod
     40    def normal_uncertain(*args): #{{{
    3341        nargin = len(args)
    3442
     
    4452                raise RuntimeError('Object ' + str(args[0]) + ' is a ' + str(type(args[0])) + ' class object, not "normal_uncertain".')
    4553
    46         # not enough arguments
    47         elif nargin == 2:
    48             raise RuntimeError('Construction of "normal_uncertain" class object requires at least 3 inputs.')
    49 
    50     # create the object from the input
     54        # create the object from the input
    5155        else:
    5256            # lines differ here in other classes / tests; see asizec problem in notes
    5357            nuv = normal_uncertain()
    54             nuv.descriptor = str(args[0])
    55             nuv.mean = args[1]
    56             nuv.stddev = args[2]
    57             if nargin >= 4:
    58                 nuv.lower = args[3]
    59             if nargin >= 5:
    60                 nuv.upper = args[4]
    61             if nargin > 5:
    62                 print('WARNING: normal_uncertain:extra_arg: Extra arguments for object of class ' + str(type(nuv)) + '.')
    63 
    64         return [nuv]
    65 
    66     def __repr__(self):
    67         # display an individual object
    68         string = '\n'
    69         string += 'class "normal_uncertain" object = \n'
    70         string += '    descriptor: ' + str(self.descriptor) + '\n'
    71         string += '          mean: ' + str(self.mean) + '\n'
    72         string += '        stddev: ' + str(self.stddev) + '\n'
    73         string += '         lower: ' + str(self.lower) + '\n'
    74         string += '         upper: ' + str(self.upper) + '\n'
     58
     59            #recover options:
     60            options = pairoptions(*args)
     61
     62            #initialize fields:
     63            nuv.descriptor = options.getfieldvalue('descriptor', '')
     64            nuv.mean       = options.getfieldvalue('mean', np.NaN)
     65            nuv.stddev     = options.getfieldvalue('stddev', np.NaN)
     66
     67            #if the variable is scaled, a partition vector should have been supplied, and
     68            #that partition vector should have as many partitions as the mean and stddev
     69            #vectors:
     70            if nuv.isscaled():
     71                nuv.partition = options.getfieldvalue('partition')
     72                npart = partition_npart(nuv.partition)
     73                if npart != len(nuv.mean):
     74                    error("normal_uncertain constructor: for the scaled variable %s the mean field is not currently a vector of values for all the partitions described in the partition vector" % nuv.descriptor)
     75                if npart != len(nuv.stddev):
     76                    error("normal_uncertain constructor: for the scaled variable %s the stddev field is not cureently a vector of values for all the partitions described in the partition vector" % nuv.descriptor)
     77
     78        return [nuv] # Always return a list, so we have something akin to a MATLAB single row matrix
     79    #}}}
     80
     81    def __repr__(self): #{{{
     82        string = '   normal uncertain variable: '
     83        string = "%s\n%s" % (string, fielddisplay(self, 'descriptor', 'name tag'))
     84        string = "%s\n%s" % (string, fielddisplay(self, 'mean', 'pdf mean'))
     85        string = "%s\n%s" % (string, fielddisplay(self, 'stddev', 'pdf standard deviation'))
     86        if self.partition != []:
     87            string = "%s\n%s" % (string, fielddisplay(self, 'partition', 'partition vector defining where sampling will occur'))
    7588
    7689        return string
    77 
    78     # from here on, nuv is either a single, or a 1d vector of, normal_uncertain
    79 
    80     @staticmethod
    81     def prop_desc(nuv, dstr):
    82         if type(nuv) not in [list, np.ndarray]:
    83             if nuv.descriptor != '' or type(nuv.descriptor) != str:
    84                 desc = str(nuv.descriptor)
    85             elif dstr != '':
    86                 desc = str(dstr)
    87             else:
    88                 desc = 'nuv'
    89             return desc
    90 
     90    #}}}
     91
     92    def __len__(self): #{{{
     93        if type(self.mean) in [list, np.ndarray]:
     94            return len(self.mean)
     95        else:
     96            return 1
     97    #}}}
     98
     99    def checkconsistency(self, md, solution, analyses): #{{{
     100        md = checkfield(md, 'field', self.mean, 'fieldname', 'normal_uncertain.mean', 'NaN', 1, 'Inf', 1, '>=', 0)
     101        md = checkfield(md, 'field', self.stddev, 'fieldname', 'normal_uncertain.stddev', 'NaN', 1, 'Inf', 1, '>=', 0, 'numel', len(self.mean))
     102        if self.isscaled():
     103            if self.partition == []:
     104                error("normal_uncertain is a scaled variable, but it's missing a partition vector")
     105            #better have a partition vector that has as many partitions as stddev's size:
     106            if len(self.stddev) != partition_npart(self.partititon):
     107                error("normal_uncertain error message: stddev and partition should be vectors of identical size")
     108            if len(self.mean) != partition_npart(self.partition):
     109                error("normal_uncertain error message: mean and partition should be vectors of identical size")
     110            md = checkfield(md, 'field', self.partition, 'fieldname', 'normal_uncertain.partition', 'NaN', 1, 'Inf', 1, '>=', -1, 'numel', [md.mesh.numberofvertices, md.mesh.numberofvertices])
     111            if self.partition.shape[1] > 1:
     112                error("normal_uncertain error message: partition should be a column vector")
     113            partcheck = np.unique(self.partition)
     114            partmin = min(partcheck)
     115            partmax = max(partcheck)
     116            if partmax < -1:
     117                error("normal_uncertain error message: partition vector's min value should be -1 (for no partition), or start at 0")
     118            nmax = max(md.mesh.numberofelements, md.mesh.numberofvertices)
     119            if partmax > nmax:
     120                error("normal_uncertain error message: partition vector's values cannot go over the number of vertices or elements")
     121    #}}}
     122
     123    #virtual functions needed by qmu processing algorithms
     124    #implemented:
     125
     126    @staticmethod
     127    def prop_desc(nuv, dstr): #{{{
    91128        desc = ['' for i in range(np.size(nuv))]
    92129        for i in range(np.size(nuv)):
     
    101138
    102139        return desc
    103 
    104     @staticmethod
    105     def prop_initpt(nuv):
    106         initpt = []
    107         return initpt
    108 
    109     @staticmethod
    110     def prop_lower(nuv):
     140    #}}}
     141
     142    @staticmethod
     143    def prop_mean(nuv): #{{{
    111144        if type(nuv) not in [list, np.ndarray]:
    112             return nuv.lower
    113 
    114         lower = np.zeros(np.size(nuv))
    115         for i in range(np.size(nuv)):
    116             lower[i] = nuv[i].lower
    117 
    118         lower = allequal(lower, -np.inf)
    119 
    120         return lower
    121 
    122     @staticmethod
    123     def prop_upper(nuv):
    124         if type(nuv) not in [list, np.ndarray]:
    125             return nuv.upper
    126 
    127         upper = np.zeros(np.size(nuv))
    128         for i in range(np.size(nuv)):
    129             upper[i] = nuv[i].upper
    130 
    131         upper = allequal(upper, -np.inf)
    132         return upper
    133 
    134     @staticmethod
    135     def prop_mean(nuv):
    136         if type(nuv) not in [list, np.ndarray]:
    137             return nuv.mean
     145            return [nuv.mean]
    138146
    139147        mean = np.zeros(np.size(nuv))
    140148        for i in range(np.size(nuv)):
    141149            mean[i] = nuv[i].mean
    142 
    143150        return mean
    144 
    145     @staticmethod
    146     def prop_stddev(nuv):
     151    #}}}
     152
     153    @staticmethod
     154    def prop_stddev(nuv): #{{{
    147155        if type(nuv) not in [list, np.ndarray]:
    148             return nuv.stddev
    149 
     156            return [nuv.stddev]
    150157        stddev = np.zeros(np.size(nuv))
    151158        for i in range(np.size(nuv)):
    152159            stddev[i] = nuv[i].stddev
    153 
    154160        return stddev
    155 
    156     @staticmethod
    157     def prop_initst(nuv):
    158         initst = []
    159         return initst
    160 
    161     @staticmethod
    162     def prop_stype(nuv):
     161    #}}}
     162
     163    #default
     164    @staticmethod
     165    def prop_abscissas(hbu): #{{{
     166        abscissas = []
     167        return abscissas
     168    #}}}
     169
     170    @staticmethod
     171    def prop_counts(hbu): #{{{
     172        counts = []
     173        return counts
     174    #}}}
     175
     176    @staticmethod
     177    def prop_pairs_per_variable(hbu): #{{{
     178        pairs_per_variable = []
     179        return pairs_per_variable
     180    #}}}
     181
     182    @staticmethod
     183    def prop_initpt(nuv): #{{{
     184        initpt = []
     185        return initpt
     186    #}}}
     187
     188    @staticmethod
     189    def prop_lower(nuv): #{{{
     190        lower = []
     191        return lower
     192    #}}}
     193
     194    @staticmethod
     195    def prop_upper(nuv): #{{{
     196        upper = []
     197        return upper
     198    #}}}
     199
     200    @staticmethod
     201    def prop_initst(nuv): #{{{
     202        inist = []
     203        return inist
     204    #}}}
     205
     206    @staticmethod
     207    def prop_stype(nuv): #{{{
    163208        stype = []
    164209        return stype
    165 
    166     @staticmethod
    167     def prop_scale(nuv):
     210    #}}}
     211
     212    @staticmethod
     213    def prop_scale(nuv): #{{{
    168214        scale = []
    169215        return scale
     216    #}}}
     217
     218    #new methods:
     219    def isscaled(self): #{{{
     220        if strncmp(self.descriptor, 'scaled_', 7):
     221            return True
     222        else:
     223            return False
     224    #}}}
    170225
    171226    @staticmethod
    172227    def dakota_write(fidi, dvar):
     228        # possible namespace pollution, the above import seems not to work
     229        from vlist_write import vlist_write
    173230        # collect only the variables of the appropriate class
    174         nuv = [struc_class(i, 'normal_uncertain', 'nuv') for i in dvar]
    175 
    176     # possible namespace pollution, the above import seems not to work
    177         from vlist_write import vlist_write
    178     # write variables
    179         vlist_write(fidi, 'normal_uncertain', 'nuv', nuv)
     231        # nuv = [struc_class(i, 'normal_uncertain', 'nuv') for i in dvar]
     232        fields = fieldnames(dvar)
     233        for field in fields:
     234            if getattr(dvar, field)[0].__class__.__name__ != 'normal_uncertain':
     235                delattr(dvar, field)
     236        if len(dvar) > 0:
     237            vlist_write(fidi, 'normal_uncertain', 'nuv', dvar)
     238    #}}}
     239
  • issm/trunk-jpl/src/m/classes/qmu/partition_npart.m

    r24836 r24870  
    11function npart=partition_npart(vector)
    22
    3         %vector could be on vertices or eleemnts, and will have a small amount of possible integer
     3        %vector could be on vertices or elements, and will have a small amount of possible integer
    44        %values:
    55        uvec=unique(vector);
  • issm/trunk-jpl/src/m/classes/qmu/response_function.m

    r24839 r24870  
    1919        rell      =[];
    2020        grell     =[];
    21                 partition = [];
     21        partition = [];
    2222    end
    2323    methods
     
    3535                        self.grell=getfieldvalue(options,'general_reliability_levels',[]);
    3636                       
    37                         %if the response is scaled,  a partition vector should have been supplied.
     37                        %if the response is scaled, a partition vector should have been supplied.
    3838                        if self.isscaled(),
    3939                                self.partition=getfieldvalue(options,'partition');
     
    4242                end %}}}
    4343        function []=disp(rf)% {{{
    44 
    45 
    46         %  display the object
    47 
     44            %TODO: Convert the following to fielddisplay
     45            % display the object
    4846            disp(sprintf('\n'));
    4947            for i=1:numel(rf)
     
    5452                disp(sprintf('         probl: %s'      ,string_vec(rf(i).probl)));
    5553                disp(sprintf('          rell: %s'      ,string_vec(rf(i).rell)));
    56                 disp(sprintf('         grell: %s\n'    ,string_vec(rf(i).grell)));
     54                disp(sprintf('         grell: %s'    ,string_vec(rf(i).grell)));
     55                if ~isempty(self.partition),
     56                    disp(sprintf('     partition: %s'    ,string_vec(rf(i).partition)));
     57                end
     58                disp(sprintf('\n'));
    5759            end
    5860
     
    127129                        %collect only the responses of the appropriate class
    128130            rf=struc_class(dresp,'response_function');
    129 
    130131                        %write responses
    131132                        [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc);
  • issm/trunk-jpl/src/m/classes/qmu/response_function.py

    r24213 r24870  
    11import numpy as np
     2
     3from MatlabFuncs import *
     4from fielddisplay import fielddisplay
     5from pairoptions import pairoptions
     6from partition_npart import *
     7from rlev_write import *
    28#from rlist_write import *
    3 from rlev_write import *
    4 from MatlabArray import *
    5 #move this later
    6 from helpers import *
    79
    810
    911class response_function(object):
    1012    '''
    11   definition for the response_function class.
    12 
    13   [rf] = response_function.response_function(args)
    14    rf = response_function()
    15 
    16   where the required args are:
    17     descriptor    (char, description, '')
    18   and the optional args and defaults are:
    19     respl         (double vector, response levels, [])
    20     probl         (double vector, probability levels, [])
    21     rell          (double vector, reliability levels, [])
    22     grell         (double vector, gen. reliability levels, [])
    23 
    24   note that zero arguments constructs a default instance, one
    25   argument of the class copies the instance, and one or more
    26   arguments constructs a new instance from the arguments.
    27 '''
    28 
     13    RESPONSE_FUNCTION class definition
     14
     15        Usage:
     16            rf = response_function(
     17                'descriptor', descriptor,
     18                'response_levels', respl,
     19                'probability_levels', probl,
     20                'reliability_levels',rell,
     21                'general_reliability_levels', grell,
     22                'partition', partition
     23            )
     24
     25            where rf is the response function object returned by the
     26            constructor. All options except the descriptor are optional. A partition can be provided for scaled variables.
     27
     28        Example:
     29            md.qmu.responses.maxvel = response_function(
     30                'descriptor', 'MaxVel',
     31                'response_levels',[0],
     32                'probl', [0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]
     33                )
     34    '''
    2935    def __init__(self):
    3036        self.descriptor = ''
    31         self.respl = []
    32         self.probl = []
    33         self.rell = []
    34         self.grell = []
     37        self.respl      = []
     38        self.probl      = []
     39        self.rell       = []
     40        self.grell      = []
     41        self.partition  = []
    3542
    3643    @staticmethod
     
    4350
    4451        # copy the object or create the object from the input
    45         else:
    46             if nargin == 1 and isinstance(args[0], response_function):
     52        elif nargin == 1:
     53            if isinstance(args[0], response_function):
    4754                rf = args[0]
    4855            else:
    49                 asizec = array_size(*args[0:min(nargin, 1)])
    50                 rf = [response_function() for i in range(asizec[0]) for j in range(asizec[1])]
    51 
    52                 for i in range(np.size(rf)):
    53                     if (np.size(args[0]) > 1):
    54                         rf[i].descriptor = args[0][i]
    55                     else:
    56                         rf[i].descriptor = str(args[0]) + string_dim(rf, i, 'vector')
    57 
    58                 if nargin >= 2:
    59                     for i in range(np.size(rf)):
    60                         rf[i].respl = args[1]
    61 
    62                 if nargin >= 3:
    63                     for i in range(np.size(rf)):
    64                         rf[i].probl = args[2]
    65 
    66                 if nargin >= 4:
    67                     for i in range(np.size(rf)):
    68                         rf[i].rell = args[3]
    69 
    70                 if nargin >= 5:
    71                     for i in range(np.size(rf)):
    72                         rf[i].grell = args[4]
    73 
    74                 if nargin > 5:
    75                     print('WARNING: response_function:extra_arg: Extra arguments for object of class ' + str(type(rf)) + '.')
    76 
    77         return rf
    78 
    79     def __repr__(self):
    80         #  display the object
    81         string = '\n'
    82         string += 'class "response_function" object = \n'
    83         string += '    descriptor: ' + str(self.descriptor) + '\n'
    84         string += '         respl: ' + str(self.respl) + '\n'
    85         string += '         probl: ' + str(self.probl) + '\n'
    86         string += '          rell: ' + str(self.rell) + '\n'
    87         string += '         grell: ' + str(self.grell) + '\n'
     56                raise RuntimeError('Object ' + str(args[0]) + ' is a ' + str(type(args[0])) + ' class object, not "response_function".')
     57        else:
     58            # asizec = array_size(*args[0:min(nargin, 1)])
     59            # rf = [response_function() for i in range(asizec[0]) for j in range(asizec[1])]
     60
     61            # for i in range(np.size(rf)):
     62            #     if (np.size(args[0]) > 1):
     63            #         rf[i].descriptor = args[0][i]
     64            #     else:
     65            #         rf[i].descriptor = str(args[0]) + string_dim(rf, i, 'vector')
     66
     67            # if nargin >= 2:
     68            #     for i in range(np.size(rf)):
     69            #         rf[i].respl = args[1]
     70
     71            # if nargin >= 3:
     72            #     for i in range(np.size(rf)):
     73            #         rf[i].probl = args[2]
     74
     75            # if nargin >= 4:
     76            #     for i in range(np.size(rf)):
     77            #         rf[i].rell = args[3]
     78
     79            # if nargin >= 5:
     80            #     for i in range(np.size(rf)):
     81            #         rf[i].grell = args[4]
     82
     83            # if nargin > 5:
     84            #     print('WARNING: response_function:extra_arg: Extra arguments for object of class ' + str(type(rf)) + '.')
     85
     86            rf = response_function()
     87
     88            #recover options:
     89            options = pairoptions(*args)
     90
     91            #initialize fields:
     92            rf.descriptor = options.getfieldvalue('descriptor')
     93            rf.respl = options.getfieldvalue('response_levels', [])
     94            rf.probl = options.getfieldvalue('probability_levels', [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     95            rf.rell = options.getfieldvalue('reliability_levels', [])
     96            rf.grell = options.getfieldvalue('general_reliability_levels', [])
     97
     98            #if the response is scaled, a partition vector should have been supplied.
     99            if rf.isscaled():
     100                rf.partition = options.getfieldvalue('partition')
     101                npart = partition_npart(rf.partition)
     102
     103        return [rf] # Always return a list, so we have something akin to a MATLAB single row matrix
     104
     105    def __repr__(self): #{{{
     106        # display the object
     107        string = 'class "response_function" object = \n'
     108        string = "%s\n%s" % (string, fielddisplay(self, 'descriptor', 'name tag'))
     109        string = "%s\n%s" % (string, fielddisplay(self, 'respl', 'response levels'))
     110        string = "%s\n%s" % (string, fielddisplay(self, 'probl', 'probability levels'))
     111        string = "%s\n%s" % (string, fielddisplay(self, 'rell', 'reliability levels'))
     112        string = "%s\n%s" % (string, fielddisplay(self, 'grell', 'general reliability levels'))
     113
     114        if self.partition != []:
     115            string = "%s\n%s" % (string, fielddisplay(self, 'partition', 'partition'))
    88116
    89117        return string
    90 
    91     def __len__(self):
     118    #}}}
     119
     120    def __len__(self): #{{{
    92121        return max(len(self.respl), len(self.probl), len(self.rell), len(self.grell))
    93 
    94     # from here on, rf is either a single, or a 1d vector of, response_function
    95 
    96     @staticmethod
    97     def prop_desc(rf, dstr):
    98         # response_function is always a vector, or should be, even with just 1
    99         if type(rf) not in [list, np.ndarray]:
    100             rf = [rf]
    101 
     122    #}}}
     123
     124    @staticmethod
     125    def prop_desc(rf, dstr): #{{{
    102126        desc = ['' for i in range(np.size(rf))]
    103127        for i in range(np.size(rf)):
     
    111135        desc = allempty(desc)
    112136        return desc
    113 
    114     @staticmethod
    115     def prop_stype(rf):
     137    #}}}
     138
     139    @staticmethod
     140    def prop_stype(rf): #{{{
    116141        stype = []
    117142        return stype
    118 
    119     @staticmethod
    120     def prop_scale(rf):
     143    #}}}
     144
     145    @staticmethod
     146    def prop_scale(rf): #{{{
    121147        scale = []
    122148        return scale
    123 
    124     @staticmethod
    125     def prop_weight(rf):
     149    #}}}
     150
     151    @staticmethod
     152    def prop_weight(rf): #{{{
    126153        weight = []
    127154        return weight
    128 
    129     @staticmethod
    130     def prop_lower(rf):
     155    #}}}
     156
     157    @staticmethod
     158    def prop_lower(rf): #{{{
    131159        lower = []
    132160        return lower
    133 
    134     @staticmethod
    135     def prop_upper(rf):
     161    #}}}
     162
     163    @staticmethod
     164    def prop_upper(rf): #{{{
    136165        upper = []
    137166        return upper
    138 
    139     @staticmethod
    140     def prop_target(rf):
     167    #}}}
     168
     169    @staticmethod
     170    def prop_target(rf): #{{{
    141171        target = []
    142172        return target
     173    #}}}
    143174
    144175    @staticmethod
    145176    def prop_levels(rf):
    146         # response_function is always a vector, or should be, even with just 1
    147         if type(rf) not in [list, np.ndarray]:
    148             rf = [rf]
    149 
    150177        respl = empty_nd_list(np.size(rf))
    151178        probl = empty_nd_list(np.size(rf))
    152179        rell = empty_nd_list(np.size(rf))
    153180        grell = empty_nd_list(np.size(rf))
    154 
    155181        for i in range(np.size(rf)):
    156182            respl[i] = rf[i].respl
     
    158184            rell[i] = rf[i].rell
    159185            grell[i] = rf[i].grell
    160 
    161186        respl = allempty(respl)
    162187        probl = allempty(probl)
     
    165190        return [respl, probl, rell, grell]
    166191
     192    #new methods:
     193    def isscaled(self): #{{{
     194        if strncmpi(self.descriptor, 'scaled_', 7):
     195            return True
     196        else:
     197            return False
     198    #}}}
     199
    167200    @staticmethod
    168201    def dakota_write(fidi, dresp, rdesc):
    169         # collect only the responses of the appropriate class
    170         rf = [struc_class(vars(dresp)[i][j], 'response_function', 'rf') for i in fieldnames(dresp) for j in range(len(vars(dresp)[i]))]
    171 
    172202        #possible namespace pollution here
    173203        from rlist_write import rlist_write
    174         # write responses
    175         rdesc = rlist_write(fidi, 'response_function', 'rf', rf, rdesc)
    176 
     204        # collect only the responses of the appropriate class
     205        #rf = [struc_class(vars(dresp)[i][j], 'response_function', 'rf') for i in fieldnames(dresp) for j in range(len(vars(dresp)[i]))]
     206        fields = fieldnames(dresp)
     207        for field in fields:
     208            if getattr(dresp, field)[0].__class__.__name__ != 'response_function':
     209                delattr(dresp, field)
     210        if len(dresp) > 0:
     211            rdesc = rlist_write(fidi, 'response_function', 'rf', dresp, rdesc)
    177212        return rdesc
    178213
  • issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.m

    r24836 r24870  
    1313
    1414classdef uniform_uncertain
    15     properties
    16         descriptor='';
    17         lower     =-Inf;
    18         upper     = Inf;
    19                 partition = [];
    20     end
    21     methods
     15        properties
     16                descriptor      = '';
     17                lower           = -Inf;
     18                upper           = Inf;
     19                partition       = [];
     20        end
     21        methods
    2222                function self=uniform_uncertain(varargin) %constructor {{{
    2323
     
    3030                        self.lower=getfieldvalue(options,'lower');
    3131
    32                         %if the variable is scaled,  a partition vector should have been supplied, and
    33                         %that partition vector should have as many partitions as the lower and upper
    34                         %vectors:
     32                        %if the variable is scaled, a partition vector should have been
     33                        %supplied, and  that partition vector should have as many
     34                        %partitions as the lower and upper vectors:
    3535                        if self.isscaled(),
    3636                                self.partition=getfieldvalue(options,'partition');
     
    4040                                end
    4141                                if npart~=length(self.lower),
    42                                         error(['uniform_uncertain constructor: for the scaled variable' self.described ' the lower field is not currently a vector of values for all the partitions described in the partition vector']);
     42                                        error(['uniform_uncertain constructor: for the scaled variable' self.descriptor ' the lower field is not currently a vector of values for all the partitions described in the partition vector']);
    4343                                end
    4444                        end
     
    5858                function md=checkconsistency(self,md,solution,analyses) % {{{
    5959
    60                 md = checkfield(md,'field',self.upper,'fieldname','uniform_uncertain.upper','NaN',1,'Inf',1,'>',self.lower,'numel',length(self.lower));
    61                 md = checkfield(md,'field',self.lower,'fieldname','uniform_uncertain.lower','NaN',1,'Inf',1,'<',self.upper,'numel',length(self.upper));
    62                 if self.isscaled(),
    63                         if isempty(self.partition),
    64                                 error('normal_uncertain is a scaled variable, but it''s missing a partition vector');
     60                        md = checkfield(md,'field',self.upper,'fieldname','uniform_uncertain.upper','NaN',1,'Inf',1,'>',self.lower,'numel',length(self.lower));
     61                        md = checkfield(md,'field',self.lower,'fieldname','uniform_uncertain.lower','NaN',1,'Inf',1,'<',self.upper,'numel',length(self.upper));
     62                        if self.isscaled(),
     63                                if isempty(self.partition),
     64                                        error('uniform_uncertain is a scaled variable, but it''s missing a partition vector');
     65                                end
     66                                %better have a partition vector that has as many partitions as upper and lower's size:
     67                                if length(self.upper)~=partition_npart(self.partition),
     68                                        error('uniform_uncertain error message: upper and partition should be vectors of identical size');
     69                                end
     70                                if length(self.lower)~=partition_npart(self.partition),
     71                                        error('uniform_uncertain error message: lower and partition should be vectors of identical size');
     72                                end
     73
     74                                md = checkfield(md,'field',self.partition,'fieldname','uniform_uncertain.partition','NaN',1,'Inf',1,'>=',-1,'numel',[md.mesh.numberofvertices,md.mesh.numberofelements]);
     75                                if size(self.partition,2)>1,
     76                                        error('uniform_uncertain error message: partition should be a column vector');
     77                                end
     78                                partcheck=unique(self.partition);
     79                                partmin=min(partcheck);
     80                                partmax=max(partcheck);
     81                                if partmax<-1,
     82                                        error('uniform_uncertain error message: partition vector''s min value should be -1 (for no partition), or start at 0');
     83                                end
     84                                nmax=max(md.mesh.numberofelements,md.mesh.numberofvertices);
     85                                if partmax>nmax,
     86                                        error('uniform_uncertain error message: partition vector''s values cannot go over the number of vertices or elements');
     87                                end
    6588                        end
    66                         %better have a partition vector that has as many partitions as stddev's size:
    67                         if  length(self.upper)~=partition_npart(self.partition),
    68                                 error('uniform_uncertain error message: upper and partition should be vectors of identical size');
    69                         end
    70                         if  length(self.lower)~=partition_npart(self.partition),
    71                                 error('uniform_uncertain error message: lower and partition should be vectors of identical size');
    72                         end
    73 
    74                         md = checkfield(md,'field',self.partition,'fieldname','normal_uncertain.partition','NaN',1,'Inf',1,'>=',-1,'numel',[md.mesh.numberofvertices,md.mesh.numberofelements]);
    75                         if size(self.partition,2)>1,
    76                                 error('uniform_uncertain error message: partition should be a column vector');
    77                         end
    78                         partcheck=unique(self.partition);
    79                         partmin=min(partcheck);
    80                         partmax=max(partcheck);
    81                         if partmax<-1,
    82                                 error('uniform_uncertain error message: partition vector''s min value should be -1 (for no partition), or start at 0');
    83                         end
    84                         nmax=max(md.mesh.numberofelements,md.mesh.numberofvertices);
    85                         if partmax>nmax,
    86                                 error('uniform_uncertain error message: partition vector''s values cannot go over the number of vertices or elements');
    87                         end
    88                 end
    89         end % }}}
    90         %virtual functions needed by qmu processing algorithms:
    91         %implemented:
    92                 function [desc]  =prop_desc(uuv,dstr) % {{{
     89                end % }}}
     90                %virtual functions needed by qmu processing algorithms:
     91                %implemented:
     92                function [desc] = prop_desc(uuv,dstr) % {{{
    9393                        desc=cell(1,numel(uuv));
    9494                        for i=1:numel(uuv)
     
    105105                        desc=allempty(desc);
    106106                end %}}}
    107                 function [lower] =prop_lower(uuv) % {{{
     107                function [lower] = prop_lower(uuv) % {{{
    108108                        lower=zeros(1,numel(uuv));
    109109                        for i=1:numel(uuv)
     
    112112                        lower=allequal(lower,-Inf);
    113113                end %}}}
    114                 function [upper] =prop_upper(uuv) % {{{
     114                function [upper] = prop_upper(uuv) % {{{
    115115                        upper=zeros(1,numel(uuv));
    116116                        for i=1:numel(uuv)
     
    119119                        upper=allequal(upper, Inf);
    120120                end % }}}
    121         %default
     121                %default
    122122                function [stddev]=prop_stddev(uuv)  %{{{
    123123                        stddev=[];
    124                         end % }}}
    125                         function [mean]  =prop_mean(nuv) % {{{
     124                end % }}}
     125                function [mean]  =prop_mean(nuv) % {{{
    126126                        mean=[];
    127                         end % }}}
    128                         function [initpt]=prop_initpt(uuv) %{{{
     127                end % }}}
     128                function [initpt]=prop_initpt(uuv) %{{{
    129129                        initpt=[];
    130                         end %}}}
    131                         function [initst]=prop_initst(uuv) %{{{
    132                                 initst=[];
    133                                 end %}}}
    134                                 function [stype] =prop_stype(uuv) %{{{
    135                                 stype={};
    136                                 end %}}}
    137                                 function [scale] =prop_scale(uuv) %{{{
    138                                 scale=[];
    139                                 end %}}}
    140                                 function [abscissas] =prop_abscissas(hbu) % {{{
    141                                 abscissas=[];
    142                                 end % }}}
    143                                 function [counts] =prop_counts(hbu) % {{{
    144                                 counts=[];
    145                                 end % }}}
    146         function [pairs_per_variable] =prop_pairs_per_variable(hbu) % {{{
    147                 pairs_per_variable=[];
    148         end % }}}
    149         %new methods:
    150         function scaled =isscaled(self) % {{{
    151                 if strncmp(self.descriptor,'scaled_',7),
    152                         scaled=1;
    153                 else
    154                         scaled=0;
    155                 end
    156         end % }}}
    157     end
     130                end %}}}
     131                function [initst]=prop_initst(uuv) %{{{
     132                        initst=[];
     133                end %}}}
     134                function [stype] =prop_stype(uuv) %{{{
     135                        stype={};
     136                end %}}}
     137                function [scale] =prop_scale(uuv) %{{{
     138                        scale=[];
     139                end %}}}
     140                function [abscissas] =prop_abscissas(hbu) % {{{
     141                        abscissas=[];
     142                end % }}}
     143                function [counts] =prop_counts(hbu) % {{{
     144                        counts=[];
     145                end % }}}
     146                function [pairs_per_variable] =prop_pairs_per_variable(hbu) % {{{
     147                        pairs_per_variable=[];
     148                end % }}}
     149                %new methods:
     150                function scaled =isscaled(self) % {{{
     151                        if strncmp(self.descriptor,'scaled_',7),
     152                                scaled=1;
     153                        else
     154                                scaled=0;
     155                        end
     156                end % }}}
     157        end
    158158        methods (Static)
    159         function []=dakota_write(fidi,dvar) % {{{
     159                function []=dakota_write(fidi,dvar) % {{{
    160160                        %  collect only the variables of the appropriate class
    161             uuv=struc_class(dvar,'uniform_uncertain');
     161                        uuv=struc_class(dvar,'uniform_uncertain');
    162162                        %  write variables
    163             vlist_write(fidi,'uniform_uncertain','uuv',uuv);
    164         end %}}}
    165     end
     163                        vlist_write(fidi,'uniform_uncertain','uuv',uuv);
     164                end %}}}
     165        end
    166166end
  • issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.py

    r24261 r24870  
    11import numpy as np
    2 #from vlist_write import *
     2
    33from MatlabArray import *
     4from MatlabFuncs import *
     5from fielddisplay import fielddisplay
     6from pairoptions import pairoptions
     7from partition_npart import *
    48
    59
    610class uniform_uncertain(object):
    711    '''
    8   definition for the uniform_uncertain class.
    9 
    10   [uuv] = uniform_uncertain.uniform_uncertain(args)
    11    uuv = uniform_uncertain()
    12 
    13   where the required args are:
    14     descriptor    (str, description, '')
    15     lower         (float, lower bound, -np.Inf)
    16     upper         (float, upper bound, np.Inf)
    17 
    18   note that zero arguments constructs a default instance, one
    19   argument of the class copies the instance, and three or more
    20   arguments constructs a new instance from the arguments.
    21 '''
    22 
     12    UNIFORM_UNCERTAIN class definition
     13
     14    Usage:
     15        nuv = uniform_uncertain(
     16            'descriptor', descriptor,
     17            'lower', lower,
     18            'upper', upper,
     19            'partition', partition
     20            )
     21
     22        where nuv is the uniform_uncertain object returned by the constructor,
     23        lower and upper are the pdf distribution bounds, and partition is the
     24        partition vector for distributed variables. Can be a partition vector
     25        over elements or vertices.
     26
     27    Example:
     28        md.qmu.variables.rheology = uniform_uncertain(
     29            'descriptor', 'RheologyBBar',
     30            'lower', 1e8,
     31            'upper', 1e9
     32            )
     33        md.qmu.variables.rheology = uniform_uncertain(
     34            'descriptor', 'RheologyBBar',
     35            'lower', 1e8,
     36            'upper', 1e9,
     37            'partition', vpartition
     38            )
     39    '''
    2340    def __init__(self):
    2441        self.descriptor = ''
    25         self.lower = -np.Inf
    26         self.upper = np.Inf
     42        self.lower      = -np.Inf
     43        self.upper      = np.Inf
     44        self.partition  = []
    2745
    2846    @staticmethod
     
    4159                raise RuntimeError('Object ' + str(args[0]) + ' is a ' + str(type(args[0])) + ' class object, not "uniform_uncertain".')
    4260
    43         # not enough arguments
    44         elif nargin == 2:
    45             raise RuntimeError('Construction of "uniform_uncertain" class object requires at least 3 inputs.')
    46 
    4761        # create the object from the input
    4862        else:
    49             # leaving this here in case it becomes important in the future
    50             #asizec = array_size(*args[0:min(nargin, 3)])
    51             #uuv = [uniform_uncertain() for i in range(asizec[0]) for j in range(asizec[1])]
    5263            uuv = uniform_uncertain()
    53             uuv.descriptor = str(args[0])
    54             uuv.lower = args[1]
    55             uuv.upper = args[2]
    56         if (nargin > 3):
    57             print('WARNING: uniform_uncertain:extra_arg: Extra arguments for object of class ' + type(uuv) + '.')
    58 
    59         return [uuv]
    60 
    61     def __repr__(self):
    62         # display an individual object
    63         string = '\n'
    64         string += 'class "uniform_uncertain" object = \n'
    65         string += '    descriptor: ' + str(self.descriptor) + '\n'
    66         string += '         lower: ' + str(self.lower) + '\n'
    67         string += '         upper: ' + str(self.upper) + '\n'
    68 
     64
     65            #recover options:
     66            options = pairoptions(*args)
     67
     68            #initialize fields:
     69            uuv.descriptor = options.getfieldvalue('descriptor', '')
     70            uuv.lower      = options.getfieldvalue('lower', -np.Inf)
     71            uuv.upper      = options.getfieldvalue('upper', np.Inf)
     72
     73            #if the variable is scaled, a partition vector should have been
     74            #supplied, and  that partition vector should have as many partitions as
     75            #the lower and upper vectors:
     76            if uuv.isscaled():
     77                uuv.partition = options.getfieldvalue('partition')
     78                npart = partition_npart(uuv.partition)
     79                if npart != len(uuv.upper):
     80                    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):
     82                    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)
     83                   
     84        return [uuv] # Always return a list, so we have something akin to a MATLAB single row matrix
     85
     86    def __repr__(self): #{{{
     87        string = '   uniform uncertain variable: '
     88        string = "%s\n%s" % (string, fielddisplay(self, 'descriptor', 'name tag'))
     89        string = "%s\n%s" % (string, fielddisplay(self, 'lower', 'pdf lower bound'))
     90        string = "%s\n%s" % (string, fielddisplay(self, 'upper', 'pdf upper bound'))
     91        if self.partition != []:
     92            string = "%s\n%s" % (string, fielddisplay(self, 'partition', 'partition vector defining where sampling will occur'))
    6993        return string
    70 
    71     # from here on, uuv is either a single, or a 1d vector of, uniform_uncertain
    72 
    73     @staticmethod
    74     def prop_desc(uuv, dstr):
    75         if type(uuv) not in [list, np.ndarray]:
    76             if uuv.descriptor != '' or type(uuv.descriptor) != str:
    77                 desc = str(uuv.descriptor)
    78             elif dstr != '':
    79                 desc = str(dstr)
    80             else:
    81                 desc = 'uuv'
    82             return desc
    83 
     94    #}}}
     95
     96    def __len__(self): #{{{
     97        if type(self.lower) in [list, np.ndarray]:
     98            return len(self.lower)
     99        else:
     100            return 1
     101    #}}}
     102   
     103    def checkconsistency(self, md, solution, analyses): #{{{
     104        md = checkfield(md, 'field', self.upper, 'fieldname', 'uniform_uncertain.upper', 'NaN', 1, 'Inf', 1, '>', self.lower, 'numel', len(self.lower))
     105        md = checkfield(md, 'field', self.lower, 'fieldname', 'uniform_uncertain.upper', 'NaN', 1, 'Inf', 1, '<', self.upper, 'numel', len(self.upper))
     106        if self.isscaled():
     107            if self.partition == []:
     108                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")
     114            md = checkfield(md, 'field', self.partition, 'fieldname', 'uniform_uncertain.partition', 'NaN', 1, 'Inf', 1, '>=', -1, 'numel', [md.mesh.numberofvertices, md.mesh.numberofvertices])
     115            if self.partition.shape[1] > 1:
     116                raise RuntimeError("uniform_uncertain error message: partition should be a column vector")
     117            partcheck = np.unique(self.partition)
     118            partmin = min(partcheck)
     119            partmax = max(partcheck)
     120            if partmax < -1:
     121                raise RuntimeError("uniform_uncertain error message: partition vector's min value should be -1 (for no partition), or start at 0")
     122            nmax = max(md.mesh.numberofelements, md.mesh.numberofvertices)
     123            if partmax > nmax:
     124                raise RuntimeError("uniform_uncertain error message: partition vector's values cannot go over the number of vertices or elements")
     125    #}}}
     126
     127    #virtual functions needed by qmu processing algorithms:
     128    #implemented:
     129
     130    @staticmethod
     131    def prop_desc(uuv, dstr): #{{{
    84132        desc = ['' for i in range(np.size(uuv))]
    85133        for i in range(np.size(uuv)):
     
    94142
    95143        return desc
    96 
    97     @staticmethod
    98     def prop_initpt(uuv):
    99         initpt = []
    100         return initpt
    101 
    102     @staticmethod
    103     def prop_lower(uuv):
     144    #}}}
     145
     146    @staticmethod
     147    def prop_lower(uuv): #{{{
    104148        if type(uuv) not in [list, np.ndarray]:
    105             return uuv.lower
     149            return [uuv.lower]
    106150
    107151        lower = np.zeros(np.size(uuv))
     
    112156
    113157        return lower
    114 
    115     @staticmethod
    116     def prop_upper(uuv):
     158    #}}}
     159
     160    @staticmethod
     161    def prop_upper(uuv): #{{{
    117162        if type(uuv) not in [list, np.ndarray]:
    118             return uuv.upper
     163            return [uuv.upper]
    119164
    120165        upper = np.zeros(np.size(uuv))
     
    125170
    126171        return upper
    127 
    128     @staticmethod
    129     def prop_mean(uuv):
     172    #}}}
     173
     174    @staticmethod
     175    def prop_stddev(uuv): #{{{
     176        stddev = []
     177        return stddev
     178    #}}}
     179
     180    @staticmethod
     181    def prop_mean(uuv): #{{{
    130182        mean = []
    131183        return mean
    132 
    133     @staticmethod
    134     def prop_stddev(uuv):
    135         stddev = []
    136         return stddev
    137 
    138     @staticmethod
    139     def prop_initst(uuv):
     184    #}}}
     185
     186    @staticmethod
     187    def prop_initpt(uuv): #{{{
     188        initpt = []
     189        return initpt
     190    #}}}
     191
     192    @staticmethod
     193    def prop_initst(uuv): #{{{
    140194        initst = []
    141195        return initst
    142 
    143     @staticmethod
    144     def prop_stype(uuv):
     196    #}}}
     197
     198    @staticmethod
     199    def prop_stype(uuv): #{{{
    145200        stype = []
    146201        return stype
    147 
    148     @staticmethod
    149     def prop_scale(uuv):
     202    #}}}
     203
     204    @staticmethod
     205    def prop_scale(uuv): #{{{
    150206        scale = []
    151207        return scale
    152 
    153     @staticmethod
    154     def dakota_write(fidi, dvar):
    155         # collect only the variables of the appropriate class
    156         uuv = [struc_class(i, 'uniform_uncertain', 'uuv') for i in dvar]
     208    #}}}
     209
     210    @staticmethod
     211    def prop_abscissas(hbu): #{{{
     212        abscissas = []
     213        return abscissas
     214    #}}}
     215
     216    @staticmethod
     217    def prop_counts(hbu): #{{{
     218        counts = []
     219        return counts
     220    #}}}
     221
     222    @staticmethod
     223    def prop_pairs_per_variable(hbu): #{{{
     224        pairs_per_variable = []
     225        return pairs_per_variable
     226    #}}}
     227
     228    #new methods:
     229    def isscaled(self): #{{{
     230        if strncmp(self.descriptor, 'scaled_', 7):
     231            return True
     232        else:
     233            return False
     234    #}}}
     235
     236    @staticmethod
     237    def dakota_write(fidi, dvar): #{{{
    157238        # possible namespace pollution, the above import seems not to work
    158239        from vlist_write import vlist_write
    159         # write variables
    160         vlist_write(fidi, 'uniform_uncertain', 'uuv', uuv)
     240        # # collect only the variables of the appropriate class
     241        # uuv = [struc_class(i, 'uniform_uncertain', 'uuv') for i in dvar]
     242        fields = fieldnames(dvar)
     243        for field in fields:
     244            if getattr(dvar, field)[0].__class__.__name__ != 'uniform_uncertain':
     245                delattr(dvar, field)
     246        if len(dvar) > 0:
     247            vlist_write(fidi, 'uniform_uncertain', 'uuv', dvar)
     248    #}}}
  • issm/trunk-jpl/src/m/qmu/dakota_in_write.m

    r23095 r24870  
    109109responses_write(fidi,dmeth,dresp,params);
    110110
    111 
    112111fclose(fidi);
    113112display('End of file successfully written.');
     113
     114% Uncomment to print contents of Dakota input file (for debugging)
     115% type([name ext]);
    114116
    115117end
     
    186188
    187189%  variables vary by method
    188 
    189190for i=1:length(dmeth.variables)
    190191    fhvar=str2func([dmeth.variables{i} '.dakota_write']);
  • issm/trunk-jpl/src/m/qmu/dakota_in_write.py

    r24213 r24870  
    9494    print('End of file successfully written.')
    9595
     96    # Uncomment to print contents of Dakota input file (for debugging)
     97    # with open(filei2, 'r') as fidi:
     98    #     print(fidi.read())
    9699
    97100#  function to write the strategy section of the file
     
    153156def variables_write(fidi, dmeth, dvar):
    154157
     158    # print('Writing variables section of Dakota input file.')
     159
     160    # fidi.write('variables, \n')
     161
     162    # #  variables vary by method
     163    # fd = fieldnames(dvar)
     164    # types = []
     165    # var = []
     166    # for i in range(len(fd)):
     167    #     i_type = eval('dvar.{}[0].__class__.__name__'.format(fd[i]))
     168    #     j = dmeth.variables.index(i_type)
     169    #     str_name = dmeth.variables[j]
     170
     171    # # organize so that multiple instances of the same qmu class
     172    # # (2 different variable instances of "normal_uncertain" for example)
     173    # # are in the same dakota_write call regardless of individual size
     174    # # but that each class has its own dakota_write call
     175    #     if str_name not in types:
     176    #         types.append(str_name)
     177    #         var.append(eval('dvar.{}'.format(fd[i])))
     178    #     else:
     179    #         t = types.index(str_name)
     180    #         var[t].extend(eval('dvar.{}'.format(fd[i])))
     181
     182    # for t in range(len(types)):
     183    #     v = eval('{}.{}()'.format(types[t], types[t]))
     184    #     v.dakota_write(fidi, var[t])
     185
     186    # #  linear constraints vary by method
     187    # fc = dmeth.lcspec
     188
     189    # for i in range(len(dmeth.lcspec)):
     190    #     str_name = dmeth.lcspec[i]
     191    #     var = eval('{}.{}()'.format(str_name, str_name))
     192    # # check that str_name is correct against matlab version which has no argument there
     193    #     var.dakota_write(fidi, eval('dvar.{}[i]'.format(j)), str_name)
     194
     195    # fidi.write('\n')
     196
    155197    print('Writing variables section of Dakota input file.')
    156198
    157199    fidi.write('variables, \n')
    158200
    159     #  variables vary by method
    160     fd = fieldnames(dvar)
    161     types = []
    162     var = []
    163     for i in range(len(fd)):
    164         i_type = eval('dvar.{}[0].__class__.__name__'.format(fd[i]))
    165         j = dmeth.variables.index(i_type)
    166         str_name = dmeth.variables[j]
    167 
    168     # organize so that multiple instances of the same qmu class
    169     # (2 different variable instances of "normal_uncertain" for example)
    170     # are in the same dakota_write call regardless of individual size
    171     # but that each class has its own dakota_write call
    172         if str_name not in types:
    173             types.append(str_name)
    174             var.append(eval('dvar.{}'.format(fd[i])))
    175         else:
    176             t = types.index(str_name)
    177             var[t].extend(eval('dvar.{}'.format(fd[i])))
    178 
    179     for t in range(len(types)):
    180         v = eval('{}.{}()'.format(types[t], types[t]))
    181         v.dakota_write(fidi, var[t])
    182 
    183     #  linear constraints vary by method
    184     fc = dmeth.lcspec
     201    for i in range(len(dmeth.variables)):
     202        str_name = dmeth.variables[i]
     203        # TODO: Remove this check after continuous_state.py has been updated!
     204        if str_name != 'continuous_state':
     205            var = eval('{}.{}()'.format(str_name, str_name))
     206            var.dakota_write(fidi, dvar)
    185207
    186208    for i in range(len(dmeth.lcspec)):
    187209        str_name = dmeth.lcspec[i]
    188210        var = eval('{}.{}()'.format(str_name, str_name))
    189     # check that str_name is correct against matlab version which has no argument there
    190         var.dakota_write(fidi, eval('dvar.{}[i]'.format(j)), str_name)
     211        # check that str_name is correct against matlab version which has no argument there
     212        var.dakota_write(fidi, eval('dvar.{}[i]'.format(str_name)), str_name)
    191213
    192214    fidi.write('\n')
     
    275297
    276298    rdesc = []
    277 
    278299    for i in range(len(dmeth.responses)):
    279300        resp = eval(dmeth.responses[i])
  • issm/trunk-jpl/src/m/qmu/expandvariables.m

    r24835 r24870  
    55for i=1:length(fnames)
    66
    7                
    87    if isa(variables.(fnames{i}),'linear_inequality_constraint') || isa(variables.(fnames{i}),'linear_equality_constraint'  )
    98                %for linear constraints, just copy
  • issm/trunk-jpl/src/m/qmu/expandvariables.py

    r24213 r24870  
    11from QmuSetupVariables import *
    22from helpers import *
    3 
    43from qmu_classes import *
    54
     
    1312
    1413    for k in fnames:
    15         v = eval('variables.{}'.format(k))
     14        v = getattr(variables, k)
    1615
    1716    #  for linear constraints, just copy
     
    2423            for j in range(len(v)):
    2524                #call setupdesign
    26                 exec('dvar.{}=QmuSetupVariables(md, dvar.{}, v[j])'.format(k, k))
     25                exec('dvar.{}=QmuSetupVariables(md, v[j])'.format(k, k))
    2726    return dvar
  • issm/trunk-jpl/src/m/qmu/helpers.py

    r24254 r24870  
    176176
    177177    def __delattr__(self, key):
    178         if name not in self._k:
     178        if key not in self._k:
    179179            raise AttributeError('Attribute "' + str(attr) + '" does not exist or is an internal field and therefore cannot be deleted safely.')
    180180        self.pop(key)
  • issm/trunk-jpl/src/m/qmu/importancefactors.m

    r24173 r24870  
    88%   Example: factors=importancefactors(md,'drag','max_vel');
    99%
    10 
    1110variablenamelength=length(variablename);
    1211
  • issm/trunk-jpl/src/m/qmu/importancefactors.py

    r24241 r24870  
    1010
    1111    Example: factors = importancefactors(md, 'drag', 'max_vel')
    12 '''
    13 
     12    '''
    1413    variablenamelength = len(variablename)
    1514
  • issm/trunk-jpl/src/m/qmu/preqmu.py

    r24541 r24870  
    5050    # go through variables and responses, and check they don't have more than
    5151    #   md.qmu.numberofpartitions values. Also determine numvariables and numresponses
    52     #[[[
     52    #{{{
    5353    numvariables = 0
    5454    variable_fieldnames = fieldnames(variables)
     
    5757        fieldvariables = vars(variables)[field_name]
    5858        for j in range(np.size(fieldvariables)):
    59             if strncmpi(fieldvariables[j].descriptor, '\'scaled_', 8) and str2int(fieldvariables[j].descriptor, 'last') > md.qmu.numberofpartitions:
    60                 raise RuntimeError('preqmu error message: one of the expanded variables has more values than the number of partitions (setup in md.qmu.numberofpartitions)')
    61 
     59            if strncmpi(fieldvariables[j].descriptor, 'scaled_', 7):
     60                npart = partition_npart(fieldvariables[j].partition)
     61                if str2int(fieldvariables[j].descriptor, 'last') > npart:
     62                    raise RuntimeError('preqmu error message: one of the expanded variables has more values than the number of partitions (setup in md.qmu.numberofpartitions)')
    6263        numvariables = numvariables + np.size(vars(variables)[field_name])
    6364
     
    6869        fieldresponses = vars(responses)[field_name]
    6970        for j in range(np.size(fieldresponses)):
    70             if strncmpi(fieldresponses[j].descriptor, '\'scaled_', 8) and str2int(fieldresponses[j].descriptor, 'last') > md.qmu.numberofpartitions:
    71                 raise RuntimeError('preqmu error message: one of the expanded responses has more values than the number of partitions (setup in md.qmu.numberofpartitions)')
    72 
     71            if strncmpi(fieldresponses[j].descriptor, 'scaled_', 7):
     72                npart = partition_npart(fieldresponses[j].partition)
     73                if str2int(fieldresponses[j].descriptor, 'last') > md.qmu.numberofpartitions:
     74                    raise RuntimeError('preqmu error message: one of the expanded responses has more values than the number of partitions (setup in md.qmu.numberofpartitions)')
    7375        numresponses = numresponses + np.size(vars(responses)[field_name])
    74 
    75     #]]]
     76    #}}}
    7677
    7778    # create in file for dakota
  • issm/trunk-jpl/src/m/qmu/rlist_write.py

    r24213 r24870  
    99def rlist_write(fidi, cstring, cstring2, dresp, rdesc):
    1010    '''
    11   function to write response list
    12 '''
    13 
     11    function to write response list
     12    '''
    1413    if dresp is None:
    1514        return
     
    1716    func = eval(cstring)
    1817
    19     if type(dresp) not in [list, np.ndarray]:
    20         dresp = [dresp]
     18    # if type(dresp) not in [list, np.ndarray]:
     19    #     dresp = [dresp]
    2120
    22     # put responses into lists for writing
    23     # (and accumulate descriptors into list for subsequent writing)
     21    fnames = fieldnames(dresp)
    2422
    2523    nresp = 0
     
    3129    ptarget = []
    3230
    33     # assume all fields in dvar[0:n] are consistent (ex. all are normal_uncertain)
    34     #   which will always be true since this is called per field
    35     fnames = fieldnames(dresp[0])
    36     for j in range(len(dresp)):
    37         for i in range(np.size(fnames)):
    38             nresp = nresp + np.size(vars(dresp[j])[fnames[i]])
    39             pstype.extend(func.prop_stype(vars(dresp[j])[fnames[i]]))
    40             pscale.extend(func.prop_scale(vars(dresp[j])[fnames[i]]))
    41             pweight.extend(func.prop_weight(vars(dresp[j])[fnames[i]]))
    42             plower.extend(func.prop_lower(vars(dresp[j])[fnames[i]]))
    43             pupper.extend(func.prop_upper(vars(dresp[j])[fnames[i]]))
    44             ptarget.extend(func.prop_target(vars(dresp[j])[fnames[i]]))
    45             rdesc.extend(func.prop_desc(vars(dresp[j])[fnames[i]], fnames[i]))
     31    for i in range(len(fnames)):
     32        field = getattr(dresp, format(fnames[i]))
     33        nresp = nresp + len(field)
     34        pstype.extend(func.prop_stype(field))
     35        pscale.extend(func.prop_scale(field))
     36        pweight.extend(func.prop_weight(field))
     37        plower.extend(func.prop_lower(field))
     38        pupper.extend(func.prop_upper(field))
     39        ptarget.extend(func.prop_target(field))
     40        rdesc.extend(func.prop_desc(field, field[0].descriptor))
    4641
    4742    # write responses
  • issm/trunk-jpl/src/m/qmu/setupdesign/QmuSetupVariables.m

    r24836 r24870  
    2323        %ok, dealing with semi-discrete distributed variable. Distribute according to how many
    2424        %partitions we want
    25 
    2625        for j=1:md.qmu.numberofpartitions
    2726                dvar(end+1)           =variables;
  • issm/trunk-jpl/src/m/qmu/setupdesign/QmuSetupVariables.py

    r24213 r24870  
    11from MatlabFuncs import *
     2from copy import deepcopy
     3from helpers import *
     4from normal_uncertain import *
    25from uniform_uncertain import *
    3 from normal_uncertain import *
    4 from copy import deepcopy
    56
    67
    7 def QmuSetupVariables(md, dvar, variables):
    8 
     8def QmuSetupVariables(md, variables):
    99    #get descriptor
    1010    descriptor = variables.descriptor
     
    1212    #decide whether this is a distributed variable, which will drive whether we expand it into npart values,
    1313    #or if we just carry it forward as is.
     14
     15    dvar = []
    1416
    1517    #ok, key off according to type of descriptor:
     
    1921            if ((type(variables.lower) in [list, np.ndarray] and len(variables.lower) > md.qmu.numberofpartitions) or (type(variables.upper) in [list, np.ndarray] and len(variables.upper) > md.qmu.numberofpartitions)):
    2022                raise RuntimeError('QmuSetupDesign error message: upper and lower should be either a scalar or a "npart" length vector')
    21 
    2223        elif isinstance(variables, normal_uncertain):
    2324            if type(variables.stddev) in [list, np.ndarray] and len(variables.stddev) > md.qmu.numberofpartitions:
    2425                raise RuntimeError('QmuSetupDesign error message: stddev should be either a scalar or a "npart" length vector')
    2526
    26         #ok, dealing with semi - discrete distributed variable. Distribute according to how many
     27        #ok, dealing with semi-discrete distributed variable. Distribute according to how many
    2728        #partitions we want
    2829        for j in range(md.qmu.numberofpartitions):
    2930            dvar.append(deepcopy(variables))
    30             # "'" is because qmu.in files need for strings to be in actual ''
    31             # must also account for whether we are given 1 instance or an array of instances
    32             # handle descriptors for everything
    33             if type(dvar[-1].descriptor) in [list, np.ndarray] and len(variables.descriptor) > 1 and len(variables.upper) != md.qmu.numberofpartitions:
    34                 if type(variables.descriptor) == np.ndarray:
    35                     dvar[-1].descriptor = np.append(dvar[-1].descriptor, "'" + str(variables.descriptor) + '_' + str(j + 1) + "'")
    36                 else:
    37                     dvar[-1].descriptor.append("'" + str(variables.descriptor) + '_' + str(j + 1) + "'")
    38             else:
    39                 dvar[-1].descriptor = "'" + str(variables.descriptor) + '_' + str(j + 1) + "'"
    4031
    41     # handle uniform_uncertain
     32            # text parsing in dakota requires literal "'identifier'" not just "identifier"
     33            dvar[-1].descriptor = "'" + str(variables.descriptor) + '_' + str(j + 1) + "'"
     34
    4235            if isinstance(variables, uniform_uncertain):
    43                 if type(variables.lower) in [list, np.ndarray] and len(variables.lower) > 1 and len(variables.upper) != md.qmu.numberofpartitions:
    44                     if type(variables.lower) == np.ndarray:
    45                         dvar[-1].lower = np.append(dvar[-1].lower, variables.lower[j])
    46                     else:
    47                         dvar[-1].lower.append(variables.lower[j])
     36                if type(variables.lower) in [list, np.ndarray]:
     37                    dvar[-1].lower = variables.lower[j]
    4838                else:
    4939                    dvar[-1].lower = variables.lower
    50 
    51                 if type(variables.upper) in [list, np.ndarray] and len(variables.upper) > 1 and len(variables.upper) != md.qmu.numberofpartitions:
    52                     if type(variables.upper) == np.ndarray:
    53                         dvar[-1].upper = np.append(dvar[-1].upper, variables.upper[j])
    54                     else:
    55                         dvar[-1].upper.append(variables.upper[j])
     40                if type(variables.upper) in [list, np.ndarray]:
     41                    dvar[-1].upper = variables.upper[j]
    5642                else:
    5743                    dvar[-1].upper = variables.upper
    58 
    59     # handle normal_uncertain
    6044            elif isinstance(variables, normal_uncertain):
    61                 if type(variables.stddev) in [list, np.ndarray] and len(variables.stddev) > 1 and len(variables.upper) != md.qmu.numberofpartitions:
    62                     if type(variables.stddev) == np.ndarray:
    63                         dvar[-1].stddev = np.append(dvar[-1].stddev, variables.stddev[j])
    64                     else:
    65                         dvar[-1].stddev.append(variables.stddev[j])
     45                if type(variables.stddev) in [list, np.ndarray]:
     46                    dvar[-1].stddev = variables.stddev[j]
    6647                else:
    6748                    dvar[-1].stddev = variables.stddev
     49                if type(variables.mean) in [list, np.ndarray]:
     50                    dvar[-1].mean = variables.mean[j]
     51                else:
     52                    dvar[-1].mean = variables.mean
     53    else:
     54        dvar.append(deepcopy(variables))
    6855
    69     # running with a single instance, and therefore length 1 arrays of qmu classes
    70     else:
    71         dvar.append(variables)
    72     # text parsing in dakota requires literal "'identifier'" not just "identifier"
    73         for v in dvar:
    74             v.descriptor = "'" + str(v.descriptor) + "'"
     56        # text parsing in dakota requires literal "'identifier'" not just "identifier"
     57        dvar[-1].descriptor = "'" + str(variables.descriptor) + "'"
    7558
    7659    return dvar
  • issm/trunk-jpl/src/m/qmu/vlist_write.m

    r24438 r24870  
    77    return;
    88end
     9
     10fnames=fieldnames(dvar);
    911
    1012%  put variables into lists for writing
     
    2426pdesc  =[];
    2527
    26 fnames=fieldnames(dvar);
    2728for i=1:numel(fnames)
    2829    nvar=nvar+numel(dvar.(fnames{i}));
  • issm/trunk-jpl/src/m/qmu/vlist_write.py

    r24213 r24870  
    1313    This is used for when both the input dvar and the 'cstring' variables have non - 1 length
    1414    '''
    15 
    1615    if np.size(a) == l:
    1716        if p == 0:
     
    4140    if dvar is None:
    4241        return
    43     #from uniform_uncertain import *
     42
    4443    func = eval(cstring)
    4544
     45    # if type(dvar) not in [list, np.ndarray]:
     46    #     dvar = [dvar]
     47   
     48    fnames = fieldnames(dvar)
     49   
    4650    # put variables into lists for writing
    47 
    48     if type(dvar) not in [list, np.ndarray]:
    49         dvar = [dvar]
    50 
    51     # assume all fields in dvar[0:n] are consistent (ex. all are normal_uncertain)
    52     #   which will always be true since this vlist_write is called per field
    53     fnames = fieldnames(dvar[0])
    54 
    5551    nvar = 0
    56     pinitpt = [[] for i in range(len(fnames))]
    57     plower = [[] for i in range(len(fnames))]
    58     pupper = [[] for i in range(len(fnames))]
    59     pmean = [[] for i in range(len(fnames))]
    60     pstddev = [[] for i in range(len(fnames))]
    61     pinitst = [[] for i in range(len(fnames))]
    62     pstype = [[] for i in range(len(fnames))]
    63     pscale = [[] for i in range(len(fnames))]
    64     pdesc = [[] for i in range(len(fnames))]
     52    pinitpt = []
     53    plower = []
     54    pupper = []
     55    pmean = []
     56    pstddev = []
     57    pinitst = []
     58    pstype = []
     59    pscale = []
     60    ppairs_per_variable = []
     61    pabscissas = []
     62    pcounts = []
     63    pdesc = []
    6564
    6665    for i in range(len(fnames)):
    67         nvar += len(dvar)
    68         for j in dvar:
    69             j = vars(j)[fnames[i]]
    70             pinitpt[i].extend(check(func.prop_initpt(j), len(dvar), len(pinitpt[i])))
    71             plower[i].extend(check(func.prop_lower(j), len(dvar), len(plower[i])))
    72             pupper[i].extend(check(func.prop_upper(j), len(dvar), len(pupper[i])))
    73             pmean[i].extend(check(func.prop_mean(j), len(dvar), len(pmean[i])))
    74             pstddev[i].extend(check(func.prop_stddev(j), len(dvar), len(pstddev[i])))
    75             pinitst[i].extend(check(func.prop_initst(j), len(dvar), len(pinitst[i])))
    76             pstype[i].extend(check(func.prop_stype(j), len(dvar), len(pstype[i])))
    77             pscale[i].extend(check(func.prop_scale(j), len(dvar), len(pscale[i])))
    78             pdesc[i].extend(check(func.prop_desc(j, fnames[i]), len(dvar), len(pdesc[i])))
     66        field = getattr(dvar, format(fnames[i]))
     67        nvar = nvar + len(field)
     68        pinitpt.extend(func.prop_initpt(field))
     69        plower.extend(func.prop_lower(field))
     70        pupper.extend(func.prop_upper(field))
     71        pmean.extend(func.prop_mean(field))
     72        pstddev.extend(func.prop_stddev(field))
     73        pinitst.extend(func.prop_initst(field))
     74        pstype.extend(func.prop_stype(field))
     75        pscale.extend(func.prop_scale(field))
     76        ppairs_per_variable.extend(func.prop_pairs_per_variable(field))
     77        pabscissas.extend(func.prop_abscissas(field))
     78        pcounts.extend(func.prop_counts(field))
     79        pdesc.extend(func.prop_desc(field, field[0].descriptor))
    7980
    8081    pinitpt = allempty(pinitpt)
     
    8687    pstype = allempty(pstype)
    8788    pscale = allempty(pscale)
     89    ppairs_per_variable = allempty(ppairs_per_variable)
     90    pabscissas = allempty(pabscissas)
     91    pcounts = allempty(pcounts)
    8892    pdesc = allempty(pdesc)
    8993
     
    124128        vector_write(fidi, '\t    ', pscale, 6, 76)
    125129
     130    if not isempty(ppairs_per_variable):
     131        fidi.write('\t  ' + cstring2 + '_pairs_per_variable =\n')
     132        vector_write(fidi, '\t    ', ppairs_per_variable, 6, 76)
     133
     134    if not isempty(pabscissas):
     135        fidi.write('\t  ' + cstring2 + '_abscissas =\n')
     136        vector_write(fidi, '\t    ', pabscissas, 6, 76)
     137
     138    if not isempty(pcounts):
     139        fidi.write('\t  ' + cstring2 + '_counts =\n')
     140        vector_write(fidi, '\t    ', pcounts, 6, 76)
     141
    126142    if not isempty(pdesc):
    127         fidi.write('\t  ' + cstring2 + '_descriptors =\n')
     143        fidi.write('\t  ' + 'descriptors =\n')
    128144        vector_write(fidi, '\t    ', pdesc, 6, 76)
    129145
  • issm/trunk-jpl/test/NightlyRun/test218.py

    r24261 r24870  
    8484
    8585#variables
    86 md.qmu.variables.rheology_B = normal_uncertain.normal_uncertain('scaled_MaterialsRheologyB', 1, .05)
     86md.qmu.variables.rheology_B = normal_uncertain.normal_uncertain(
     87        'descriptor', 'scaled_MaterialsRheologyB',
     88        'mean', np.ones(md.mesh.numberofvertices),
     89        'stddev', .05 * np.ones(md.mesh.numberofvertices),
     90        'partition', md.qmu.vpartition
     91        )
    8792
    8893#responses
    89 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     94md.qmu.responses.MaxVel = response_function.response_function('descriptor', 'MaxVel')
    9095
    9196#method
  • issm/trunk-jpl/test/NightlyRun/test234.py

    r24384 r24870  
    4343
    4444#variables
    45 md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain('scaled_SmbMassBalance', 1, 0.1)
     45md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain(
     46    'descriptor', 'scaled_SmbMassBalance',
     47    'mean', np.ones(md.qmu.numberofpartitions),
     48    'stddev', .1 * np.ones(md.qmu.numberofpartitions),
     49    'partition', md.qmu.vpartition
     50    )
    4651
    4752#responses
    48 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    49 md.qmu.responses.IceVolume = response_function.response_function('IceVolume', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    50 md.qmu.responses.MassFlux1 = response_function.response_function('indexed_MassFlux_1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    51 md.qmu.responses.MassFlux2 = response_function.response_function('indexed_MassFlux_2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    52 md.qmu.responses.MassFlux3 = response_function.response_function('indexed_MassFlux_3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    53 md.qmu.responses.MassFlux4 = response_function.response_function('indexed_MassFlux_4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    54 md.qmu.responses.MassFlux5 = response_function.response_function('indexed_MassFlux_5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    55 md.qmu.responses.massFlux6 = response_function.response_function('indexed_MassFlux_6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     53md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
     54md.qmu.responses.IceVolume = response_function.response_function('descriptor','IceVolume')
     55md.qmu.responses.MassFlux1 = response_function.response_function('descriptor','indexed_MassFlux_1')
     56md.qmu.responses.MassFlux2 = response_function.response_function('descriptor','indexed_MassFlux_2')
     57md.qmu.responses.MassFlux3 = response_function.response_function('descriptor','indexed_MassFlux_3')
     58md.qmu.responses.MassFlux4 = response_function.response_function('descriptor','indexed_MassFlux_4')
     59md.qmu.responses.MassFlux5 = response_function.response_function('descriptor','indexed_MassFlux_5')
     60md.qmu.responses.massFlux6 = response_function.response_function('descriptor','indexed_MassFlux_6')
    5661
    5762#mass flux profiles
  • issm/trunk-jpl/test/NightlyRun/test244.py

    r24261 r24870  
    7373
    7474#variables
    75 md.qmu.variables.surface_mass_balanceC = normal_uncertain.normal_uncertain('scaled_SmbC', 1, 0.5)
     75md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain(
     76    'descriptor', 'scaled_SmbC',
     77    'mean', np.ones(md.qmu.numberofpartitions),
     78    'stddev', .5 * np.ones(md.qmu.numberofpartitions),
     79    'partition', md.qmu.epartition
     80    )
    7681Tmin = 273.
    7782telms = np.atleast_2d(np.min(md.smb.Ta[0:-1, :], 1))
     
    8590
    8691mint_on_partition[np.where(np.isnan(mint_on_partition))] = 10**-10
    87 md.qmu.variables.surface_mass_balanceTa = uniform_uncertain.uniform_uncertain('scaled_SmbTa', 1, 0.05)
    88 md.qmu.variables.surface_mass_balanceTa[0].lower = 0.95
    89 md.qmu.variables.surface_mass_balanceTa[0].upper = np.maximum(np.minimum(np.maximum(1.05, mint_on_partition), 0.9999), 0.0001)
     92md.qmu.variables.surface_mass_balanceTa = uniform_uncertain.uniform_uncertain(
     93    'descriptor', 'scaled_SmbTa',
     94    'lower', .95 * np.ones(md.qmu.numberofpartitions),
     95    'upper', np.maximum(np.minimum(np.maximum(1.05, mint_on_partition), 0.9999), 0.0001),
     96    'partition', md.qmu.epartition
     97    )
    9098
    9199#responses
    92 md.qmu.responses.IceVolume = response_function.response_function('IceVolume', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    93 md.qmu.responses.IceMass = response_function.response_function('IceMass', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    94 md.qmu.responses.TotalSmb = response_function.response_function('TotalSmb', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     100md.qmu.responses.IceVolume = response_function.response_function('descriptor','IceVolume')
     101md.qmu.responses.IceMass = response_function.response_function('descriptor','IceMass')
     102md.qmu.responses.TotalSmb = response_function.response_function('descriptor','TotalSmb')
    95103
    96104#  nond_sampling study
  • issm/trunk-jpl/test/NightlyRun/test250.py

    r24384 r24870  
    4141
    4242#variables
    43 md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain('scaled_SmbMassBalance', 1, 0.1)
     43md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain(
     44    'descriptor', 'scaled_SmbMassBalance',
     45    'mean', np.ones(md.qmu.numberofpartitions),
     46    'stddev', .1 * np.ones(md.qmu.numberofpartitions),
     47    'partition', md.qmu.vpartition
     48    )
    4449
    4550#responses
    46 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    47 md.qmu.responses.IceVolume = response_function.response_function('IceVolume', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    48 md.qmu.responses.MassFlux1 = response_function.response_function('indexed_MassFlux_1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    49 md.qmu.responses.MassFlux2 = response_function.response_function('indexed_MassFlux_2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    50 md.qmu.responses.MassFlux3 = response_function.response_function('indexed_MassFlux_3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    51 md.qmu.responses.MassFlux4 = response_function.response_function('indexed_MassFlux_4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    52 md.qmu.responses.MassFlux5 = response_function.response_function('indexed_MassFlux_5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    53 md.qmu.responses.massFlux6 = response_function.response_function('indexed_MassFlux_6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     51md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
     52md.qmu.responses.IceVolume = response_function.response_function('descriptor','IceVolume')
     53md.qmu.responses.MassFlux1 = response_function.response_function('descriptor','indexed_MassFlux_1')
     54md.qmu.responses.MassFlux2 = response_function.response_function('descriptor','indexed_MassFlux_2')
     55md.qmu.responses.MassFlux3 = response_function.response_function('descriptor','indexed_MassFlux_3')
     56md.qmu.responses.MassFlux4 = response_function.response_function('descriptor','indexed_MassFlux_4')
     57md.qmu.responses.MassFlux5 = response_function.response_function('descriptor','indexed_MassFlux_5')
     58md.qmu.responses.massFlux6 = response_function.response_function('descriptor','indexed_MassFlux_6')
    5459
    5560#mass flux profiles
  • issm/trunk-jpl/test/NightlyRun/test251.py

    r24384 r24870  
    4242
    4343#variables
    44 md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain('scaled_SmbMassBalance', 1, 100)
     44md.qmu.variables.surface_mass_balance = normal_uncertain.normal_uncertain(
     45    'descriptor', 'scaled_SmbMassBalance',
     46    'mean', np.ones(md.qmu.numberofpartitions),
     47    'stddev', 100 * np.ones(md.qmu.numberofpartitions),
     48    'partition', md.qmu.vpartition
     49    )
    4550
    4651#responses
    47 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    48 md.qmu.responses.IceVolume = response_function.response_function('IceVolume', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    49 md.qmu.responses.MassFlux1 = response_function.response_function('indexed_MassFlux_1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    50 md.qmu.responses.MassFlux2 = response_function.response_function('indexed_MassFlux_2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    51 md.qmu.responses.MassFlux3 = response_function.response_function('indexed_MassFlux_3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    52 md.qmu.responses.MassFlux4 = response_function.response_function('indexed_MassFlux_4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    53 md.qmu.responses.MassFlux5 = response_function.response_function('indexed_MassFlux_5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    54 md.qmu.responses.massFlux6 = response_function.response_function('indexed_MassFlux_6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     52md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
     53md.qmu.responses.IceVolume = response_function.response_function('descriptor','IceVolume')
     54md.qmu.responses.MassFlux1 = response_function.response_function('descriptor','indexed_MassFlux_1')
     55md.qmu.responses.MassFlux2 = response_function.response_function('descriptor','indexed_MassFlux_2')
     56md.qmu.responses.MassFlux3 = response_function.response_function('descriptor','indexed_MassFlux_3')
     57md.qmu.responses.MassFlux4 = response_function.response_function('descriptor','indexed_MassFlux_4')
     58md.qmu.responses.MassFlux5 = response_function.response_function('descriptor','indexed_MassFlux_5')
     59md.qmu.responses.massFlux6 = response_function.response_function('descriptor','indexed_MassFlux_6')
    5560
    5661#mass flux profiles
  • issm/trunk-jpl/test/NightlyRun/test412.m

    r24839 r24870  
    1111md.qmu.vpartition=md.qmu.vpartition-1;
    1212md.qmu.isdakota=1;
    13 
    1413
    1514%Dakota options
  • issm/trunk-jpl/test/NightlyRun/test412.py

    r24261 r24870  
    3131
    3232#variables
    33 md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain('MaterialsRhoIce', md.materials.rho_ice, 0.01)
    34 md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain('scaled_FrictionCoefficient', 1, 0.01)
     33md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain(
     34    'descriptor', 'MaterialsRhoIce',
     35    'mean', md.materials.rho_ice,
     36    'stddev', .01
     37    )
     38md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain(
     39    'descriptor', 'scaled_FrictionCoefficient',
     40    'mean', np.ones(md.mesh.numberofvertices),
     41    'stddev', .01 * np.ones(md.mesh.numberofvertices),
     42    'partition', md.qmu.vpartition
     43    )
    3544
    3645#responses
    37 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     46md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
    3847
    3948#method
  • issm/trunk-jpl/test/NightlyRun/test413.py

    r24261 r24870  
    2828
    2929#variables
    30 md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain('MaterialsRhoIce', md.materials.rho_ice, 0.01)
    31 md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain('scaled_FrictionCoefficient', 1, 0.01)
     30md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain(
     31    'descriptor', 'MaterialsRhoIce',
     32    'mean', md.materials.rho_ice,
     33    'stddev', 0.1
     34    )
     35md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain(
     36    'descriptor', 'scaled_FrictionCoefficient',
     37    'mean', np.ones(md.qmu.numberofpartitions),
     38    'stddev', .01 * np.ones(md.qmu.numberofpartitions),
     39    'partition', md.qmu.vpartition
     40    )
    3241
    3342#responses
    34 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     43md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
    3544
    3645#method
  • issm/trunk-jpl/test/NightlyRun/test414.py

    r24261 r24870  
    3737
    3838#variables
    39 md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain('scaled_FrictionCoefficient', 1, 0.01)
     39md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain(
     40    'descriptor', 'scaled_FrictionCoefficient',
     41    'mean', np.ones(md.qmu.numberofpartitions),
     42    'stddev', .01 * np.ones(md.qmu.numberofpartitions),
     43    'partition', md.qmu.vpartition
     44    )
    4045
    4146#responses
    42 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    43 md.qmu.responses.MassFlux1 = response_function.response_function('indexed_MassFlux_1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    44 md.qmu.responses.MassFlux2 = response_function.response_function('indexed_MassFlux_2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    45 md.qmu.responses.MassFlux3 = response_function.response_function('indexed_MassFlux_3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    46 md.qmu.responses.MassFlux4 = response_function.response_function('indexed_MassFlux_4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    47 md.qmu.responses.MassFlux5 = response_function.response_function('indexed_MassFlux_5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    48 md.qmu.responses.MassFlux6 = response_function.response_function('indexed_MassFlux_6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    49 md.qmu.responses.MassFlux7 = response_function.response_function('indexed_MassFlux_7', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     47md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
     48md.qmu.responses.IceVolume = response_function.response_function('descriptor','IceVolume')
     49md.qmu.responses.MassFlux1 = response_function.response_function('descriptor','indexed_MassFlux_1')
     50md.qmu.responses.MassFlux2 = response_function.response_function('descriptor','indexed_MassFlux_2')
     51md.qmu.responses.MassFlux3 = response_function.response_function('descriptor','indexed_MassFlux_3')
     52md.qmu.responses.MassFlux4 = response_function.response_function('descriptor','indexed_MassFlux_4')
     53md.qmu.responses.MassFlux5 = response_function.response_function('descriptor','indexed_MassFlux_5')
     54md.qmu.responses.massFlux6 = response_function.response_function('descriptor','indexed_MassFlux_6')
     55md.qmu.responses.massFlux7 = response_function.response_function('descriptor','indexed_MassFlux_7')
    5056
    5157#mass flux profiles
  • issm/trunk-jpl/test/NightlyRun/test417.py

    r24261 r24870  
    3737
    3838#variables
    39 md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain('scaled_FrictionCoefficient', 1, 0.01)
     39md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain(
     40    'descriptor', 'scaled_FrictionCoefficient',
     41    'mean', np.ones(md.qmu.numberofpartitions),
     42    'stddev', .01 * np.ones(md.qmu.numberofpartitions),
     43    'partition', md.qmu.vpartition
     44    )
    4045
    4146#responses
    42 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    43 md.qmu.responses.MassFlux1 = response_function.response_function('indexed_MassFlux_1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    44 md.qmu.responses.MassFlux2 = response_function.response_function('indexed_MassFlux_2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    45 md.qmu.responses.MassFlux3 = response_function.response_function('indexed_MassFlux_3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    46 md.qmu.responses.MassFlux4 = response_function.response_function('indexed_MassFlux_4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    47 md.qmu.responses.MassFlux5 = response_function.response_function('indexed_MassFlux_5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    48 md.qmu.responses.MassFlux6 = response_function.response_function('indexed_MassFlux_6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    49 md.qmu.responses.MassFlux7 = response_function.response_function('indexed_MassFlux_7', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     47md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
     48md.qmu.responses.IceVolume = response_function.response_function('descriptor','IceVolume')
     49md.qmu.responses.MassFlux1 = response_function.response_function('descriptor','indexed_MassFlux_1')
     50md.qmu.responses.MassFlux2 = response_function.response_function('descriptor','indexed_MassFlux_2')
     51md.qmu.responses.MassFlux3 = response_function.response_function('descriptor','indexed_MassFlux_3')
     52md.qmu.responses.MassFlux4 = response_function.response_function('descriptor','indexed_MassFlux_4')
     53md.qmu.responses.MassFlux5 = response_function.response_function('descriptor','indexed_MassFlux_5')
     54md.qmu.responses.massFlux6 = response_function.response_function('descriptor','indexed_MassFlux_6')
     55md.qmu.responses.massFlux7 = response_function.response_function('descriptor','indexed_MassFlux_7')
    5056
    5157#mass flux profiles
  • issm/trunk-jpl/test/NightlyRun/test420.py

    r24261 r24870  
    2929
    3030#variables
    31 md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain('MaterialsRhoIce', md.materials.rho_ice, 0.01)
     31md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain(
     32    'descriptor', 'MaterialsRhoIce',
     33    'mean', 1,
     34    'stddev', .01
     35    )
    3236
    3337#responses
    34 md.qmu.responses.MaxVel = response_function.response_function('scaled_Thickness', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     38md.qmu.responses.MaxVel = response_function.response_function(
     39    'descriptor', 'scaled_Thickness',
     40    'partition', md.qmu.vpartition
     41    )
    3542
    3643#method
  • issm/trunk-jpl/test/NightlyRun/test440.py

    r24261 r24870  
    3030
    3131#variables
    32 md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain('MaterialsRhoIce', md.materials.rho_ice, 0.01)
     32md.qmu.variables.rho_ice = normal_uncertain.normal_uncertain(
     33    'descriptor', 'MaterialsRhoIce',
     34    'mean', 1,
     35    'stddev', 0.01
     36    )
    3337
    3438#responses
    35 md.qmu.responses.MaxVel = response_function.response_function('scaled_Thickness', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     39md.qmu.responses.MaxVel = response_function.response_function(
     40    'descriptor', 'scaled_Thickness',
     41    'partition', md.qmu.vpartition
     42    )
    3643
    3744#method
  • issm/trunk-jpl/test/NightlyRun/test444.py

    r24862 r24870  
    6565version = float(version[0])
    6666
     67#partitioning
     68md.qmu.numberofpartitions = 10
     69md = partitioner(md, 'package', 'chaco', 'npart', md.qmu.numberofpartitions, 'weighting', 'on')
     70md.qmu.vpartition = md.qmu.vpartition - 1
     71md.qmu.isdakota = 1
     72
    6773#variables
    68 md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain('scaled_BasalforcingsFloatingiceMeltingRate', 1, 0.1)
     74md.qmu.variables.drag_coefficient = normal_uncertain.normal_uncertain(
     75    'descriptor', 'scaled_BasalforcingsFloatingiceMeltingRate',
     76    'mean', np.ones(md.qmu.numberofpartitions),
     77    'stddev', .1 * np.ones(md.qmu.numberofpartitions),
     78    'partition', md.qmu.vpartition
     79    )
     80
    6981
    7082#responses
    71 md.qmu.responses.IceMass1 = response_function.response_function('Outputdefinition5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    72 md.qmu.responses.IceVolume1 = response_function.response_function('Outputdefinition6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    73 md.qmu.responses.IceVolumeAboveFloatation1 = response_function.response_function('Outputdefinition7', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    74 md.qmu.responses.IceVolumeAboveFloatation = response_function.response_function('IceVolumeAboveFloatation', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    75 md.qmu.responses.GroundedArea1 = response_function.response_function('Outputdefinition1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    76 md.qmu.responses.FloatingArea1 = response_function.response_function('Outputdefinition2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    77 md.qmu.responses.TotalFloatingBmb1 = response_function.response_function('Outputdefinition3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    78 md.qmu.responses.TotalGroundedBmb1 = response_function.response_function('Outputdefinition4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    79 md.qmu.responses.TotalSmb1 = response_function.response_function('Outputdefinition8', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    80 md.qmu.responses.TotalSmb2 = response_function.response_function('Outputdefinition9', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    81 md.qmu.responses.FloatingArea = response_function.response_function('FloatingArea', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     83md.qmu.responses.IceMass1 = response_function.response_function('descriptor','Outputdefinition5')
     84md.qmu.responses.IceVolume1 = response_function.response_function('descriptor','Outputdefinition6')
     85md.qmu.responses.IceVolumeAboveFloatation1 = response_function.response_function('descriptor','Outputdefinition7')
     86md.qmu.responses.IceVolumeAboveFloatation = response_function.response_function('descriptor','IceVolumeAboveFloatation')
     87md.qmu.responses.GroundedArea1 = response_function.response_function('descriptor','Outputdefinition1')
     88md.qmu.responses.FloatingArea1 = response_function.response_function('descriptor','Outputdefinition2')
     89md.qmu.responses.TotalFloatingBmb1 = response_function.response_function('descriptor','Outputdefinition3')
     90md.qmu.responses.TotalGroundedBmb1 = response_function.response_function('descriptor','Outputdefinition4')
     91md.qmu.responses.TotalSmb1 = response_function.response_function('descriptor','Outputdefinition8')
     92md.qmu.responses.TotalSmb2 = response_function.response_function('descriptor','Outputdefinition9')
     93md.qmu.responses.FloatingArea = response_function.response_function('descriptor','FloatingArea')
    8294
    8395#method
  • issm/trunk-jpl/test/NightlyRun/test445.m

    r24839 r24870  
    2929        'stddev',.05*ones(md.qmu.numberofpartitions,1),...
    3030        'partition',md.qmu.vpartition);
    31 md.qmu.variables.neff=normal_uncertain('descriptor','scaled_BasalforcingsGeothermalflux',...
     31md.qmu.variables.geoflux=normal_uncertain('descriptor','scaled_BasalforcingsGeothermalflux',...
    3232        'mean',ones(md.qmu.numberofpartitions,1),...
    3333        'stddev',.05*ones(md.qmu.numberofpartitions,1),...
  • issm/trunk-jpl/test/NightlyRun/test445.py

    r24261 r24870  
    3434version = float(version[0])
    3535
     36#partitioning
     37md.qmu.numberofpartitions = 10
     38md = partitioner(md, 'package', 'chaco', 'npart', md.qmu.numberofpartitions, 'weighting', 'on')
     39md.qmu.vpartition = md.qmu.vpartition - 1
     40md.qmu.isdakota = 1
     41
    3642#variables
    37 md.qmu.variables.neff = normal_uncertain.normal_uncertain('scaled_FrictionEffectivePressure', 1, .05)
    38 md.qmu.variables.geoflux = normal_uncertain.normal_uncertain('scaled_BasalforcingsGeothermalflux', 1, .05)
     43md.qmu.variables.neff = normal_uncertain.normal_uncertain(
     44    'descriptor', 'scaled_FrictionEffectivePressure',
     45    'mean', np.ones(md.qmu.numberofpartitions),
     46    'stddev', .05 * np.ones(md.qmu.numberofpartitions),
     47    'partition', md.qmu.vpartition
     48    )
     49md.qmu.variables.geoflux = normal_uncertain.normal_uncertain(
     50    'descriptor', 'scaled_BasalforcingsGeothermalflux',
     51    'mean', np.ones(md.qmu.numberofpartitions),
     52    'stddev', .05 * np.ones(md.qmu.numberofpartitions),
     53    'partition', md.qmu.vpartition
     54    )
    3955
    4056#responses
    41 md.qmu.responses.MaxVel = response_function.response_function('MaxVel', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    42 md.qmu.responses.MassFlux1 = response_function.response_function('indexed_MassFlux_1', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    43 md.qmu.responses.MassFlux2 = response_function.response_function('indexed_MassFlux_2', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    44 md.qmu.responses.MassFlux3 = response_function.response_function('indexed_MassFlux_3', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    45 md.qmu.responses.MassFlux4 = response_function.response_function('indexed_MassFlux_4', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    46 md.qmu.responses.MassFlux5 = response_function.response_function('indexed_MassFlux_5', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    47 md.qmu.responses.MassFlux6 = response_function.response_function('indexed_MassFlux_6', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
    48 md.qmu.responses.MassFlux7 = response_function.response_function('indexed_MassFlux_7', [], [0.0001, 0.001, 0.01, 0.25, 0.5, 0.75, 0.99, 0.999, 0.9999])
     57md.qmu.responses.MaxVel = response_function.response_function('descriptor','MaxVel')
     58md.qmu.responses.MassFlux1 = response_function.response_function('descriptor','indexed_MassFlux_1')
     59md.qmu.responses.MassFlux2 = response_function.response_function('descriptor','indexed_MassFlux_2')
     60md.qmu.responses.MassFlux3 = response_function.response_function('descriptor','indexed_MassFlux_3')
     61md.qmu.responses.MassFlux4 = response_function.response_function('descriptor','indexed_MassFlux_4')
     62md.qmu.responses.MassFlux5 = response_function.response_function('descriptor','indexed_MassFlux_5')
     63md.qmu.responses.massFlux6 = response_function.response_function('descriptor','indexed_MassFlux_6')
     64md.qmu.responses.massFlux7 = response_function.response_function('descriptor','indexed_MassFlux_7')
    4965
    5066#mass flux profiles
Note: See TracChangeset for help on using the changeset viewer.