source: issm/oecreview/Archive/24684-25833/ISSM-25459-25460.diff@ 25834

Last change on this file since 25834 was 25834, checked in by Mathieu Morlighem, 4 years ago

CHG: added 24684-25833

File size: 6.0 KB
  • ../trunk-jpl/src/m/classes/qmu.py

     
    11import numpy as np
    2 
    3 from checkfield import checkfield
    42from collections import OrderedDict
    53from dakota_method import *
    64from fielddisplay import fielddisplay
     
    2018
    2119    def __init__(self):  # {{{
    2220        self.isdakota = 0
    23         self.output   = 0
     21        self.output = 0
    2422        self.variables = OrderedStruct()
    2523        self.correlation_matrix = []
    2624        self.responses = OrderedStruct()
     
    3129        self.variabledescriptors = []
    3230        self.variablepartitions = []
    3331        self.variablepartitions_npart = []
     32        self.variablepartitions_nt = []
    3433        self.responsedescriptors = []
    3534        self.responsepartitions = []
    3635        self.responsepartitions_npart = []
     
    127126
    128127        return s
    129128    # }}}
     129
    130130    def extrude(self, md):  # {{{
    131131        return self
    132132    #}}}
     133
    133134    def setdefaultparameters(self):  # {{{
    134135        return self
    135136    #}}}
     137
    136138    def checkconsistency(self, md, solution, analyses):  # {{{
    137139        #Early return
    138140        if not md.qmu.isdakota:
     
    165167            if hasattr(variable, 'checkconsistency'):
    166168                variable.checkconsistency(md, solution, analyses)
    167169
    168         # Go through variables and check that we have normal uncertains first, 
    169         # then uniform uncertains and finally histogram_bin_uncertain. Indeed, 
    170         # Dakota will order them this waym, and when we send partitions for 
    171         # scaled variables, they better show up in the order Dakota is feeding 
     170        # Go through variables and check that we have normal uncertains first,
     171        # then uniform uncertains and finally histogram_bin_uncertain. Indeed,
     172        # Dakota will order them this waym, and when we send partitions for
     173        # scaled variables, they better show up in the order Dakota is feeding
    172174        # them to us in InputUpdateFromDakotax!
    173175        fv = fieldnames(self.variables)
    174176        classlist = []
     
    193195
    194196        return md
    195197    # }}}
     198
    196199    def marshall(self, prefix, md, fid):  # {{{
    197200        WriteData(fid, prefix, 'object', self, 'fieldname', 'isdakota', 'format', 'Boolean')
    198201        WriteData(fid, prefix, 'object', self, 'fieldname', 'output', 'format', 'Boolean')
  • ../trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py

     
    157157                DimDict, ncvar = CreateVar(NCData, Var, field, NCgroup, DimDict)
    158158                if ncvar is not None:
    159159                    FillVar(ncvar, Var)
    160             # this is a multi layered group thta should not be an "else"
     160            # this is an issm class
    161161            elif isclass(type(md.__dict__[group].__dict__[field])):
    162162                classtype = getmodule(type(md.__dict__[group])).__name__
    163163                NCgroup.__setattr__('classtype', classtype)
    164164                Subgroup = NCgroup.createGroup(str(field))
    165                 classtype = getmodule(type(md.__dict__[group].__dict__[field])).__name__
     165                classname = type(md.__dict__[group].__dict__[field]).__name__
     166                modulename = getmodule(type(md.__dict__[group].__dict__[field])).__name__
     167                if classname == modulename:
     168                    #when module and class name have the same name
     169                    classtype = classname
     170                else:
     171                    classtype = modulename + '.' + classname
    166172                Subgroup.__setattr__('classtype', classtype)
    167173                subfields = dict.keys(md.__dict__[group].__dict__[field].__dict__)
    168174                for subfield in subfields:
  • ../trunk-jpl/src/m/io/loadvars.py

     
    1616def loadvars(*args, **kwargs):
    1717    """LOADVARS - function to load variables from a file
    1818
    19     This function loads one or more variables from a file. The names of the 
    20     variables must be supplied. If more than one variable is specified, it may 
    21     be done with a list of names or a dictionary of name as keys. The output 
    22     type will correspond to the input type. All the variables in the file may 
     19    This function loads one or more variables from a file. The names of the
     20    variables must be supplied. If more than one variable is specified, it may
     21    be done with a list of names or a dictionary of name as keys. The output
     22    type will correspond to the input type. All the variables in the file may
    2323    be loaded by specifying only the file name.
    2424
    2525    Usage:
     
    303303        if len(NCData.groups[group].groups) > 0:
    304304            for subgroup in NCData.groups[group].groups:
    305305                classe = str(group) + '.' + str(subgroup)
    306                 class_dict[classe] = [str(getattr(NCData.groups[group].groups[subgroup], 'classtype')), ]
     306                submodule = str(getattr(NCData.groups[group].groups[subgroup], 'classtype')).split('.')[-1]
     307                class_dict[classe] = [submodule, ]
    307308                if class_dict[classe][0] not in ['dict', 'list', 'cell']:
    308                     class_dict[classe].append(__import__(class_dict[classe][0]))
     309                    try:
     310                        class_dict[classe].append(__import__(class_dict[classe][0]))
     311                    except ModuleNotFoundError:
     312                        #submodule probably has a different name
     313                        modulename = str(getattr(NCData.groups[group].groups[subgroup], 'classtype')).split('.')[0]
     314                        class_dict[classe].append(__import__(modulename))
    309315                class_tree[classe] = [group, subgroup]
    310316        else:
    311317            classe = str(group)
Note: See TracBrowser for help on using the repository browser.