[25834] | 1 | Index: ../trunk-jpl/src/m/classes/qmu.py
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/classes/qmu.py (revision 25459)
|
---|
| 4 | +++ ../trunk-jpl/src/m/classes/qmu.py (revision 25460)
|
---|
| 5 | @@ -1,6 +1,4 @@
|
---|
| 6 | import numpy as np
|
---|
| 7 | -
|
---|
| 8 | -from checkfield import checkfield
|
---|
| 9 | from collections import OrderedDict
|
---|
| 10 | from dakota_method import *
|
---|
| 11 | from fielddisplay import fielddisplay
|
---|
| 12 | @@ -20,7 +18,7 @@
|
---|
| 13 |
|
---|
| 14 | def __init__(self): # {{{
|
---|
| 15 | self.isdakota = 0
|
---|
| 16 | - self.output = 0
|
---|
| 17 | + self.output = 0
|
---|
| 18 | self.variables = OrderedStruct()
|
---|
| 19 | self.correlation_matrix = []
|
---|
| 20 | self.responses = OrderedStruct()
|
---|
| 21 | @@ -31,6 +29,7 @@
|
---|
| 22 | self.variabledescriptors = []
|
---|
| 23 | self.variablepartitions = []
|
---|
| 24 | self.variablepartitions_npart = []
|
---|
| 25 | + self.variablepartitions_nt = []
|
---|
| 26 | self.responsedescriptors = []
|
---|
| 27 | self.responsepartitions = []
|
---|
| 28 | self.responsepartitions_npart = []
|
---|
| 29 | @@ -127,12 +126,15 @@
|
---|
| 30 |
|
---|
| 31 | return s
|
---|
| 32 | # }}}
|
---|
| 33 | +
|
---|
| 34 | def extrude(self, md): # {{{
|
---|
| 35 | return self
|
---|
| 36 | #}}}
|
---|
| 37 | +
|
---|
| 38 | def setdefaultparameters(self): # {{{
|
---|
| 39 | return self
|
---|
| 40 | #}}}
|
---|
| 41 | +
|
---|
| 42 | def checkconsistency(self, md, solution, analyses): # {{{
|
---|
| 43 | #Early return
|
---|
| 44 | if not md.qmu.isdakota:
|
---|
| 45 | @@ -165,10 +167,10 @@
|
---|
| 46 | if hasattr(variable, 'checkconsistency'):
|
---|
| 47 | variable.checkconsistency(md, solution, analyses)
|
---|
| 48 |
|
---|
| 49 | - # Go through variables and check that we have normal uncertains first,
|
---|
| 50 | - # then uniform uncertains and finally histogram_bin_uncertain. Indeed,
|
---|
| 51 | - # Dakota will order them this waym, and when we send partitions for
|
---|
| 52 | - # scaled variables, they better show up in the order Dakota is feeding
|
---|
| 53 | + # Go through variables and check that we have normal uncertains first,
|
---|
| 54 | + # then uniform uncertains and finally histogram_bin_uncertain. Indeed,
|
---|
| 55 | + # Dakota will order them this waym, and when we send partitions for
|
---|
| 56 | + # scaled variables, they better show up in the order Dakota is feeding
|
---|
| 57 | # them to us in InputUpdateFromDakotax!
|
---|
| 58 | fv = fieldnames(self.variables)
|
---|
| 59 | classlist = []
|
---|
| 60 | @@ -193,6 +195,7 @@
|
---|
| 61 |
|
---|
| 62 | return md
|
---|
| 63 | # }}}
|
---|
| 64 | +
|
---|
| 65 | def marshall(self, prefix, md, fid): # {{{
|
---|
| 66 | WriteData(fid, prefix, 'object', self, 'fieldname', 'isdakota', 'format', 'Boolean')
|
---|
| 67 | WriteData(fid, prefix, 'object', self, 'fieldname', 'output', 'format', 'Boolean')
|
---|
| 68 | Index: ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
|
---|
| 69 | ===================================================================
|
---|
| 70 | --- ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py (revision 25459)
|
---|
| 71 | +++ ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py (revision 25460)
|
---|
| 72 | @@ -157,12 +157,18 @@
|
---|
| 73 | DimDict, ncvar = CreateVar(NCData, Var, field, NCgroup, DimDict)
|
---|
| 74 | if ncvar is not None:
|
---|
| 75 | FillVar(ncvar, Var)
|
---|
| 76 | - # this is a multi layered group thta should not be an "else"
|
---|
| 77 | + # this is an issm class
|
---|
| 78 | elif isclass(type(md.__dict__[group].__dict__[field])):
|
---|
| 79 | classtype = getmodule(type(md.__dict__[group])).__name__
|
---|
| 80 | NCgroup.__setattr__('classtype', classtype)
|
---|
| 81 | Subgroup = NCgroup.createGroup(str(field))
|
---|
| 82 | - classtype = getmodule(type(md.__dict__[group].__dict__[field])).__name__
|
---|
| 83 | + classname = type(md.__dict__[group].__dict__[field]).__name__
|
---|
| 84 | + modulename = getmodule(type(md.__dict__[group].__dict__[field])).__name__
|
---|
| 85 | + if classname == modulename:
|
---|
| 86 | + #when module and class name have the same name
|
---|
| 87 | + classtype = classname
|
---|
| 88 | + else:
|
---|
| 89 | + classtype = modulename + '.' + classname
|
---|
| 90 | Subgroup.__setattr__('classtype', classtype)
|
---|
| 91 | subfields = dict.keys(md.__dict__[group].__dict__[field].__dict__)
|
---|
| 92 | for subfield in subfields:
|
---|
| 93 | Index: ../trunk-jpl/src/m/io/loadvars.py
|
---|
| 94 | ===================================================================
|
---|
| 95 | --- ../trunk-jpl/src/m/io/loadvars.py (revision 25459)
|
---|
| 96 | +++ ../trunk-jpl/src/m/io/loadvars.py (revision 25460)
|
---|
| 97 | @@ -16,10 +16,10 @@
|
---|
| 98 | def loadvars(*args, **kwargs):
|
---|
| 99 | """LOADVARS - function to load variables from a file
|
---|
| 100 |
|
---|
| 101 | - This function loads one or more variables from a file. The names of the
|
---|
| 102 | - variables must be supplied. If more than one variable is specified, it may
|
---|
| 103 | - be done with a list of names or a dictionary of name as keys. The output
|
---|
| 104 | - type will correspond to the input type. All the variables in the file may
|
---|
| 105 | + This function loads one or more variables from a file. The names of the
|
---|
| 106 | + variables must be supplied. If more than one variable is specified, it may
|
---|
| 107 | + be done with a list of names or a dictionary of name as keys. The output
|
---|
| 108 | + type will correspond to the input type. All the variables in the file may
|
---|
| 109 | be loaded by specifying only the file name.
|
---|
| 110 |
|
---|
| 111 | Usage:
|
---|
| 112 | @@ -303,9 +303,15 @@
|
---|
| 113 | if len(NCData.groups[group].groups) > 0:
|
---|
| 114 | for subgroup in NCData.groups[group].groups:
|
---|
| 115 | classe = str(group) + '.' + str(subgroup)
|
---|
| 116 | - class_dict[classe] = [str(getattr(NCData.groups[group].groups[subgroup], 'classtype')), ]
|
---|
| 117 | + submodule = str(getattr(NCData.groups[group].groups[subgroup], 'classtype')).split('.')[-1]
|
---|
| 118 | + class_dict[classe] = [submodule, ]
|
---|
| 119 | if class_dict[classe][0] not in ['dict', 'list', 'cell']:
|
---|
| 120 | - class_dict[classe].append(__import__(class_dict[classe][0]))
|
---|
| 121 | + try:
|
---|
| 122 | + class_dict[classe].append(__import__(class_dict[classe][0]))
|
---|
| 123 | + except ModuleNotFoundError:
|
---|
| 124 | + #submodule probably has a different name
|
---|
| 125 | + modulename = str(getattr(NCData.groups[group].groups[subgroup], 'classtype')).split('.')[0]
|
---|
| 126 | + class_dict[classe].append(__import__(modulename))
|
---|
| 127 | class_tree[classe] = [group, subgroup]
|
---|
| 128 | else:
|
---|
| 129 | classe = str(group)
|
---|