Changeset 13116


Ignore:
Timestamp:
08/21/12 16:09:35 (13 years ago)
Author:
jschierm
Message:

CHG: Minor python modifications.

Location:
issm/trunk-jpl/src/m
Files:
11 edited

Legend:

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

    r13032 r13116  
    11#module imports
    22import numpy
     3from collections import OrderedDict
    34from fielddisplay import fielddisplay
    45from EnumDefinitions import *
     
    1920                self.targets            = ''
    2021                self.tracks             = ''
    21                 self.flightreqs         = {}
     22                self.flightreqs         = OrderedDict()
    2223                self.criterion          = float('NaN')
    2324                self.gridsatequator     = 200000
  • issm/trunk-jpl/src/m/classes/miscellaneous.py

    r13030 r13116  
    11#module imports
     2from collections import OrderedDict
    23from fielddisplay import fielddisplay
    34from EnumDefinitions import *
     
    1819                self.notes = ''
    1920                self.name  = ''
    20                 self.dummy = {}
     21                self.dummy = OrderedDict()
    2122
    2223                #set defaults
  • issm/trunk-jpl/src/m/classes/model/model.py

    r13107 r13116  
    8686                #}}}
    8787
     88        def properties(self):    # {{{
     89                # ordered list of properties since vars(self) is random
     90                return ['mesh',\
     91                        'mask',\
     92                        'geometry',\
     93                        'constants',\
     94                        'surfaceforcings',\
     95                        'basalforcings',\
     96                        'materials',\
     97                        'friction',\
     98                        'flowequation',\
     99                        'timestepping',\
     100                        'initialization',\
     101                        'rifts',\
     102                        'debug',\
     103                        'verbose',\
     104                        'settings',\
     105                        'solver',\
     106                        'cluster',\
     107                        'balancethickness',\
     108                        'diagnostic',\
     109                        'groundingline',\
     110                        'hydrology',\
     111                        'prognostic',\
     112                        'thermal',\
     113                        'steadystate',\
     114                        'transient',\
     115                        'autodiff',\
     116                        'flaim',\
     117                        'inversion',\
     118                        'qmu',\
     119                        'results',\
     120                        'radaroverlay',\
     121                        'miscellaneous',\
     122                        'private']
     123        # }}}
     124
    88125        def __repr__(obj):
    89126                # {{{ Display
     
    101138                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("timestepping","[%s,%s]" % ("1x1",obj.timestepping.__class__.__name__),"time stepping for transient models"))
    102139                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("initialization","[%s,%s]" % ("1x1",obj.initialization.__class__.__name__),"initial guess/state"))
    103                 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("rifts","[%s,%s]" % ("1x1",obj.rifts.__class__.__name__),"rifts properties'"))
     140                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("rifts","[%s,%s]" % ("1x1",obj.rifts.__class__.__name__),"rifts properties"))
    104141                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("debug","[%s,%s]" % ("1x1",obj.debug.__class__.__name__),"debugging tools (valgrind, gprof"))
    105142                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("verbose","[%s,%s]" % ("1x1",obj.verbose.__class__.__name__),"verbosity level in solve"))
    106143                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("settings","[%s,%s]" % ("1x1",obj.settings.__class__.__name__),"settings properties"))
    107                 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("solver","[%s,%s]" % ("1x1",obj.solver.__class__.__name__),"PETSc options for each solution'"))
     144                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("solver","[%s,%s]" % ("1x1",obj.solver.__class__.__name__),"PETSc options for each solution"))
    108145                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("cluster","[%s,%s]" % ("1x1",obj.cluster.__class__.__name__),"cluster parameters (number of cpus...)"))
    109146                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("balancethickness","[%s,%s]" % ("1x1",obj.balancethickness.__class__.__name__),"parameters for balancethickness solution"))
  • issm/trunk-jpl/src/m/classes/pairoptions.py

    r13098 r13116  
     1from collections import OrderedDict
    12from WriteData import *
    23
     
    1213        def __init__(self,*arg):
    1314                self.functionname = ''
    14                 self.list         = {}
     15                self.list         = OrderedDict()
    1516
    1617                #get calling function name
  • issm/trunk-jpl/src/m/classes/private.py

    r13030 r13116  
    11#module imports
     2from collections import OrderedDict
    23from fielddisplay import fielddisplay
    34from EnumDefinitions import *
     
    1718                self.isconsistent = True
    1819                self.runtimename  = ''
    19                 self.bamg         = {}
     20                self.bamg         = OrderedDict()
    2021                self.solution     = ''
    2122
  • issm/trunk-jpl/src/m/classes/qmu.py

    r13030 r13116  
    11#module imports
    22import numpy
     3from collections import OrderedDict
    34from fielddisplay import fielddisplay
    45from EnumDefinitions import *
     
    1920                # {{{ Properties
    2021                self.isdakota                    = 0
    21                 self.variables                   = {}
    22                 self.responses                   = {}
    23                 self.method                      = {}
    24                 self.params                      = {}
    25                 self.results                     = {}
     22                self.variables                   = OrderedDict()
     23                self.responses                   = OrderedDict()
     24                self.method                      = OrderedDict()
     25                self.params                      = OrderedDict()
     26                self.results                     = OrderedDict()
    2627                self.partition                   = float('NaN')
    2728                self.numberofpartitions          = 0
     
    7273
    7374                s+="%s\n" % fielddisplay(self,'isdakota','is qmu analysis activated?')
    74                 for i,variable in enumerate(self.variables):
     75                for i,variable in enumerate(self.variables.iteritems()):
    7576                        s+="         variables%s:  (arrays of each variable class)\n" % \
    7677                                string_dim(self.variables,i)
     
    8485                                        (maxlen+1,fname,size(getattr(variable,fname)),type(getattr(variable,fname)))
    8586
    86                 for i,response in enumerate(self.responses):
     87                for i,response in enumerate(self.responses.iteritems()):
    8788                        s+="         responses%s:  (arrays of each response class)\n" % \
    8889                                string_dim(self.responses,i)
     
    9899                s+="%s\n" % fielddisplay(self,'numberofresponses','number of responses')
    99100
    100                 for i,method in enumerate(self.method):
     101                for i,method in enumerate(self.method.iteritems()):
    101102                        if isinstance(method,'dakota_method'):
    102103                                s+="            method%s :    '%s'\n" % \
    103104                                        (string_dim(method,i),method.method)
    104105
    105                 for i,param in enumerate(self.params):
     106                for i,param in enumerate(self.params.iteritems()):
    106107                        s+="         params%s:  (array of method-independent parameters)\n" % \
    107108                                string_dim(self.params,i)
     
    115116                                        (maxlen+1,fname,any2str(getattr(param,fname)))
    116117
    117                 for i,result in enumerate(self.results):
     118                for i,result in enumerate(self.results.iteritems()):
    118119                        s+="         results%s:  (information from dakota files)\n" % \
    119120                                string_dim(self.results,i)
  • issm/trunk-jpl/src/m/consistency/ismodelselfconsistent.py

    r13043 r13116  
    7777        #Go through a model fields, check that it is a class, and call checkconsistency
    7878        fields=vars(md)
    79         for field in fields.iterkeys():
     79#       for field in fields.iterkeys():
     80        for field in md.properties():
    8081
    8182                #Some properties do not need to be checked
  • issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py

    r13098 r13116  
    11import os
     2from collections import OrderedDict
    23from parseresultsfromdisk import *
    34from EnumToString import EnumToString
     
    2324                #initialize md.results if not a structure yet
    2425                if not isinstance(md.results,dict):
    25                         md.results={}
     26                        md.results=OrderedDict()
    2627
    2728                #load results onto model
  • issm/trunk-jpl/src/m/solve/marshall.py

    r13107 r13116  
    2828
    2929#       for field in fields.iterkeys():
    30         for field in ['mesh','mask','geometry','constants','surfaceforcings','basalforcings','materials','friction','flowequation','timestepping','initialization','rifts','debug','verbose','settings','solver','cluster','balancethickness','diagnostic','groundingline','hydrology','prognostic','thermal','steadystate','transient','autodiff','flaim','inversion','qmu','results','radaroverlay','miscellaneous','private']:
     30        for field in md.properties():
    3131
    3232                #Some properties do not need to be marshalled
  • issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py

    r13023 r13116  
    11import struct
    22import numpy
     3from collections import OrderedDict
    34from MatlabFuncs import *
    45from MatlabProcessPatch import *
     
    3637                raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename)
    3738
    38         results={}
     39        results=OrderedDict()
    3940
    4041        #Read fields until the end of the file.
     
    4344                #Get time and step
    4445                if result['step'] not in results:
    45                         results[result['step']]={}
     46                        results[result['step']]=OrderedDict()
    4647                        results[result['step']]['step']=result['step']
    4748                        results[result['step']]['time']=result['time']
     
    7778                raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename)
    7879
    79         results={}
     80        results=OrderedDict()
    8081
    8182        #if we have done split I/O, ie, we have results that are fragmented across patches,
     
    8687                #Get time and step
    8788                if result['step'] not in results:
    88                         results[result['step']]={}
     89                        results[result['step']]=OrderedDict()
    8990                        results[result['step']]['step']=result['step']
    9091                        results[result['step']]['time']=result['time']
     
    125126                #Get time and step
    126127                if result['step'] not in results:
    127                         results[result['step']]={}
     128                        results[result['step']]=OrderedDict()
    128129                        results[result['step']]['step']=result['step']
    129130                        results[result['step']]['time']=result['time']
     
    180181                        raise TypeError("cannot read data of type %d" % type)
    181182
    182                 result={}
     183                result=OrderedDict()
    183184                result['fieldname']=fieldname
    184185                result['time']=time
     
    187188
    188189        except struct.error as e:
    189                 result={}
     190                result=OrderedDict()
    190191
    191192        return result
     
    221222                        raise TypeError("cannot read data of type %d" % type)
    222223
    223                 result={}
     224                result=OrderedDict()
    224225                result['fieldname']=fieldname
    225226                result['time']=time
     
    229230
    230231        except struct.error as e:
    231                 result={}
     232                result=OrderedDict()
    232233
    233234        return result
  • issm/trunk-jpl/src/m/solve/process_solve_options.py

    r13043 r13116  
    11import os
     2from collections import OrderedDict
    23from EnumDefinitions import *
    34from EnumToString import EnumToString
     
    1314        """
    1415
    15         outoptions={}
     16        outoptions=OrderedDict()
    1617
    1718        #solution_type: check on this option, error out otherwise
Note: See TracChangeset for help on using the changeset viewer.