Ignore:
Timestamp:
06/21/20 21:48:26 (5 years ago)
Author:
jdquinn
Message:

CHG: Cleanup; saving progress

File:
1 edited

Legend:

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

    r25044 r25090  
    1414
    1515    Usage:
    16         nuv = normal_uncertain('descriptor',descriptor,'mean',mean,'stddev',stddev,'partition',partition)
    17         where nuv is the normal_uncertain object returned by the constructor, mean and stddev are self
    18         explanatory.  partition is the partition vector for distributed variables. Can be a partition
    19         vector over elements or vertices.
     16        [nuv] = normal_uncertain(
     17            'descriptor', descriptor,
     18            'mean', mean,
     19            'stddev', stddev,
     20            'partition', partition
     21            )
     22
     23        where nuv is the normal_uncertain object returned by the constructor,
     24        mean and stddev are self explanatory, and partition is the partition
     25        vector for distributed variables. Can be a partition vector over
     26        elements or vertices.
    2027
    2128    Example:
     
    3239            )
    3340    '''
    34     def __init__(self):
     41    def __init__(self): #{{{
    3542        self.descriptor = ''
    3643        self.mean       = np.NaN
     
    3845        self.partition  = []
    3946        self.nsteps     = 0
     47    #}}}
    4048
    4149    @staticmethod
     
    5260                nuv = args[0]
    5361            else:
    54                 raise RuntimeError('Object ' + str(args[0]) + ' is a ' + str(type(args[0])) + ' class object, not "normal_uncertain".')
     62                raise Exception('Object ' + str(args[0]) + ' is a ' + str(type(args[0])) + ' class object, not "normal_uncertain".')
    5563
    5664        # create the object from the input
    5765        else:
    58             # lines differ here in other classes / tests; see asizec problem in notes
    5966            nuv = normal_uncertain()
    6067
     
    6774            nuv.stddev     = options.getfieldvalue('stddev')
    6875
    69             #if the variable is scaled, a partition vector should have been supplied, and
    70             #that partition vector should have as many partitions as the mean and stddev
    71             #vectors:
     76            #if the variable is scaled, a partition vector should have been
     77            #supplied, and that partition vector should have as many partitions
     78            #as the mean and stddev vectors:
    7279            if nuv.isscaled():
    7380                nuv.partition = options.getfieldvalue('partition')
     
    7582                npart = qmupart2npart(nuv.partition)
    7683                if npart != nuv.mean.shape[0]:
    77                     raise RuntimeError("normal_uncertain constructor: for the scaled variable %s the row size of the mean field should be identical to the number of partitions" % nuv.descriptor)
     84                    raise Exception("normal_uncertain constructor: for the scaled variable %s the row size of the mean field should be identical to the number of partitions" % nuv.descriptor)
    7885                if npart != nuv.stddev.shape[0]:
    79                     raise RuntimeError("normal_uncertain constructor: for the scaled variable %s the row size of the stddev field should be identical to the number of partitions" % nuv.descriptor)
     86                    raise Exception("normal_uncertain constructor: for the scaled variable %s the row size of the stddev field should be identical to the number of partitions" % nuv.descriptor)
    8087                if nuv.nsteps != nuv.mean.shape[1]:
    81                     raise RuntimeError("normal_uncertain constructor: for the scaled variable %s the col size of the mean field should be identical to the number of time steps" % nuv.descriptor)
     88                    raise Exception("normal_uncertain constructor: for the scaled variable %s the col size of the mean field should be identical to the number of time steps" % nuv.descriptor)
    8289                if nuv.nsteps != nuv.stddev.shape[1]:
    83                     raise RuntimeError("normal_uncertain constructor: for the scaled variable %s the col size of the stddev field should be identical to the number of time steps" % nuv.descriptor)
     90                    raise Exception("normal_uncertain constructor: for the scaled variable %s the col size of the stddev field should be identical to the number of time steps" % nuv.descriptor)
    8491
    8592        return [nuv] # Always return a list, so we have something akin to a MATLAB single row matrix
     
    107114    def checkconsistency(self, md, solution, analyses): #{{{
    108115        md = checkfield(md, 'field', self.mean, 'fieldname', 'normal_uncertain.mean', 'NaN', 1, 'Inf', 1, '>=', 0)
    109         md = checkfield(md, 'field', self.stddev, 'fieldname', 'normal_uncertain.stddev', 'NaN', 1, 'Inf', 1, '>=', 0, 'numel', len(self.mean))
     116        md = checkfield(md, 'field', self.stddev, 'fieldname', 'normal_uncertain.stddev', 'NaN', 1, 'Inf', 1, '>=', 0)
    110117        if self.isscaled():
    111118            if self.partition == []:
    112                 raise RuntimeError("normal_uncertain is a scaled variable, but it's missing a partition vector")
     119                raise Exception("normal_uncertain is a scaled variable, but it's missing a partition vector")
    113120            #better have a partition vector that has as many partitions as stddev's size:
    114121            if self.stddev.shape[0] != partition_npart(self.partititon):
    115                 raise RuntimeError("normal_uncertain error message: row size of stddev and partition size should be identical")
     122                raise Exception("normal_uncertain error message: row size of stddev and partition size should be identical")
    116123            if self.mean.shape[0] != partition_npart(self.partition):
    117                 raise RuntimeError("normal_uncertain error message: row size of mean and partition size should be identical")
     124                raise Exception("normal_uncertain error message: row size of mean and partition size should be identical")
    118125            #we need as many steps in stddev and mean as there are in time steps
    119126            if self.stddev.shape[1] != self.nsteps:
    120                 raise RuntimeError("normal_uncertain error message: col size of stddev and partition size should be identical")
     127                raise Exception("normal_uncertain error message: col size of stddev and partition size should be identical")
    121128            if self.mean.shape[1] != self.nsteps:
    122                 raise RuntimeError("normal_uncertain error message: col size of mean and partition size should be identical")
     129                raise Exception("normal_uncertain error message: col size of mean and partition size should be identical")
    123130            md = checkfield(md, 'field', self.partition, 'fieldname', 'normal_uncertain.partition', 'NaN', 1, 'Inf', 1, '>=', -1, 'numel', [md.mesh.numberofvertices, md.mesh.numberofvertices])
    124131            if self.partition.shape[1] > 1:
    125                 raise RuntimeError("normal_uncertain error message: partition should be a column vector")
     132                raise Exception("normal_uncertain error message: partition should be a column vector")
    126133            partcheck = np.unique(self.partition)
    127134            partmin = min(partcheck)
    128135            partmax = max(partcheck)
    129136            if partmax < -1:
    130                 raise RuntimeError("normal_uncertain error message: partition vector's min value should be -1 (for no partition), or start at 0")
     137                raise Exception("normal_uncertain error message: partition vector's min value should be -1 (for no partition), or start at 0")
    131138            nmax = max(md.mesh.numberofelements, md.mesh.numberofvertices)
    132139            if partmax > nmax:
    133                 raise RuntimeError("normal_uncertain error message: partition vector's values cannot go over the number of vertices or elements")
     140                raise Exception("normal_uncertain error message: partition vector's values cannot go over the number of vertices or elements")
    134141    #}}}
    135142
Note: See TracChangeset for help on using the changeset viewer.