Changeset 23709


Ignore:
Timestamp:
02/11/19 04:14:06 (6 years ago)
Author:
bdef
Message:

CHG: pyhton 3 migration (not opperational yet)

Location:
issm/trunk-jpl/src/py3
Files:
64 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/py3/archive/arch.py

    r23689 r23709  
    9595
    9696        print('Source file: ')
    97         print('\t{0}'.format(filename))
     97        print(('\t{0}'.format(filename)))
    9898        print('Variables: ')
    9999
    100100        result=read_field(fid)
    101101        while result:
    102                 print('\t{0}'.format(result['field_name']))
    103                 print('\t\tSize:\t\t{0}'.format(result['size']))
    104                 print('\t\tDatatype:\t{0}'.format(result['data_type']))
     102                print(('\t{0}'.format(result['field_name'])))
     103                print(('\t\tSize:\t\t{0}'.format(result['size'])))
     104                print(('\t\tDatatype:\t{0}'.format(result['data_type'])))
    105105                # go to next result
    106106                result=read_field(fid)
  • issm/trunk-jpl/src/py3/array/MatlabArray.py

    r23677 r23709  
    2929'''
    3030        if type(ain) != type(aval):
    31                 print(allequal.__doc__)
     31                print((allequal.__doc__))
    3232                raise RuntimeError("ain and aval must be of the same type")
    3333       
  • issm/trunk-jpl/src/py3/classes/SMBgemb.py

    r23677 r23709  
    1414
    1515        def __init__(self): # {{{
    16                 #each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived 
    17                 #from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number 
     16                #each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived
     17                #from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number
    1818                #of time steps. )
    1919
     
    2727                #ismelt
    2828                #isdensification
    29                 #isturbulentflux   
    30 
    31                 #inputs: 
     29                #isturbulentflux
     30
     31                #inputs:
    3232                Ta    = float('NaN')    #2 m air temperature, in Kelvin
    3333                V     = float('NaN')    #wind speed (m/s-1)
     
    3737                eAir  = float('NaN')    #screen level vapor pressure [Pa]
    3838                pAir  = float('NaN')    #surface pressure [Pa]
    39                
    4039                Tmean = float('NaN')    #mean annual temperature [K]
    41                 Vmean = float('NaN')    #mean annual wind velocity [m s-1]
     40                Vmean = float('NaN')    #mean annual wind velocity [m s-1]
    4241                C     = float('NaN')    #mean annual snow accumulation [kg m-2 yr-1]
    4342                Tz    = float('NaN')    #height above ground at which temperature (T) was sampled [m]
     
    4746                aValue  = float('NaN') #Albedo forcing at every element.  Used only if aIdx == 0.
    4847                teValue = float('NaN') #Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)
    49        
     48
    5049                # Initialization of snow properties
    5150                Dzini = float('NaN')    #cell depth (m)
     
    6059                Sizeini = float('NaN')  #Number of layers
    6160
    62                 #settings: 
     61                #settings:
    6362                aIdx   = float('NaN')   #method for calculating albedo and subsurface absorption (default is 1)
    64                            # 0: direct input from aValue parameter
    65                                           # 1: effective grain radius [Gardner & Sharp, 2009]
    66                                           # 2: effective grain radius [Brun et al., 2009]
    67                                           # 3: density and cloud amount [Greuell & Konzelmann, 1994]
    68                                           # 4: exponential time decay & wetness [Bougamont & Bamber, 2005]
    69                                           # 5: ingest MODIS mode, direct input from aValue parameter applied to surface ice only
    70 
     63                # 0: direct input from aValue parameter
     64                # 1: effective grain radius [Gardner & Sharp, 2009]
     65                # 2: effective grain radius [Brun et al., 2009]
     66                # 3: density and cloud amount [Greuell & Konzelmann, 1994]
     67                # 4: exponential time decay & wetness [Bougamont & Bamber, 2005]
     68                # 5: ingest MODIS mode, direct input from aValue parameter applied to surface ice only
    7169                swIdx  = float('NaN')   # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1)
    72 
    7370                denIdx = float('NaN')   #densification model to use (default is 2):
    74                                         # 1 = emperical model of Herron and Langway (1980)
    75                                         # 2 = semi-emperical model of Anthern et al. (2010)
    76                                         # 3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)
    77                                         # 4 = DO NOT USE: emperical model of Li and Zwally (2004)
    78                                         # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)
    79                                         # 6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)
    80                                         # 7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)
    81                                        
    82                 dsnowIdx = float('NaN') #model for fresh snow accumulation density (default is 1):
    83                                         # 0 = Original GEMB value, 150 kg/m^3
    84                                         # 1 = Antarctica value of fresh snow density, 350 kg/m^3
    85                                         # 2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)
    86                                         # 3 = Antarctica model of Kaspers et al. (2004)
    87                                         # 4 = Greenland model of Kuipers Munneke et al. (2015)
    88 
     71                # 1 = emperical model of Herron and Langway (1980)
     72                # 2 = semi-emperical model of Anthern et al. (2010)
     73                # 3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)
     74                # 4 = DO NOT USE: emperical model of Li and Zwally (2004)
     75                # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)
     76                # 6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)
     77                # 7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)
     78                dsnowIdx = float('NaN') #model for fresh snow accumulation density (default is 1):
     79                # 0 = Original GEMB value, 150 kg/m^3
     80                # 1 = Antarctica value of fresh snow density, 350 kg/m^3
     81                # 2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)
     82                # 3 = Antarctica model of Kaspers et al. (2004)
     83                # 4 = Greenland model of Kuipers Munneke et al. (2015)
    8984                zTop  = float('NaN')    # depth over which grid length is constant at the top of the snopack (default 10) [m]
    90                 dzTop = float('NaN')    # initial top vertical grid spacing (default .05) [m] 
    91                 dzMin = float('NaN')    # initial min vertical allowable grid spacing (default dzMin/2) [m] 
     85                dzTop = float('NaN')    # initial top vertical grid spacing (default .05) [m]
     86                dzMin = float('NaN')    # initial min vertical allowable grid spacing (default dzMin/2) [m]
    9287                zY    = float('NaN')    # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]
    9388                zMax = float('NaN')     #initial max model depth (default is min(thickness,500)) [m]
     
    9590                outputFreq = float('NaN')       #output frequency in days (default is monthly, 30)
    9691
    97                 #specific albedo parameters: 
    98                 #Method 1 and 2: 
     92                #specific albedo parameters:
     93                #Method 1 and 2:
    9994                aSnow = float('NaN')    # new snow albedo (0.64 - 0.89)
    10095                aIce  = float('NaN')    # range 0.27-0.58 for old snow
    101                         #Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo
     96                #Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo
    10297                cldFrac = float('NaN')  # average cloud amount
    103                         #Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005)
    104                 t0wet = float('NaN')    # time scale for wet snow (15-21.9) 
    105                 t0dry = float('NaN')    # warm snow timescale (30) 
    106                 K     = float('NaN')    # time scale temperature coef. (7) 
     98                #Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005)
     99                t0wet = float('NaN')    # time scale for wet snow (15-21.9)
     100                t0dry = float('NaN')    # warm snow timescale (30)
     101                K     = float('NaN')    # time scale temperature coef. (7)
    107102                adThresh = float('NaN') # Apply aIdx method to all areas with densities below this value,
    108                                         # or else apply direct input value from aValue, allowing albedo to be altered.
    109                                                                                 # Default value is rho water (1023 kg m-3).
     103                # or else apply direct input value from aValue, allowing albedo to be altered.
     104                # Default value is rho water (1023 kg m-3).
    110105
    111106                #densities:
     
    114109                #thermo:
    115110                ThermoDeltaTScaling = float('NaN') #scaling factor to multiply the thermal diffusion timestep (delta t)
    116                
     111
    117112                requested_outputs      = []
    118113
    119                 #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM. 
    120                 #dateN: that's the last row of the above fields. 
    121                 #dt:    included in dateN. Not an input. 
     114                #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM.
     115                #dateN: that's the last row of the above fields.
     116                #dt:    included in dateN. Not an input.
    122117                #elev:  this is taken from the ISSM surface itself.
    123118
     
    128123                #string = "#s\n#s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
    129124                string = '   surface forcings for SMB GEMB model :'
    130                        
    131                 string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'))
     125                string = "%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'))
    132126                string = "%s\n%s"%(string,fielddisplay(self,'isgraingrowth','run grain growth module (default true)'))
    133127                string = "%s\n%s"%(string,fielddisplay(self,'isalbedo','run albedo module (default true)'))
     
    147141                string = "%s\n%s"%(string,fielddisplay(self,'Tmean','mean annual temperature [K]'))
    148142                string = "%s\n%s"%(string,fielddisplay(self,'C','mean annual snow accumulation [kg m-2 yr-1]'))
    149                 string = "%s\n%s"%(string,fielddisplay(self,'Vmean','mean annual temperature [m s-1] (default 10 m/s)'))
     143                string = "%s\n%s"%(string,fielddisplay(self,'Vmean','mean annual temperature [m s-1] (default 10 m/s)'))
    150144                string = "%s\n%s"%(string,fielddisplay(self,'Tz','height above ground at which temperature (T) was sampled [m]'))
    151145                string = "%s\n%s"%(string,fielddisplay(self,'Vz','height above ground at which wind (V) eas sampled [m]'))
     
    161155                string = "%s\n%s"%(string,fielddisplay(self,'adThresh','Apply aIdx method to all areas with densities below this value,','or else apply direct input value from aValue, allowing albedo to be altered.'))
    162156                string = "%s\n%s"%(string,fielddisplay(self,'aIdx',['method for calculating albedo and subsurface absorption (default is 1)',
    163                                  '0: direct input from aValue parameter',
    164                                                 '1: effective grain radius [Gardner & Sharp, 2009]',
    165                                                 '2: effective grain radius [Brun et al., 2009]',
    166                                                 '3: density and cloud amount [Greuell & Konzelmann, 1994]',
    167                                                 '4: exponential time decay & wetness [Bougamont & Bamber, 2005]']))
    168 
     157                                                                                                                                                                                                                                '0: direct input from aValue parameter',
     158                                                                                                                                                                                                                                '1: effective grain radius [Gardner & Sharp, 2009]',
     159                                                                                                                                                                                                                                '2: effective grain radius [Brun et al., 2009]',
     160                                                                                                                                                                                                                                '3: density and cloud amount [Greuell & Konzelmann, 1994]',
     161                                                                                                                                                                                                                                '4: exponential time decay & wetness [Bougamont & Bamber, 2005]']))
    169162                string = "%s\n%s"%(string,fielddisplay(self,'teValue','Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)'))
    170                                
    171163                #snow properties init
    172164                string = "%s\n%s"%(string,fielddisplay(self,'Dzini','Initial cell depth when restart [m]'))
     
    180172                string = "%s\n%s"%(string,fielddisplay(self,'Tini','Initial snow temperature when restart [K]'))
    181173                string = "%s\n%s"%(string,fielddisplay(self,'Sizeini','Initial number of layers when restart [K]'))
    182                        
    183                 #additional albedo parameters: 
     174
     175                #additional albedo parameters:
    184176                if type(self.aIdx) == list or type(self.aIdx) == type(np.array([1,2])) and (self.aIdx == [1,2] or (1 in self.aIdx and 2 in self.aIdx)):
    185177                        string = "%s\n%s"%(string,fielddisplay(self,'aSnow','new snow albedo (0.64 - 0.89)'))
     
    195187                        string = "%s\n%s"%(string,fielddisplay(self,'t0dry','warm snow timescale (30) [d]'))
    196188                        string = "%s\n%s"%(string,fielddisplay(self,'K','time scale temperature coef. (7) [d]'))
    197                
     189
    198190                string = "%s\n%s"%(string,fielddisplay(self,'swIdx','apply all SW to top grid cell (0) or allow SW to penetrate surface (1) [default 1]'))
    199191                string = "%s\n%s"%(string,fielddisplay(self,'denIdx',['densification model to use (default is 2):',
    200                                                 '1 = emperical model of Herron and Langway (1980)',
    201                                                 '2 = semi-emperical model of Anthern et al. (2010)',
    202                                                 '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)',
    203                                                 '4 = DO NOT USE: emperical model of Li and Zwally (2004)',
    204                                                 '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)',
    205                                                 '6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)',
    206                                                 '7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)']))
    207 
    208                 string = "%s\n%s"%(string,fielddisplay(self,'dsnowIdx',['model for fresh snow accumulation density (default is 1):',
    209                                                 '0 = Original GEMB value, 150 kg/m^3',
    210                                                 '1 = Antarctica value of fresh snow density, 350 kg/m^3',
    211                                                 '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)',
    212                                                 '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately',
    213                                                 '4 = Greenland model of Kuipers Munneke et al. (2015)']));
    214 
     192                                                                                                                                                                                                                                        '1 = emperical model of Herron and Langway (1980)',
     193                                                                                                                                                                                                                                        '2 = semi-emperical model of Anthern et al. (2010)',
     194                                                                                                                                                                                                                                        '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)',
     195                                                                                                                                                                                                                                        '4 = DO NOT USE: emperical model of Li and Zwally (2004)',
     196                                                                                                                                                                                                                                        '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)',
     197                                                                                                                                                                                                                                        '6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)',
     198                                                                                                                                                                                                                                        '7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)']))
     199                string = "%s\n%s"%(string,fielddisplay(self,'dsnowIdx',['model for fresh snow accumulation density (default is 1):',
     200                                                                                                                                                                                                                                                '0 = Original GEMB value, 150 kg/m^3',
     201                                                                                                                                                                                                                                                '1 = Antarctica value of fresh snow density, 350 kg/m^3',
     202                                                                                                                                                                                                                                                '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)',
     203                                                                                                                                                                                                                                                '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately',
     204                                                                                                                                                                                                                                                '4 = Greenland model of Kuipers Munneke et al. (2015)']));
    215205                string = "%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
    216206                return string
     
    247237                self.isdensification = 1
    248238                self.isturbulentflux = 1
    249        
     239
    250240                self.aIdx = 1
    251241                self.swIdx = 1
    252242                self.denIdx = 2
    253                 self.dsnowIdx = 1
     243                self.dsnowIdx = 1
    254244                self.zTop = 10*np.ones((mesh.numberofelements,))
    255245                self.dzTop = .05* np.ones((mesh.numberofelements,))
     
    258248                self.ThermoDeltaTScaling = 1/11.0
    259249
    260                 self.Vmean = 10*np.ones((mesh.numberofelements,))
    261                
     250                self.Vmean = 10*np.ones((mesh.numberofelements,))
     251
    262252                self.zMax = 250*np.ones((mesh.numberofelements,))
    263253                self.zMin = 130*np.ones((mesh.numberofelements,))
     
    268258                self.aSnow = 0.85
    269259                self.aIce = 0.48
    270                 self.cldFrac = 0.1 
     260                self.cldFrac = 0.1
    271261                self.t0wet = 15
    272262                self.t0dry = 30
     
    276266                self.teValue = np.ones((mesh.numberofelements,));
    277267                self.aValue = self.aSnow*np.ones(mesh.numberofelements,);
    278        
     268
    279269                self.Dzini = 0.05*np.ones((mesh.numberofelements,2))
    280                 self.Dini = 910.0*np.ones((mesh.numberofelements,2)) 
     270                self.Dini = 910.0*np.ones((mesh.numberofelements,2))
    281271                self.Reini = 2.5*np.ones((mesh.numberofelements,2))
    282272                self.Gdnini = 0.0*np.ones((mesh.numberofelements,2))
     
    286276                self.Aini = self.aSnow*np.ones((mesh.numberofelements,2))
    287277                self.Tini = 273.15*np.ones((mesh.numberofelements,2))
    288 #               /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh). 
    289 #               If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp 
     278#               /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh).
     279#               If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp
    290280                self.Sizeini = 2*np.ones((mesh.numberofelements,))
    291281        #}}}
     
    310300
    311301                md = checkfield(md,'fieldname','smb.Tmean','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'>',273-100,'<',273+100) #-100/100 celsius min/max value
    312                 md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0) 
    313                 md = checkfield(md,'fieldname','smb.Vmean','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0)
    314                 md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000) 
    315                 md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000) 
     302                md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0)
     303                md = checkfield(md,'fieldname','smb.Vmean','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0)
     304                md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000)
     305                md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000)
    316306
    317307                md = checkfield(md,'fieldname','smb.teValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1);
     
    320310                md = checkfield(md,'fieldname','smb.swIdx','NaN',1,'Inf',1,'values',[0,1])
    321311                md = checkfield(md,'fieldname','smb.denIdx','NaN',1,'Inf',1,'values',[1,2,3,4,5,6,7])
    322                 md = checkfield(md,'fieldname','smb.dsnowIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4])
     312                md = checkfield(md,'fieldname','smb.dsnowIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4])
    323313
    324314                md = checkfield(md,'fieldname','smb.zTop','NaN',1,'Inf',1,'> = ',0)
     
    326316                md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0)
    327317                md = checkfield(md,'fieldname','smb.zY','NaN',1,'Inf',1,'> = ',1)
    328                 md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365) #10 years max 
     318                md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365) #10 years max
    329319                md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'> = ',0,'< = ',1)
    330320                md = checkfield(md,'fieldname','smb.ThermoDeltaTScaling','NaN',1,'Inf',1,'> = ',0,'< = ',1)
     
    342332                        md = checkfield(md,'fieldname','smb.t0dry','NaN',1,'Inf',1,'> = ',30,'< = ',30)
    343333                        md = checkfield(md,'fieldname','smb.K','NaN',1,'Inf',1,'> = ',7,'< = ',7)
    344                        
     334
    345335
    346336                #check zTop is < local thickness:
     
    348338                if np.any(he<self.zTop):
    349339                        error('SMBgemb consistency check error: zTop should be smaller than local ice thickness')
    350                
     340
    351341                md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1)
    352342                return md
     
    358348
    359349                WriteData(fid,prefix,'name','md.smb.model','data',8,'format','Integer')
    360                        
     350
    361351                WriteData(fid,prefix,'object',self,'class','smb','fieldname','isgraingrowth','format','Boolean')
    362352                WriteData(fid,prefix,'object',self,'class','smb','fieldname','isalbedo','format','Boolean')
     
    367357                WriteData(fid,prefix,'object',self,'class','smb','fieldname','isdensification','format','Boolean')
    368358                WriteData(fid,prefix,'object',self,'class','smb','fieldname','isturbulentflux','format','Boolean')
    369            
     359
    370360                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Ta','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
    371361                WriteData(fid,prefix,'object',self,'class','smb','fieldname','V','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
     
    374364                WriteData(fid,prefix,'object',self,'class','smb','fieldname','P','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
    375365                WriteData(fid,prefix,'object',self,'class','smb','fieldname','eAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
    376                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','pAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)         
     366                WriteData(fid,prefix,'object',self,'class','smb','fieldname','pAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts)
    377367
    378368                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tmean','format','DoubleMat','mattype',2)
    379369                WriteData(fid,prefix,'object',self,'class','smb','fieldname','C','format','DoubleMat','mattype',2)
    380                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vmean','format','DoubleMat','mattype',2)
     370                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vmean','format','DoubleMat','mattype',2)
    381371                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tz','format','DoubleMat','mattype',2)
    382372                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vz','format','DoubleMat','mattype',2)
     
    387377                WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMax','format','DoubleMat','mattype',2)
    388378                WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMin','format','DoubleMat','mattype',2)
    389                
     379
    390380                WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIdx','format','Integer')
    391381                WriteData(fid,prefix,'object',self,'class','smb','fieldname','swIdx','format','Integer')
    392382                WriteData(fid,prefix,'object',self,'class','smb','fieldname','denIdx','format','Integer')
    393                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dsnowIdx','format','Integer')
     383                WriteData(fid,prefix,'object',self,'class','smb','fieldname','dsnowIdx','format','Integer')
    394384                WriteData(fid,prefix,'object',self,'class','smb','fieldname','InitDensityScaling','format','Double')
    395385                WriteData(fid,prefix,'object',self,'class','smb','fieldname','ThermoDeltaTScaling','format','Double')
     
    405395                WriteData(fid,prefix,'object',self,'class','smb','fieldname','aValue','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts);
    406396                WriteData(fid,prefix,'object',self,'class','smb','fieldname','teValue','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts);
    407            
     397
    408398                #snow properties init
    409399                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dzini','format','DoubleMat','mattype',3)
     
    418408                WriteData(fid,prefix,'object',self,'class','smb','fieldname','Sizeini','format','IntMat','mattype',2)
    419409
    420                 #figure out dt from forcings: 
     410                #figure out dt from forcings:
    421411                time = self.Ta[-1] #assume all forcings are on the same time step
    422412                dtime = np.diff(time,n=1,axis=0)
    423413                dt = min(dtime) / yts
    424            
     414
    425415                WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts)
    426416
    427417                # Check if smb_dt goes evenly into transient core time step
    428418                if (md.timestepping.time_step % dt >=  1e-10):
    429                         error('smb_dt/dt = #f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt)
    430                        
     419                        error('smb_dt/dt = #f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt)
     420
    431421                #process requested outputs
    432422                outputs = self.requested_outputs
     
    435425                        outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
    436426                        outputs    =outputscopy
    437                
     427
    438428                WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
    439429        # }}}
    440 
  • issm/trunk-jpl/src/py3/classes/bamggeom.py

    r23670 r23709  
    2525                elif len(args) == 1:
    2626                        object=args[0]
    27                         for field in object.keys():
     27                        for field in list(object.keys()):
    2828                                if field in vars(self):
    2929                                        setattr(self,field,object[field])
  • issm/trunk-jpl/src/py3/classes/bamgmesh.py

    r23670 r23709  
    3232                elif len(args) == 1:
    3333                        object=args[0]
    34                         for field in object.keys():
     34                        for field in list(object.keys()):
    3535                                if field in vars(self):
    3636                                        setattr(self,field,object[field])
  • issm/trunk-jpl/src/py3/classes/frictioncoulomb.py

    r23670 r23709  
    55
    66class frictioncoulomb(object):
    7     """
    8     FRICTIONCOULOMB class definition
     7        """
     8        FRICTIONCOULOMB class definition
    99
    10     Usage:
    11         frictioncoulomb=frictioncoulomb()
    12     """
     10        Usage:
     11        frictioncoulomb=frictioncoulomb()
     12        """
    1313
    14     def __init__(self): # {{{
    15         self.coefficient = float('NaN')
    16         self.coefficientcoulomb = float('NaN')
    17         self.p = float('NaN')
    18         self.q = float('NaN')
    19         self.coupling    = 0
    20         self.effective_pressure = float('NaN')
    21         #set defaults
    22         self.setdefaultparameters()
     14        def __init__(self): # {{{
     15                self.coefficient = float('NaN')
     16                self.coefficientcoulomb = float('NaN')
     17                self.p = float('NaN')
     18                self.q = float('NaN')
     19                self.coupling    = 0
     20                self.effective_pressure = float('NaN')
     21                #set defaults
     22                self.setdefaultparameters()
     23    #}}}
    2324
    24     #}}}
    25     def __repr__(self): # {{{
    26         string="Basal shear stress parameters: Sigma_b = min(coefficient^2 * Neff ^r * |u_b|^(s-1) * u_b,\n coefficientcoulomb^2 * rho_i * g * (h-h_f)), (effective stress Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p)."
     25        def __repr__(self): # {{{
     26                string="Basal shear stress parameters: Sigma_b = min(coefficient^2 * Neff ^r * |u_b|^(s-1) * u_b,\n coefficientcoulomb^2 * rho_i * g * (h-h_f)), (effective stress Neff=rho_ice*g*thickness+rho_water*g*bed, r=q/p and s=1/p)."
     27                string="%s\n%s"%(string,fielddisplay(self,"coefficient","power law (Weertman) friction coefficient [SI]"))
     28                string="%s\n%s"%(string,fielddisplay(self,"coefficientcoulomb","Coulomb friction coefficient [SI]"))
     29                string="%s\n%s"%(string,fielddisplay(self,"p","p exponent"))
     30                string="%s\n%s"%(string,fielddisplay(self,"q","q exponent"))
     31                string="%s\n%s"%(string,fielddisplay(self,'coupling','Coupling flag: 0 for default, 1 for forcing(provide md.friction.effective_pressure)  and 2 for coupled(not implemented yet)'))
     32                string="%s\n%s"%(string,fielddisplay(self,'effective_pressure','Effective Pressure for the forcing if not coupled [Pa]'))
     33                return string
     34        #}}}
     35        def extrude(self,md): # {{{
     36                self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1)
     37                self.coefficientcoulomb=project3d(md,'vector',self.coefficientcoulomb,'type','node','layer',1)
     38                self.p=project3d(md,'vector',self.p,'type','element')
     39                self.q=project3d(md,'vector',self.q,'type','element')
     40                if self.coupling==1:
     41                        self.effective_pressure=project3d(md,'vector',self.effective_pressure,'type','node','layer',1)
     42                elif self.coupling==2:
     43                        raise ValueError('coupling not supported yet')
     44                elif self.coupling > 2:
     45                        raise ValueError('md.friction.coupling larger than 2, not supported yet')
     46                return self
     47        #}}}
    2748
    28         string="%s\n%s"%(string,fielddisplay(self,"coefficient","power law (Weertman) friction coefficient [SI]"))
    29         string="%s\n%s"%(string,fielddisplay(self,"coefficientcoulomb","Coulomb friction coefficient [SI]"))
    30         string="%s\n%s"%(string,fielddisplay(self,"p","p exponent"))
    31         string="%s\n%s"%(string,fielddisplay(self,"q","q exponent"))
    32         string="%s\n%s"%(string,fielddisplay(self,'coupling','Coupling flag: 0 for default, 1 for forcing(provide md.friction.effective_pressure)  and 2 for coupled(not implemented yet)'))
    33         string="%s\n%s"%(string,fielddisplay(self,'effective_pressure','Effective Pressure for the forcing if not coupled [Pa]'))
    34         return string
    35     #}}}
    36     def extrude(self,md): # {{{
    37         self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1)
    38         self.coefficientcoulomb=project3d(md,'vector',self.coefficientcoulomb,'type','node','layer',1)
    39         self.p=project3d(md,'vector',self.p,'type','element')
    40         self.q=project3d(md,'vector',self.q,'type','element')
    41         if self.coupling==1:
    42                 self.effective_pressure=project3d(md,'vector',self.effective_pressure,'type','node','layer',1)
    43         elif self.coupling==2:
    44                 raise ValueError('coupling not supported yet')
    45         elif self.coupling > 2:
    46                 raise ValueError('md.friction.coupling larger than 2, not supported yet')       
    47         return self
    48     #}}}
    49     def setdefaultparameters(self): # {{{
    50         return self
    51     #}}}
    52     def checkconsistency(self,md,solution,analyses):    # {{{
     49        def setdefaultparameters(self): # {{{
     50                return self
     51        #}}}
    5352
    54         #Early return
    55         if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
    56             return md
     53        def checkconsistency(self,md,solution,analyses):    # {{{
     54                #Early return
     55                if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
     56                        return md
    5757
    58         md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1,'Inf',1)
    59         md = checkfield(md,'fieldname','friction.coefficientcoulomb','timeseries',1,'NaN',1,'Inf',1)
    60         md = checkfield(md,'fieldname','friction.q','NaN',1,'Inf',1,'size',[md.mesh.numberofelements])
    61         md = checkfield(md,'fieldname','friction.p','NaN',1,'Inf',1,'size',[md.mesh.numberofelements])
    62         if self.coupling==1:
    63                 md = checkfield(md,'fieldname','friction.effective_pressure','NaN',1,'Inf',1,'timeseries',1)
    64         elif self.coupling==2:
    65                 raise ValueError('coupling not supported yet')
    66         elif self.coupling > 2:
    67                 raise ValueError('md.friction.coupling larger than 2, not supported yet')
    68         return md
     58                md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1,'Inf',1)
     59                md = checkfield(md,'fieldname','friction.coefficientcoulomb','timeseries',1,'NaN',1,'Inf',1)
     60                md = checkfield(md,'fieldname','friction.q','NaN',1,'Inf',1,'size',[md.mesh.numberofelements])
     61                md = checkfield(md,'fieldname','friction.p','NaN',1,'Inf',1,'size',[md.mesh.numberofelements])
     62                if self.coupling==1:
     63                        md = checkfield(md,'fieldname','friction.effective_pressure','NaN',1,'Inf',1,'timeseries',1)
     64                elif self.coupling==2:
     65                        raise ValueError('coupling not supported yet')
     66                elif self.coupling > 2:
     67                        raise ValueError('md.friction.coupling larger than 2, not supported yet')
     68                return md
     69    # }}}
    6970
     71        def marshall(self,prefix,md,fid):    # {{{
     72                WriteData(fid,prefix,'name','md.friction.law','data',7,'format','Integer')
     73                WriteData(fid,prefix,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     74                WriteData(fid,prefix,'object',self,'fieldname','coefficientcoulomb','format','DoubleMat','mattype',1)
     75                WriteData(fid,prefix,'object',self,'fieldname','p','format','DoubleMat','mattype',2)
     76                WriteData(fid,prefix,'object',self,'fieldname','q','format','DoubleMat','mattype',2)
     77                WriteData(fid,prefix,'class','friction','object',self,'fieldname','coupling','format','Integer')
     78                if self.coupling==1:
     79                        WriteData(fid,prefix,'class','friction','object',self,'fieldname','effective_pressure','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     80                elif self.coupling==2:
     81                        raise ValueError('coupling not supported yet')
     82                elif self.coupling > 2:
     83                        raise ValueError('md.friction.coupling larger than 2, not supported yet')
    7084    # }}}
    71     def marshall(self,prefix,md,fid):    # {{{
    72         WriteData(fid,prefix,'name','md.friction.law','data',7,'format','Integer')
    73         WriteData(fid,prefix,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    74         WriteData(fid,prefix,'object',self,'fieldname','coefficientcoulomb','format','DoubleMat','mattype',1)
    75         WriteData(fid,prefix,'object',self,'fieldname','p','format','DoubleMat','mattype',2)
    76         WriteData(fid,prefix,'object',self,'fieldname','q','format','DoubleMat','mattype',2)
    77         WriteData(fid,prefix,'class','friction','object',self,'fieldname','coupling','format','Integer')
    78         if self.coupling==1:
    79                 WriteData(fid,prefix,'class','friction','object',self,'fieldname','effective_pressure','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    80         elif self.coupling==2:
    81                 raise ValueError('coupling not supported yet')
    82         elif self.coupling > 2:
    83                 raise ValueError('md.friction.coupling larger than 2, not supported yet')       
    84     # }}}
  • issm/trunk-jpl/src/py3/classes/frictionshakti.py

    r23677 r23709  
    55
    66class frictionshakti(object):
    7     """
    8     FRICTIONSHAKTI class definition
     7        """
     8        FRICTIONSHAKTI class definition
    99
    10     Usage:
    11         friction=frictionshakti()
    12     """
     10        Usage:
     11        friction=frictionshakti()
     12        """
    1313
    14     def __init__(self,md): # {{{
    15         self.coefficient = md.friction.coefficient
    16         #set defaults
    17         self.setdefaultparameters()
     14        def __init__(self,md): # {{{
     15                self.coefficient = md.friction.coefficient
     16                #set defaults
     17                self.setdefaultparameters()
     18        #}}}
    1819
    19     #}}}
    20     def __repr__(self): # {{{
    21         string="Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n(effective stress Neff=rho_ice*g*thickness+rho_water*g*(head-b))"
     20        def __repr__(self): # {{{
     21                string="Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n(effective stress Neff=rho_ice*g*thickness+rho_water*g*(head-b))"
     22                string="%s\n%s"%(string,fielddisplay(self,"coefficient","friction coefficient [SI]"))
     23                return string
     24        #}}}
    2225
    23         string="%s\n%s"%(string,fielddisplay(self,"coefficient","friction coefficient [SI]"))
    24         return string
    25     #}}}
    26     def extrude(self,md): # {{{
    27         self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1)       
    28         return self
    29     #}}}
    30     def setdefaultparameters(self): # {{{
    31         return self
    32     #}}}
    33     def checkconsistency(self,md,solution,analyses):    # {{{
     26        def extrude(self,md): # {{{
     27                self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1)
     28                return self
     29        #}}}
    3430
    35         #Early return
    36         if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
    37             return md
     31        def setdefaultparameters(self): # {{{
     32                return self
     33        #}}}
    3834
    39         md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1,'Inf',1)
    40         return md
     35        def checkconsistency(self,md,solution,analyses):    # {{{
     36                #Early return
     37                if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
     38                        return md
    4139
     40                md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1,'Inf',1)
     41                return md
     42        # }}}
     43
     44        def marshall(self,prefix,md,fid):    # {{{
     45                yts=md.constants.yts
     46                WriteData(fid,prefix,'name','md.friction.law','data',8,'format','Integer')
     47                WriteData(fid,prefix,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    4248    # }}}
    43     def marshall(self,prefix,md,fid):    # {{{
    44         yts=md.constants.yts
    45         WriteData(fid,prefix,'name','md.friction.law','data',8,'format','Integer')
    46         WriteData(fid,prefix,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)     
    47     # }}}
  • issm/trunk-jpl/src/py3/classes/hydrologyshakti.py

    r23677 r23709  
    3030                #}}}
    3131        def __repr__(self): # {{{
    32                
    3332                string='   hydrologyshakti solution parameters:'
    3433                string="%s\n%s"%(string,fielddisplay(self,'head','subglacial hydrology water head (m)'))
     
    4544                string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
    4645                return string
    47                 #}}}
     46        #}}}
     47
    4848        def extrude(self,md): # {{{
    4949                return self
    5050        #}}}
     51
    5152        def setdefaultparameters(self): # {{{
    52                 # Set under-relaxation parameter to be 1 (no under-relaxation of nonlinear iteration)   
     53                # Set under-relaxation parameter to be 1 (no under-relaxation of nonlinear iteration)
    5354                self.relaxation=1
    5455                self.storage=0
     
    5657                return self
    5758        #}}}
     59
    5860        def defaultoutputs(self,md): # {{{
    5961                list = ['HydrologyHead','HydrologyGapHeight','EffectivePressure','HydrologyBasalFlux','DegreeOfChannelization']
     
    6264
    6365        def checkconsistency(self,md,solution,analyses):    # {{{
    64                
    6566                #Early return
    6667                if 'HydrologyShaktiAnalysis' not in analyses:
     
    7677                md = checkfield(md,'fieldname','hydrology.neumannflux','timeseries',1,'NaN',1,'Inf',1)
    7778                md = checkfield(md,'fieldname','hydrology.spchead','size',[md.mesh.numberofvertices])
    78                 md = checkfield(md,'fieldname','hydrology.relaxation','>=',0)   
     79                md = checkfield(md,'fieldname','hydrology.relaxation','>=',0)
    7980                md = checkfield(md,'fieldname','hydrology.storage','>=',0)
    8081                md = checkfield(md,'fieldname','hydrology.requested_outputs','stringrow',1)
    81 
    8282                return md
    8383        # }}}
     84
    8485        def marshall(self,prefix,md,fid):    # {{{
    8586                yts=md.constants.yts
  • issm/trunk-jpl/src/py3/classes/massfluxatgate.py

    r23670 r23709  
    4646        #}}}
    4747        def checkconsistency(self,md,solution,analyses):    # {{{
    48                
     48
    4949                if  not isinstance(self.name, str):
    5050                        raise RuntimeError("massfluxatgate error message: 'name' field should be a string!")
    51                        
     51
    5252                if  not isinstance(self.profilename, str):
    53                         raise RuntimeError("massfluxatgate error message: 'profilename' field should be a string!") 
    54                
     53                        raise RuntimeError("massfluxatgate error message: 'profilename' field should be a string!")
     54
    5555                OutputdefinitionStringArray=[]
    5656                for i in range(1,100):
    5757                        x='Outputdefinition'+str(i)
    5858                        OutputdefinitionStringArray.append(x)
    59                        
     59
    6060                md = checkfield(md,'field',self.definitionstring,'values',OutputdefinitionStringArray)
    61                
    62                 #check the profilename points to a file!: 
     61
     62                #check the profilename points to a file!:
    6363                if not os.path.isfile(self.profilename):
    6464                        raise RuntimeError("massfluxatgate error message: file name for profile corresponding to gate does not point to a legitimate file on disk!")
     
    6767        # }}}
    6868        def marshall(self,prefix,md,fid):    # {{{
    69                
    70                 #before marshalling, we need to create the segments out of the profilename: 
     69
     70                #before marshalling, we need to create the segments out of the profilename:
    7171                self.segments=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,self.profilename)[0]
    7272
    73                 #ok, marshall name and segments: 
     73                #ok, marshall name and segments:
    7474                WriteData(fid,prefix,'data',self.name,'name','md.massfluxatgate.name','format','String');
    7575                WriteData(fid,prefix,'data',self.definitionstring,'name','md.massfluxatgate.definitionstring','format','String');
  • issm/trunk-jpl/src/py3/classes/matestar.py

    r23677 r23709  
    1414
    1515        def __init__(self): # {{{
    16                
    17                 rho_ice                    = 0.
    18                 rho_water                  = 0.
    19                 rho_freshwater             = 0.
    20                 mu_water                   = 0.
    21                 heatcapacity               = 0.
    22                 latentheat                 = 0.
    23                 thermalconductivity        = 0.
    24                 temperateiceconductivity   = 0.
    25                 meltingpoint               = 0.
    26                 beta                       = 0.
    27                 mixed_layer_capacity       = 0.
    28                 thermal_exchange_velocity  = 0.
    29                 rheology_B    = float('NaN')
    30                 rheology_Ec   = float('NaN')
    31                 rheology_Es   = float('NaN')
    32                 rheology_law = ''
     16                rho_ice                   = 0.
     17                rho_water                 = 0.
     18                rho_freshwater            = 0.
     19                mu_water                  = 0.
     20                heatcapacity              = 0.
     21                latentheat                = 0.
     22                thermalconductivity       = 0.
     23                temperateiceconductivity  = 0.
     24                meltingpoint              = 0.
     25                beta                      = 0.
     26                mixed_layer_capacity      = 0.
     27                thermal_exchange_velocity = 0.
     28                rheology_B                                                              = float('NaN')
     29                rheology_Ec                                                             = float('NaN')
     30                rheology_Es                                                             = float('NaN')
     31                rheology_law                                                    = ''
    3332
    34                 #giaivins: 
     33                #giaivins:
    3534                lithosphere_shear_modulus  = 0.
    3635                lithosphere_density        = 0.
     
    4140                earth_density              = 0
    4241
    43                 #set default parameters:
     42                #set default parameters:
    4443                self.setdefaultparameters()
    4544        #}}}
     45
    4646        def __repr__(self): # {{{
    4747                string="   Materials:"
    48 
    4948                string="%s\n%s"%(string,fielddisplay(self,'rho_ice','ice density [kg/m^3]'))
    5049                string="%s\n%s"%(string,fielddisplay(self,'rho_water','ocean water density [kg/m^3]'))
     
    6867                string="%s\n%s"%(string,fielddisplay(self,'mantle_density','Mantle density [g/cm^-3]'))
    6968                string="%s\n%s"%(string,fielddisplay(self,'earth_density','Mantle density [kg/m^-3]'))
    70 
    7169                return string
    7270        #}}}
     71
    7372        def extrude(self,md): # {{{
    7473                self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node')
    7574                self.rheology_Ec=project3d(md,'vector',self.rheology_Ec,'type','node')
    7675                self.rheology_Es=project3d(md,'vector',self.rheology_Es,'type','node')
    77                 return self
     76                return self
    7877        #}}}
     78
    7979        def setdefaultparameters(self): # {{{
    8080                #ice density (kg/m^3)
    8181                self.rho_ice=917.
    82 
    8382                #ocean water density (kg/m^3)
    8483                self.rho_water=1023.
    85 
    8684                #fresh water density (kg/m^3)
    8785                self.rho_freshwater=1000.
    88 
    8986                #water viscosity (N.s/m^2)
    90                 self.mu_water=0.001787
    91 
     87                self.mu_water=0.001787
    9288                #ice heat capacity cp (J/kg/K)
    9389                self.heatcapacity=2093.
    94 
    9590                #ice latent heat of fusion L (J/kg)
    9691                self.latentheat=3.34*10**5
    97 
    9892                #ice thermal conductivity (W/m/K)
    9993                self.thermalconductivity=2.4
    100                        
    10194                #wet ice thermal conductivity (W/m/K)
    10295                self.temperateiceconductivity=.24
    103 
    10496                #the melting point of ice at 1 atmosphere of pressure in K
    10597                self.meltingpoint=273.15
    106 
    10798                #rate of change of melting point with pressure (K/Pa)
    10899                self.beta=9.8*10**-8
    109 
    110100                #mixed layer (ice-water interface) heat capacity (J/kg/K)
    111101                self.mixed_layer_capacity=3974.
    112 
    113102                #thermal exchange velocity (ice-water interface) (m/s)
    114103                self.thermal_exchange_velocity=1.00*10**-4
    115 
    116104                #Rheology law: what is the temperature dependence of B with T
    117105                #available: none, paterson and arrhenius
    118106                self.rheology_law='Paterson'
    119 
    120107                # GIA:
    121108                self.lithosphere_shear_modulus  = 6.7*10**10  # (Pa)
     
    123110                self.mantle_shear_modulus       = 1.45*10**11 # (Pa)
    124111                self.mantle_density             = 3.34      # (g/cm^-3)
    125 
    126112                #SLR
    127113                self.earth_density= 5512  # average density of the Earth, (kg/m^3)
     
    129115                return self
    130116        #}}}
     117
    131118        def checkconsistency(self,md,solution,analyses):    # {{{
    132119                md = checkfield(md,'fieldname','materials.rho_ice','>',0)
     
    144131                        md = checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1)
    145132                        md = checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1)
     133
    146134                if 'SealevelriseAnalysis' in analyses:
    147135                        md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1)
     
    149137                return md
    150138        # }}}
     139
    151140        def marshall(self,prefix,md,fid):    # {{{
    152141                WriteData(fid,prefix,'name','md.materials.type','data',2,'format','Integer')
     
    167156                WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_Es','format','DoubleMat','mattype',1)
    168157                WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String')
    169 
    170158                WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double')
    171159                WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3)
  • issm/trunk-jpl/src/py3/classes/mismipbasalforcings.py

    r23670 r23709  
    66
    77class mismipbasalforcings(object):
    8     """
    9     MISMIP Basal Forcings class definition
     8        """
     9        MISMIP Basal Forcings class definition
    1010
    11         Usage:
    12             mismipbasalforcings=mismipbasalforcings()
    13     """
     11        Usage:
     12        mismipbasalforcings=mismipbasalforcings()
     13        """
    1414
    15     def __init__(self): # {{{
     15        def __init__(self): # {{{
     16                self.groundedice_melting_rate = float('NaN')
     17                self.meltrate_factor = float('NaN')
     18                self.threshold_thickness = float('NaN')
     19                self.upperdepth_melt = float('NaN')
     20                self.geothermalflux = float('NaN')
     21                self.setdefaultparameters()
    1622
    17         self.groundedice_melting_rate = float('NaN')
    18         self.meltrate_factor = float('NaN')
    19         self.threshold_thickness = float('NaN')
    20         self.upperdepth_melt = float('NaN')
    21         self.geothermalflux = float('NaN')
    22 
    23         self.setdefaultparameters()
    24 
    25     #}}}
    26     def __repr__(self): # {{{
    27         string=" MISMIP+ basal melt parameterization\n"
    28         string="%s\n%s"%(string,fielddisplay(self,"groundedice_melting_rate","basal melting rate (positive if melting) [m/yr]"))
    29         string="%s\n%s"%(string,fielddisplay(self,"meltrate_factor","Melt-rate rate factor [1/yr] (sign is opposite to MISMIP+ benchmark to remain consistent with ISSM convention of positive values for melting)"))
    30         string="%s\n%s"%(string,fielddisplay(self,"threshold_thickness","Threshold thickness for saturation of basal melting [m]"))
    31         string="%s\n%s"%(string,fielddisplay(self,"upperdepth_melt","Depth above which melt rate is zero [m]"))
    32         string="%s\n%s"%(string,fielddisplay(self,"geothermalflux","Geothermal heat flux [W/m^2]"))
    33         return string
    34     #}}}
    35     def extrude(self,md): # {{{
    36         self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1)
    37         self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1)    #bedrock only gets geothermal flux
    38         return self
    39     #}}}
    40     def initialize(self,md): # {{{
    41         if np.all(np.isnan(self.groundedice_melting_rate)):
    42             self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices))
    43             print(' no basalforcings.groundedice_melting_rate specified: values set as zero')
    44         if np.all(np.isnan(self.geothermalflux)):
     23                #}}}
     24        def __repr__(self): # {{{
     25                string=" MISMIP+ basal melt parameterization\n"
     26                string="%s\n%s"%(string,fielddisplay(self,"groundedice_melting_rate","basal melting rate (positive if melting) [m/yr]"))
     27                string="%s\n%s"%(string,fielddisplay(self,"meltrate_factor","Melt-rate rate factor [1/yr] (sign is opposite to MISMIP+ benchmark to remain consistent with ISSM convention of positive values for melting)"))
     28                string="%s\n%s"%(string,fielddisplay(self,"threshold_thickness","Threshold thickness for saturation of basal melting [m]"))
     29                string="%s\n%s"%(string,fielddisplay(self,"upperdepth_melt","Depth above which melt rate is zero [m]"))
     30                string="%s\n%s"%(string,fielddisplay(self,"geothermalflux","Geothermal heat flux [W/m^2]"))
     31                return string
     32        #}}}
     33        def extrude(self,md): # {{{
     34                self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1)
     35                self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1)    #bedrock only gets geothermal flux
     36                return self
     37        #}}}
     38        def initialize(self,md): # {{{
     39                if np.all(np.isnan(self.groundedice_melting_rate)):
     40                        self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices))
     41                        print(' no basalforcings.groundedice_melting_rate specified: values set as zero')
     42                if np.all(np.isnan(self.geothermalflux)):
    4543                        self.geothermalflux=np.zeros((md.mesh.numberofvertices))
    4644                        print("      no basalforcings.geothermalflux specified: values set as zero")
    47         return self
    48     #}}}
    49     def setdefaultparameters(self): # {{{
    50         # default values for melting parameterization
    51         self.meltrate_factor = 0.2
    52         self.threshold_thickness = 75.
    53         self.upperdepth_melt = -100.
    54         return self
    55     #}}}
    56     def checkconsistency(self,md,solution,analyses):    # {{{
     45                return self
     46        #}}}
     47        def setdefaultparameters(self): # {{{
     48                # default values for melting parameterization
     49                self.meltrate_factor = 0.2
     50                self.threshold_thickness = 75.
     51                self.upperdepth_melt = -100.
     52                return self
     53        #}}}
     54        def checkconsistency(self,md,solution,analyses):    # {{{
     55                #Early return
     56                if 'MasstransportAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.ismasstransport==0):
     57                        md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
     58                        md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
     59                        md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
     60                        md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
    5761
    58         #Early return
    59         if 'MasstransportAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.ismasstransport==0):
     62                if 'BalancethicknessAnalysis' in analyses:
     63                        md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     64                        md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
     65                        md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
     66                        md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
    6067
    61             md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
    62             md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
    63             md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
    64             md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
     68                if 'ThermalAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.isthermal==0):
     69                        md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
     70                        md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
     71                        md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
     72                        md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
     73                        md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0)
     74                return md
     75        # }}}
     76        def marshall(self,prefix,md,fid):    # {{{
     77                yts=md.constants.yts
     78                if yts!=365.2422*24.*3600.:
     79                        print('WARNING: value of yts for MISMIP+ runs different from ISSM default!')
    6580
    66         if 'BalancethicknessAnalysis' in analyses:
    67 
    68             md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    69             md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
    70             md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
    71             md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
    72 
    73         if 'ThermalAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.isthermal==0):
    74 
    75             md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
    76             md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
    77             md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
    78             md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
    79             md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0)
    80         return md
     81                WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
     82                WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     83                WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     84                WriteData(fid,prefix,'object',self,'fieldname','meltrate_factor','format','Double','scale',1./yts)
     85                WriteData(fid,prefix,'object',self,'fieldname','threshold_thickness','format','Double')
     86                WriteData(fid,prefix,'object',self,'fieldname','upperdepth_melt','format','Double')
    8187    # }}}
    82     def marshall(self,prefix,md,fid):    # {{{
    83 
    84         yts=md.constants.yts
    85         if yts!=365.2422*24.*3600.:
    86             print('WARNING: value of yts for MISMIP+ runs different from ISSM default!')
    87 
    88         WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
    89         WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    90         WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    91         WriteData(fid,prefix,'object',self,'fieldname','meltrate_factor','format','Double','scale',1./yts)
    92         WriteData(fid,prefix,'object',self,'fieldname','threshold_thickness','format','Double')
    93         WriteData(fid,prefix,'object',self,'fieldname','upperdepth_melt','format','Double')
    94 
    95     # }}}
  • issm/trunk-jpl/src/py3/classes/model.py

    r23670 r23709  
    218218        # }}}
    219219        def checkmessage(self,string):    # {{{
    220                 print("model not consistent: ", string)
     220                print(("model not consistent: ", string))
    221221                self.private.isconsistent=False
    222222                return self
     
    419419                        md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity)[0]
    420420                        segments=contourenvelope(md2)
    421                         md2.mesh.vertexonboundary=np.zeros(numberofvertices2/md2.mesh.numberoflayers,bool)
     421                        md2.mesh.vertexonboundary=np.zeros(int(numberofvertices2/md2.mesh.numberoflayers),bool)
    422422                        md2.mesh.vertexonboundary[segments[:,0:2]-1]=True
    423423                        md2.mesh.vertexonboundary=np.tile(md2.mesh.vertexonboundary,md2.mesh.numberoflayers)
     
    449449                if md1.results:
    450450                        md2.results=results()
    451                         for solutionfield,field in md1.results.__dict__.items():
     451                        for solutionfield,field in list(md1.results.__dict__.items()):
    452452                                if   isinstance(field,list):
    453453                                        setattr(md2.results,solutionfield,[])
     
    458458                                                        fieldr=getattr(md2.results,solutionfield)[i]
    459459                                                        #get subfields
    460                                                         for solutionsubfield,subfield in fieldi.__dict__.items():
     460                                                        for solutionsubfield,subfield in list(fieldi.__dict__.items()):
    461461                                                                if   np.size(subfield)==numberofvertices1:
    462462                                                                        setattr(fieldr,solutionsubfield,subfield[pos_node])
     
    472472                                                fieldr=getattr(md2.results,solutionfield)
    473473                                                #get subfields
    474                                                 for solutionsubfield,subfield in field.__dict__.items():
     474                                                for solutionsubfield,subfield in list(field.__dict__.items()):
    475475                                                        if   np.size(subfield)==numberofvertices1:
    476476                                                                setattr(fieldr,solutionsubfield,subfield[pos_node])
     
    482482                #OutputDefinitions fields
    483483                if md1.outputdefinition.definitions:
    484                         for solutionfield,field in md1.outputdefinition.__dict__.items():
     484                        for solutionfield,field in list(md1.outputdefinition.__dict__.items()):
    485485                                if isinstance(field,list):
    486486                                        #get each definition
     
    489489                                                        fieldr=getattr(md2.outputdefinition,solutionfield)[i]
    490490                                                        #get subfields
    491                                                         for solutionsubfield,subfield in fieldi.__dict__.items():
     491                                                        for solutionsubfield,subfield in list(fieldi.__dict__.items()):
    492492                                                                if   np.size(subfield)==numberofvertices1:
    493493                                                                        setattr(fieldr,solutionsubfield,subfield[pos_node])
     
    834834                #OutputDefinitions
    835835                if md.outputdefinition.definitions:
    836                         for solutionfield,field in md.outputdefinition.__dict__.items():
     836                        for solutionfield,field in list(md.outputdefinition.__dict__.items()):
    837837                                if isinstance(field,list):
    838838                                        #get each definition
     
    841841                                                        fieldr=getattr(md.outputdefinition,solutionfield)[i]
    842842                                                        #get subfields
    843                                                         for solutionsubfield,subfield in fieldi.__dict__.items():
     843                                                        for solutionsubfield,subfield in list(fieldi.__dict__.items()):
    844844                                                                if   np.size(subfield)==md.mesh.numberofvertices:
    845845                                                                        setattr(fieldr,solutionsubfield,project2d(md,subfield,1))
  • issm/trunk-jpl/src/py3/classes/organizer.py

    r23670 r23709  
    66from savevars import savevars
    77from model import model
    8 from dbm import whichdb
     8from dbm.ndbm import whichdb
    99import MatlabFuncs as m
    1010
     
    8686                if os.path.exists(path):
    8787                        struc=loadvars(path)
    88                         name=name=[key for key in struc.keys()]
     88                        name=name=[key for key in list(struc.keys())]
    8989                        md=struc.name[0]
    9090                else:
     
    115115                                raise IOError("Could find neither '%s' nor '%s'" % (path,path2))
    116116                        else:
    117                                 print("--> Branching '%s' from trunk '%s'" % (self.prefix,self.trunkprefix))
     117                                print(("--> Branching '%s' from trunk '%s'" % (self.prefix,self.trunkprefix)))
    118118                                md=loadmodel(path2)
    119119                                return md
     
    142142                if 0 in self.requestedsteps:
    143143                        if self._currentstep==1:
    144                                 print("   prefix: %s" % self.prefix)
    145                         print("   step #%i : %s" % (self.steps[self._currentstep-1]['id'],self.steps[self._currentstep-1]['string']))
     144                                print(("   prefix: %s" % self.prefix))
     145                        print(("   step #%i : %s" % (self.steps[self._currentstep-1]['id'],self.steps[self._currentstep-1]['string'])))
    146146
    147147                #Ok, now if _currentstep is a member of steps, return true
    148148                if self._currentstep in self.requestedsteps:
    149                         print("\n   step #%i : %s\n" % (self.steps[self._currentstep-1]['id'],self.steps[self._currentstep-1]['string']))
     149                        print(("\n   step #%i : %s\n" % (self.steps[self._currentstep-1]['id'],self.steps[self._currentstep-1]['string'])))
    150150                        bool=True
    151151
     
    167167                else:
    168168                        name=os.path.join(self.repository,name)
    169                 print("saving model as: '%s'" % name)
     169                print(("saving model as: '%s'" % name))
    170170
    171171                #check that md is a model
  • issm/trunk-jpl/src/py3/classes/pairoptions.py

    r23689 r23709  
    3030                if self.list:
    3131                        s+="   list: ({}x{}) \n\n".format(len(self.list),2)
    32                         for item in self.list.items():
     32                        for item in list(self.list.items()):
    3333                                #if   isinstance(item[1],str):
    3434                                s+="     field: {} value: '{}'\n".format((item[0],item[1]))
     
    5555                        else:
    5656                                #option is not a string, ignore it
    57                                 print("WARNING: option number {} is not a string and will be ignored.".format(i+1))
     57                                print(("WARNING: option number {} is not a string and will be ignored.".format(i+1)))
    5858        # }}}
    5959        def addfield(self,field,value):    # {{{
     
    6161                if isinstance(field,str):
    6262                        if field in self.list:
    63                                 print("WARNING: field '{}' with value={} exists and will be overwritten with value={}.".format(field,str(self.list[field]),str(value)))
     63                                print(("WARNING: field '{}' with value={} exists and will be overwritten with value={}.".format(field,str(self.list[field]),str(value))))
    6464                        self.list[field] = value
    6565        # }}}
     
    7272        def AssignObjectFields(self,obj2):    # {{{
    7373                """ASSIGNOBJECTFIELDS - assign object fields from options"""
    74                 for item in self.list.items():
     74                for item in list(self.list.items()):
    7575                        if item[0] in dir(obj2):
    7676                                setattr(obj2,item[0],item[1])
    7777                        else:
    78                                 print("WARNING: field '%s' is not a property of '%s'." % (item[0],type(obj2)))
     78                                print(("WARNING: field '%s' is not a property of '%s'." % (item[0],type(obj2))))
    7979                return obj2
    8080        # }}}
     
    150150                        #warn user if requested
    151151                        if warn:
    152                                 print("removefield info: option '%s' has been removed from the list of options." % field)
     152                                print(("removefield info: option '%s' has been removed from the list of options." % field))
    153153        # }}}
    154154        def marshall(self,md,fid,firstindex):    # {{{
  • issm/trunk-jpl/src/py3/classes/plotoptions.py

    r23691 r23709  
    2323                if self.list:
    2424                        s+="    list: (%ix%i)\n" % (len(self.list),2)
    25                         for item in self.list.items():
     25                        for item in list(self.list.items()):
    2626                                #s+="   options of plot number %i\n" % item
    2727                                if   isinstance(item[1],str):
     
    5050                        else:
    5151                                #option is not a string, ignore it
    52                                 print("WARNING: option number %d is not a string and will be ignored." % (i+1))
     52                                print(("WARNING: option number %d is not a string and will be ignored." % (i+1)))
    5353
    5454                #get figure number
     
    125125                                                j=j+1
    126126                                if j+1>numberofplots:
    127                                         print("WARNING: too many instances of '%s' in options" % rawlist[i][0])
     127                                        print(("WARNING: too many instances of '%s' in options" % rawlist[i][0]))
    128128        #}}}
  • issm/trunk-jpl/src/py3/classes/qmu/@dakota_method/dakota_method.py

    r23677 r23709  
    11#move this later
    22from helpers import *
     3
     4from MatlabFuncs import *
    35import numpy as np
    46
     
    4446
    4547        def __init__(self,*args):
    46                 self.method              = ''
    47                 self.type                        = ''
    48                 self.variables = []
    49                 self.lcspec              = []
    50                 self.responses = []
    51                 self.ghspec              = []
     48                self.method   =''
     49                self.type     =''
     50                self.variables=[]
     51                self.lcspec   =[]
     52                self.responses=[]
     53                self.ghspec   =[]
    5254                #properites
    53                 self.params              = struct()
     55                self.params   =struct()
    5456
    5557        @staticmethod
     
    7577                        #given argument was a way of constructing a method
    7678                        else:
    77                                 mlist=[
    78                                         'dot_bfgs',
    79                                         'dot_frcg',
    80                                         'dot_mmfd',
    81                                         'dot_slp',
    82                                         'dot_sqp',
    83                                         'npsol_sqp',
    84                                         'conmin_frcg',
    85                                         'conmin_mfd',
    86                                         'optpp_cg',
    87                                         'optpp_q_newton',
    88                                         'optpp_fd_newton',
    89                                         'optpp_newton',
    90                                         'optpp_pds',
    91                                         'asynch_pattern_search',
    92                                         'coliny_cobyla',
    93                                         'coliny_direct',
    94                                         'coliny_ea',
    95                                         'coliny_pattern_search',
    96                                         'coliny_solis_wets',
    97                                         'ncsu_direct',
    98                                         'surrogate_based_local',
    99                                         'surrogate_based_global',
    100                                         'moga',
    101                                         'soga',
    102                                         'nl2sol',
    103                                         'nlssol_sqp',
    104                                         'optpp_g_newton',
    105                                         'nond_sampling',
    106                                         'nond_local_reliability',
    107                                         'nond_global_reliability',
    108                                         'nond_polynomial_chaos',
    109                                         'nond_stoch_collocation',
    110                                         'nond_evidence',
    111                                         'dace',
    112                                         'fsu_quasi_mc',
    113                                         'fsu_cvt',
    114                                         'vector_parameter_study',
    115                                         'list_parameter_study',
    116                                         'centered_parameter_study',
    117                                         'multidim_parameter_study',
    118                                         'bayes_calibration']
     79                                mlist=['dot_bfgs',
     80                                                         'dot_frcg',
     81                                                         'dot_mmfd',
     82                                                         'dot_slp',
     83                                                         'dot_sqp',
     84                                                         'npsol_sqp',
     85                                                         'conmin_frcg',
     86                                                         'conmin_mfd',
     87                                                         'optpp_cg',
     88                                                         'optpp_q_newton',
     89                                                         'optpp_fd_newton',
     90                                                         'optpp_newton',
     91                                                         'optpp_pds',
     92                                                         'asynch_pattern_search',
     93                                                         'coliny_cobyla',
     94                                                         'coliny_direct',
     95                                                         'coliny_ea',
     96                                                         'coliny_pattern_search',
     97                                                         'coliny_solis_wets',
     98                                                         'ncsu_direct',
     99                                                         'surrogate_based_local',
     100                                                         'surrogate_based_global',
     101                                                         'moga',
     102                                                         'soga',
     103                                                         'nl2sol',
     104                                                         'nlssol_sqp',
     105                                                         'optpp_g_newton',
     106                                                         'nond_sampling',
     107                                                         'nond_local_reliability',
     108                                                         'nond_global_reliability',
     109                                                         'nond_polynomial_chaos',
     110                                                         'nond_stoch_collocation',
     111                                                         'nond_evidence',
     112                                                         'dace',
     113                                                         'fsu_quasi_mc',
     114                                                         'fsu_cvt',
     115                                                         'vector_parameter_study',
     116                                                         'list_parameter_study',
     117                                                         'centered_parameter_study',
     118                                                         'multidim_parameter_study',
     119                                                         'bayes_calibration']
    119120
    120121                                mlist2=[]
     
    122123                                        if strncmpi(method,mlist[i],len(method)):
    123124                                                mlist2.append(mlist[i])
    124 
    125                                 #  check for a unique match in the list of methods
    126 
     125                                                #  check for a unique match in the list of methods
    127126                                l = len(mlist2)
    128127                                if l == 0:
     
    134133
    135134                                #  assign the default values for the method
     135                          # switch dm.method
    136136                                if dm.method in ['dot_bfgs','dot_frcg']:
    137137                                        dm.type     ='dot'
    138                                         dm.variables=['continuous_design','continuous_state']
     138                                        dm.variables=['continuous_design',
     139                                                                                                'continuous_state']
    139140                                        dm.lcspec   =[]
    140141                                        dm.responses=['objective_function']
     
    151152                                elif dm.method in ['dot_mmfd','dot_slp','dot_sqp']:
    152153                                        dm.type     ='dot'
    153                                         dm.variables=['continuous_design','continuous_state']
     154                                        dm.variables=['continuous_design',
     155                                                                                                'continuous_state']
    154156                                        dm.lcspec   =['linear_inequality_constraint',
    155157                                                                                                'linear_equality_constraint']
     
    236238                                        dm.params.max_step=1000.
    237239                                        dm.params.gradient_tolerance=1.0e-4
    238                                 elif dm.method in ['optpp_q_newton','optpp_fd_newton','optpp_newton']:
     240
     241                                elif dm.method in ['optpp_q_newton',
     242                                                                                                         'optpp_fd_newton',
     243                                                                                                         'optpp_newton']:
    239244                                        dm.type     ='optpp'
    240245                                        dm.variables=['continuous_design',
     
    455460                                        dm.params.vol_boxsize_limit=1.0e-8
    456461
    457                                 # elif dm.method in ['surrogate_based_local',
    458                                 #                                                                        'surrogate_based_global']:
     462                                        #if dm.method in ['surrogate_based_local',
     463                                        #'surrogate_based_global']:
     464
    459465                                elif dm.method == 'moga':
    460466                                        dm.type     ='jega'
     
    501507                                        dm.params.postprocessor_type=False
    502508                                        dm.params.orthogonal_distance=[0.01]
     509
    503510                                elif dm.method == 'soga':
    504511                                        dm.type     ='jega'
     
    563570                                        dm.params.covariance=0
    564571                                        dm.params.regression_stressbalances=False
     572
    565573                                elif dm.method == 'nlssol_sqp':
    566574                                        dm.type     ='lsq'
     
    619627                                        dm.responses=['response_function']
    620628                                        dm.ghspec   =[]
    621                                         #not documented, but apparently works
     629                                        #                               not documented, but apparently works
    622630                                        dm.params.output=False
    623631                                        dm.params.seed=False
     
    658666                                        dm.responses=['response_function']
    659667                                        dm.ghspec   =['grad']
    660                                         #not documented, but may work
     668                                        #                               not documented, but may work
    661669                                        dm.params.output=False
    662670                                        dm.params.x_gaussian_process=False
     
    860868
    861869                                else:
    862                                         raise RuntimeError('Unimplemented method: '+str(dm.method)+'.')
     870                                        raise RuntimeError('Unimplemented method: {}.'.format(dm.method))
    863871
    864872                #  if more than one argument, issue warning
  • issm/trunk-jpl/src/py3/classes/qmu/@dakota_method/dmeth_params_set.py

    r23677 r23709  
    2222
    2323        return dm
    24    
    25 
    26 
    27 
  • issm/trunk-jpl/src/py3/classes/qmu/@dakota_method/dmeth_params_write.py

    r23677 r23709  
    11from dakota_method import *
     2from MatlabFuncs import *
    23from IssmConfig import *
    34
     
    2122        #  unfortunately this prevents merely looping through the fields
    2223        #  of the parameters structure.
     24
    2325        #  write method-indepent controls
     26
    2427        # param_write(fid,sbeg,'id_method','                = ','\n',dm.params)
    2528        # param_write(fid,sbeg,'model_pointer','            = ','\n',dm.params)
    2629
    2730        #  write method-depent controls
     31
     32        #switch dm.type
    2833        if dm.type == 'dot':
    2934                param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params)
     
    95100                                raise RuntimeError('#s'' method must have only one algorithm.',
    96101                                                                                                         dm.method)
    97                                 param_write(fid,sbeg,'value_based_line_search','','\n',dm.params)
    98                                 param_write(fid,sbeg,'gradient_based_line_search','','\n',dm.params)
    99                                 param_write(fid,sbeg,'trust_region','','\n',dm.params)
    100                                 param_write(fid,sbeg,'tr_pds','','\n',dm.params)
    101                                 param_write(fid,sbeg,'max_step','               = ','\n',dm.params)
    102                                 param_write(fid,sbeg,'gradient_tolerance','     = ','\n',dm.params)
    103                                 param_write(fid,sbeg,'merit_function','         = ','\n',dm.params)
    104                                 param_write(fid,sbeg,'central_path','           = ','\n',dm.params)
    105                                 param_write(fid,sbeg,'steplength_to_boundary',' = ','\n',dm.params)
    106                                 param_write(fid,sbeg,'centering_parameter','    = ','\n',dm.params)
     102                        param_write(fid,sbeg,'value_based_line_search','','\n',dm.params)
     103                        param_write(fid,sbeg,'gradient_based_line_search','','\n',dm.params)
     104                        param_write(fid,sbeg,'trust_region','','\n',dm.params)
     105                        param_write(fid,sbeg,'tr_pds','','\n',dm.params)
     106                        param_write(fid,sbeg,'max_step','               = ','\n',dm.params)
     107                        param_write(fid,sbeg,'gradient_tolerance','     = ','\n',dm.params)
     108                        param_write(fid,sbeg,'merit_function','         = ','\n',dm.params)
     109                        param_write(fid,sbeg,'central_path','           = ','\n',dm.params)
     110                        param_write(fid,sbeg,'steplength_to_boundary',' = ','\n',dm.params)
     111                        param_write(fid,sbeg,'centering_parameter','    = ','\n',dm.params)
    107112
    108113                elif dm.method == 'optpp_pds':
    109                         param_write(fid,sbeg,'search_scheme_size',' = ','\n',dm.params)
     114                        param_write(fid,sbeg,'search_scheme_size',' = ','\n',dm.params)
    110115
    111116                else:
     
    137142                param_write(fid,sbeg,'output',' ','\n',dm.params)
    138143                param_write(fid,sbeg,'scaling','','\n',dm.params)
    139 
    140144                param_write(fid,sbeg,'show_misc_options','','\n',dm.params)
    141145                param_write(fid,sbeg,'misc_options','      = ','\n',dm.params)
     
    246250                        param_write(fid,sbeg,'niching_type','        = ','\n',dm.params)
    247251                        if not isempty(dm.params.radial) and not isempty(dm.params.distance):
    248                                 raise RuntimeError('#s'' method must have only one niching distance.',dm.method)
    249 
     252                                raise RuntimeError('#s'' method must have only one niching distance.',
     253                                                                                                         dm.method)
    250254                        param_write(fid,sbeg,'radial','              = ','\n',dm.params)
    251255                        param_write(fid,sbeg,'distance','            = ','\n',dm.params)
     
    266270                else:
    267271                        raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.')
    268 
    269272
    270273        elif dm.type == 'lsq':
     
    310313                                        dm.params.trust_region +
    311314                                        dm.params.tr_pds > 1):
    312                                 raise RuntimeError('#s'' method must have only one algorithm.',dm.method)
     315                                raise RuntimeError('#s'' method must have only one algorithm.',
     316                                                                                                         dm.method)
    313317
    314318                        param_write(fid,sbeg,'value_based_line_search','','\n',dm.params)
     
    348352                        if type(dm.params.mpp_search) == str:
    349353                                if (dm.params.sqp +dm.params.nip > 1):
    350                                         raise RuntimeError('#s'' method must have only one algorithm.',dm.method)
     354                                        raise RuntimeError('#s'' method must have only one algorithm.',
     355                                                                                                                 dm.method)
     356
    351357                                param_write(fid,sbeg,'sqp','','\n',dm.params)
    352358                                param_write(fid,sbeg,'nip','','\n',dm.params)
     
    360366                elif dm.method == 'nond_global_reliability':
    361367                        if (dm.params.x_gaussian_process + dm.params.u_gaussian_process != 1):
    362                                 raise RuntimeError('#s'' method must have one and only one algorithm.',dm.method)
     368                                raise RuntimeError('#s'' method must have one and only one algorithm.',
     369                                                                                                         dm.method)
     370
    363371                        param_write(fid,sbeg,'x_gaussian_process','','\n',dm.params)
    364372                        param_write(fid,sbeg,'u_gaussian_process','','\n',dm.params)
     
    399407                        raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.')
    400408
     409
    401410        elif dm.type == 'dace':
    402411                #switch dm.method
    403412                if dm.method == 'dace':
    404413                        if (dm.params.grid + dm.params.random + dm.params.oas + dm.params.lhs + dm.params.oa_lhs + dm.params.box_behnken + dm.params.central_composite != 1):
    405                                 raise RuntimeError('#s'' method must have one and only one algorithm.',dm.method)
     414                                raise RuntimeError('#s'' method must have one and only one algorithm.',
     415                                                                                                         dm.method)
     416
    406417                        param_write(fid,sbeg,'grid','','\n',dm.params)
    407418                        param_write(fid,sbeg,'random','','\n',dm.params)
     
    421432                        if (dm.params.halton + dm.params.hammersley != 1):
    422433                                raise RuntimeError('#s'' method must have one and only one sequence type.',dm.method)
     434
    423435                        param_write(fid,sbeg,'halton','','\n',dm.params)
    424436                        param_write(fid,sbeg,'hammersley','','\n',dm.params)
     
    445457                        raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.')
    446458
    447 
    448459        elif dm.type == 'param':
    449460                param_write(fid,sbeg,'output',' ','\n',dm.params)
     
    457468                                param_write(fid,sbeg,'step_length',' = ','\n',dm.params)
    458469                                param_write(fid,sbeg,'num_steps','   = ','\n',dm.params)
     470
    459471                        elif not isempty(dm.params.step_vector):
    460472                                param_write(fid,sbeg,'step_vector',' = ','\n',dm.params)
     
    474486                        raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.')
    475487
     488
    476489        elif dm.type == 'bayes':
    477490                #switch dm.method
    478491                if dm.method == 'bayes_calibration':
    479                         # if (dm.params.queso +
    480                         #    dm.params.dream +
    481                         #        dm.params.gpmsa ~= 1)
    482                         #    raise RuntimeError('''#s'' method must have one and only one bayes type. YOU SUCK',
    483                         #       dm.method)
    484                         #
     492                # if (dm.params.queso +
     493                #    dm.params.dream +
     494                #        dm.params.gpmsa ~= 1)
     495                #    raise RuntimeError('''#s'' method must have one and only one bayes type. YOU SUCK',
     496                #       dm.method)
     497                #
    485498                        param_write(fid,sbeg,'queso','','\n',dm.params)
    486499                        param_write(fid,sbeg,'dream','','\n',dm.params)
     
    501514        #  loop through each parameter field in the structure
    502515        fnames=fieldnames(params)
    503 
    504516        for i in range(np.size(fnames)):
    505517                param_write(fidi,sbeg,fnames[i],smid,s,params)
     
    517529                return
    518530        elif isempty(vars(params)[pname]):
    519                 print('Warning: param_write:param_empty: Parameter '+pname+' requires input of type '+type(vars(params)[pname])+'.')
     531                print('Warning: param_write:param_empty: Parameter {} requires input of type {}.'.format(pname,type(vars(params)[pname])))
    520532                return
    521533
     
    523535        if type(vars(params)[pname]) == bool:
    524536                fidi.write(sbeg+str(pname)+s)
     537
    525538        elif type(vars(params)[pname]) in [int,float]:
    526539                fidi.write(sbeg+str(pname)+smid+str(vars(params)[pname])+s)
     540
    527541        elif type(vars(params)[pname]) == list:
    528542                fidi.write(sbeg+str(pname)+smid+str(vars(params)[pname][0]))
     
    531545
    532546                fidi.write(s)
     547
    533548        elif type(vars(params)[pname]) == str:
    534549                fidi.write(sbeg+str(pname)+smid+str(vars(params)[pname])+s)
     550
    535551        else:
    536                 print('Warning: param_write:param_unrecog: Parameter '+pname+' is of unrecognized type '+type(vars(params)[pname])+'.')
     552                print('Warning: param_write:param_unrecog: Parameter {} is of unrecognized type {}.'.format(pname,type(vars(params)[pname])))
    537553                return
  • issm/trunk-jpl/src/py3/classes/qmu/calibration_function.py

    r23677 r23709  
    11import numpy as np
    2 from rlist_write import rlist_write
     2from rlist_write import *
     3from MatlabArray import *
    34
    45class calibration_function(object):
     
    7071                string += '         scale: '+str(self.scale) + '\n'
    7172                string += '        weight: '+str(self.weight) + '\n'
    72 
    7373                return string
    7474
    7575        # from here on, cf is either a single, or a 1d vector of, calibration_function
    76 
    7776        @staticmethod
    7877        def prop_desc(cf,dstr):
     
    9695
    9796                desc = allempty(desc)
    98 
    9997                return desc
    10098
  • issm/trunk-jpl/src/py3/classes/qmu/least_squares_term.py

    r23677 r23709  
    11import numpy as np
    2 from rlist_write import rlist_write
     2from rlist_write import *
     3from MatlabArray import *
    34
    45class least_squares_term(object):
     
    5859                                        for i in range(np.size(lst)):
    5960                                                if (np.size(args[2]) > 1):
    60                                                         lst[i].scale      = args[2][i]
     61                                                        lst[i].scale = args[2][i]
    6162                                                else:
    62                                                         lst[i].scale      = args[2]
     63                                                        lst[i].scale = args[2]
    6364
    6465                                if (nargin >= 4):
    6566                                        for i in range(np.size(lst)):
    6667                                                if (np.size(args[3]) > 1):
    67                                                         lst[i].weight     = args[3][i]
     68                                                        lst[i].weight = args[3][i]
    6869                                                else:
    69                                                         lst[i].weight     = args[3]
     70                                                        lst[i].weight = args[3]
    7071
    7172                                if (nargin > 4):
     
    8283                string += '         scale: '+str(self.scale) + '\n'
    8384                string += '        weight: '+str(self.weight) + '\n'
    84 
    8585                return string
    8686
     
    100100
    101101                desc = allempty(desc)
    102 
    103102                return desc
    104103
     
    113112
    114113                stype = allequal(stype,'none')
    115 
    116114                return stype
    117115
     
    126124
    127125                scale = allequal(scale,1.)
    128 
    129126                return scale
    130127
     
    139136
    140137                weight = allequal(weight,1.)
    141 
    142138                return weight
    143139
  • issm/trunk-jpl/src/py3/classes/qmu/normal_uncertain.py

    r23677 r23709  
    11import numpy as np
     2#from vlist_write import *
     3from MatlabArray import *
    24
    35class normal_uncertain(object):
     
    128130
    129131                upper = allequal(upper,-np.inf)
    130 
    131132                return upper
    132133
     
    173174                nuv = [struc_class(i,'normal_uncertain','nuv') for i in dvar]
    174175
     176                # possible namespace pollution, the above import seems not to work
     177                from vlist_write import vlist_write
    175178                # write variables
    176179                vlist_write(fidi,'normal_uncertain','nuv',nuv)
  • issm/trunk-jpl/src/py3/classes/qmu/objective_function.py

    r23677 r23709  
    11import numpy as np
    2 from rlist_write import rlist_write
     2from rlist_write import *
     3from MatlabArray import *
    34
    45class objective_function(object):
     
    2930        def objective_function(*args):
    3031                nargin = len(args)
     32
    3133                #  create a default object
    3234                if nargin == 0:
     
    4042                                shapec = array_size(*args[0:min(nargin,4)])
    4143                                of = [objective_function() for i in range(shapec[0]) for j in range(shapec[1])]
     44
    4245                                for i in range(np.size(of)):
    4346                                        if (np.size(args[0]) > 1):
     
    7275                return of
    7376
     77
    7478        def __repr__(self):
    7579                #  display the object
     
    8084                string += '         scale: '  +str(self.scale) + '\n'
    8185                string += '        weight: '  +str(self.weight) + '\n'
    82 
    8386                return string
    8487
     
    104107
    105108                desc = allempty(desc)
    106 
    107109                return desc
    108110
     
    132134
    133135                weight = allequal(weight,1.)
    134 
    135136                return weight
    136137
     
    145146
    146147                stype = allequal(stype,'none')
    147 
    148148                return stype
    149149
     
    158158
    159159                scale = allequal(scale,1.)
    160 
    161160                return scale
    162161
  • issm/trunk-jpl/src/py3/classes/qmu/response_function.py

    r23677 r23709  
    11import numpy as np
    2 from rlist_write import *
    3 from rlev_write import rlev_write
     2#from rlist_write import *
     3from rlev_write import *
     4from MatlabArray import *
    45
    56#move this later
     
    3536        @staticmethod
    3637        def response_function(*args):
     38
    3739                nargin = len(args)
    3840                # create a default object
     
    7577                return rf
    7678
    77 
    7879        def __repr__(self):
    7980                #  display the object
     
    109110
    110111                desc = allempty(desc)
    111 
    112112                return desc
    113113
     
    149149
    150150                respl = empty_nd_list(np.size(rf))
    151 
    152151                probl = empty_nd_list(np.size(rf))
    153 
    154152                rell = empty_nd_list(np.size(rf))
    155 
    156153                grell = empty_nd_list(np.size(rf))
    157154
     
    166163                rell  = allempty(rell)
    167164                grell = allempty(grell)
    168 
    169165                return [respl,probl,rell,grell]
    170166
  • issm/trunk-jpl/src/py3/classes/qmu/uniform_uncertain.py

    r23677 r23709  
    11import numpy as np
    2 from vlist_write import vlist_write
     2#from vlist_write import *
    33from MatlabArray import *
    44
     
    2828        def uniform_uncertain(*args):
    2929                nargin = len(args)
     30
    3031                # create a default object
    3132                if nargin == 0:
     
    153154                # collect only the variables of the appropriate class
    154155                uuv = [struc_class(i,'uniform_uncertain','uuv') for i in dvar]
    155 
     156                # possible namespace pollution, the above import seems not to work
     157                from vlist_write import vlist_write
    156158                # write variables
    157159                vlist_write(fidi,'uniform_uncertain','uuv',uuv)
  • issm/trunk-jpl/src/py3/classes/results.py

    r23670 r23709  
    2525                        s+="%s\n" % fielddisplay(self,'SolutionType',"solution type")
    2626
    27                 for name in self.__dict__.keys():
     27                for name in list(self.__dict__.keys()):
    2828                        if name not in ['step','time','SolutionType','errlog','outlog']:
    2929                                if   isinstance(getattr(self,name),list):
  • issm/trunk-jpl/src/py3/classes/rifts.py

    r23670 r23709  
    4747                                md.checkmessage("model should be processed for rifts (run meshprocessrifts)!")
    4848                        for i,rift in enumerate(self.riftstruct):
    49                                 md = checkfield(md,'fieldname',"rifts.riftstruct[%d]['fill']" % i,'values',['Water','Air','Ice','Melange',0,1,2,3])
     49                                md = checkfield(md,'fieldname',"rifts.riftstruct[{}]['fill']".format(i),'values',['Water','Air','Ice','Melange',0,1,2,3])
    5050                else:
    5151                        if self.riftstruct and np.any(np.logical_not(isnans(self.riftstruct))):
  • issm/trunk-jpl/src/py3/classes/toolkits.py

    r23670 r23709  
    3535        def __repr__(self):    # {{{
    3636                s ="List of toolkits options per analysis:\n\n"
    37                 for analysis in vars(self).keys():
     37                for analysis in list(vars(self).keys()):
    3838                        s+="%s\n" % fielddisplay(self,analysis,'')
    3939
     
    5656        # }}}
    5757        def checkconsistency(self,md,solution,analyses):    # {{{
    58                 for analysis in vars(self).keys():
     58                for analysis in list(vars(self).keys()):
    5959                        if not getattr(self,analysis):
    6060                                md.checkmessage("md.toolkits.%s is empty" % analysis)
     
    8383
    8484                #start writing options
    85                 for analysis in vars(self).keys():
     85                for analysis in list(vars(self).keys()):
    8686                        options=getattr(self,analysis)
    8787
     
    8989                        fid.write("\n+%s\n" % analysis)    #append a + to recognize it's an analysis enum
    9090                        #now, write options
    91                         for optionname,optionvalue in options.items():
     91                        for optionname,optionvalue in list(options.items()):
    9292
    9393                                if not optionvalue:
  • issm/trunk-jpl/src/py3/classes/verbose.py

    r23670 r23709  
    6767                        #Cast to logicals
    6868                        listproperties=vars(self)
    69                         for fieldname,fieldvalue in listproperties.items():
     69                        for fieldname,fieldvalue in list(listproperties.items()):
    7070                                if isinstance(fieldvalue,bool) or isinstance(fieldvalue,(int,float)):
    7171                                        setattr(self,fieldname,bool(fieldvalue))
  • issm/trunk-jpl/src/py3/consistency/checkfield.py

    r23689 r23709  
    11import numpy as np
    22import os
     3from re import findall,split
    34from pairoptions import pairoptions
    45from operator import attrgetter
     
    4243        else:
    4344                fieldname=options.getfieldvalue('fieldname')
    44 
    45                 field=attrgetter(fieldname)(md)
     45                fieldprefix=split(r'\[(.*?)\]',fieldname)[0]
     46                fieldindexes=findall(r'\[(.*?)\]',fieldname)
     47                field=attrgetter(fieldprefix)(md)
     48                for index in fieldindexes:
     49                        try:
     50                                field=field[index.strip("\'")]
     51                        except TypeError:
     52                                field=field[int(index)] #looking for an index and not a key
     53
     54# that works for py2
     55#               exec("field=md.{}".format(fieldname))
    4656#               exec("field=md.{}".format(fieldname),namespace)
     57
    4758
    4859        if isinstance(field,(bool,int,float)):
     
    135146        if options.exist('>='):
    136147                lowerbound = options.getfieldvalue('>=')
     148                if type(lowerbound) is str:
     149                        lowerbound=attrgetter(lowerbound)(md)
    137150                if np.size(lowerbound)>1: #checking elementwise
    138151                        if any(field<upperbound):
     
    153166        if options.exist('>'):
    154167                lowerbound=options.getfieldvalue('>')
     168                if type(lowerbound) is str:
     169                        lowerbound=attrgetter(lowerbound)(md)
    155170                if np.size(lowerbound)>1: #checking elementwise
    156171                        if any(field<=upperbound):
     
    172187        if options.exist('<='):
    173188                upperbound=options.getfieldvalue('<=')
     189                if type(upperbound) is str:
     190                        upperbound=attrgetter(upperbound)(md)
    174191                if np.size(upperbound)>1: #checking elementwise
    175192                        if any(field>upperbound):
     
    189206        if options.exist('<'):
    190207                upperbound=options.getfieldvalue('<')
     208                if type(upperbound) is str:
     209                        upperbound=attrgetter(upperbound)(md)
    191210                if np.size(upperbound)>1: #checking elementwise
    192211                        if any(field>=upperbound):
  • issm/trunk-jpl/src/py3/contrib/defleurian/netCDF/export_netCDF.py

    r23677 r23709  
    1212        if path.exists(filename):
    1313                print(('File {} allready exist'.format(filename)))
    14                 newname=input('Give a new name or "delete" to replace: ')
     14                newname=eval(input('Give a new name or "delete" to replace: '))
    1515                if newname=='delete':
    1616                        remove(filename)
  • issm/trunk-jpl/src/py3/contrib/defleurian/paraview/enveloppeVTK.py

    r23677 r23709  
    2828        if os.path.exists(filename):
    2929                print(('File {} allready exist'.format(filename)))
    30                 newname=input('Give a new name or "delete" to replace: ')
     30                newname=eval(input('Give a new name or "delete" to replace: '))
    3131                if newname=='delete':
    3232                        filelist = glob.glob(filename+'/*')
  • issm/trunk-jpl/src/py3/contrib/defleurian/paraview/enveloppeVTK_bleeding.py

    r23677 r23709  
    3232        if os.path.exists(filename):
    3333                print(('File {} allready exist'.format(filename)))
    34                 newname=input('Give a new name or "delete" to replace: ')
     34                newname=eval(input('Give a new name or "delete" to replace: '))
    3535                if newname=='delete':
    3636                        filelist = glob.glob(filename+'/*')
  • issm/trunk-jpl/src/py3/contrib/defleurian/paraview/exportVTK.py

    r23677 r23709  
    2828        if os.path.exists(filename):
    2929                print(('File {} allready exist'.format(filename)))
    30                 newname=input('Give a new name or "delete" to replace: ')
     30                newname=eval(input('Give a new name or "delete" to replace: '))
    3131                if newname=='delete':
    3232                        filelist = glob.glob(filename+'/*')
     
    193193                                                        for node in range(0,num_of_points):
    194194                                                                #paraview does not like NaN, replacing
    195                                                                 print(other_struct.__dict__[field][node])
     195                                                                print((other_struct.__dict__[field][node]))
    196196                                                                if np.isnan(other_struct.__dict__[field][node]):
    197197                                                                        fid.write('%e\n' % -9999.9999)
  • issm/trunk-jpl/src/py3/contrib/morlighem/bamg/YamsCall.py

    r23677 r23709  
    2929        #Compute Hessian
    3030        t1=time.time()
    31         print("%s" % '      computing Hessian...')
     31        print(("%s" % '      computing Hessian...'))
    3232        hessian=ComputeHessian(md.mesh.elements,md.mesh.x,md.mesh.y,field,'node')
    3333        t2=time.time()
    34         print("%s%d%s\n" % (' done (',t2-t1,' seconds)'))
     34        print(("%s%d%s\n" % (' done (',t2-t1,' seconds)')))
    3535
    3636        #Compute metric
    3737        t1=time.time()
    38         print("%s" % '      computing metric...')
     38        print(("%s" % '      computing metric...'))
    3939        metric=ComputeMetric(hessian,scale,epsilon,hmin,hmax,np.empty(0,int))
    4040        t2=time.time()
    41         print("%s%d%s\n" % (' done (',t2-t1,' seconds)'))
     41        print(("%s%d%s\n" % (' done (',t2-t1,' seconds)')))
    4242
    4343        #write files
    4444        t1=time.time()
    45         print("%s" % '      writing initial mesh files...')
     45        print(("%s" % '      writing initial mesh files...'))
    4646        np.savetxt('carre0.met',metric)
    4747
     
    8080        f.close()
    8181        t2=time.time()
    82         print("%s%d%s\n" % (' done (',t2-t1,' seconds)'))
     82        print(("%s%d%s\n" % (' done (',t2-t1,' seconds)')))
    8383
    8484        #call yams
    85         print("%s\n" % '      call Yams...')
     85        print(("%s\n" % '      call Yams...'))
    8686        if   m.ispc():
    8787                #windows
     
    9696        #plug new mesh
    9797        t1=time.time()
    98         print("\n%s" % '      reading final mesh files...')
     98        print(("\n%s" % '      reading final mesh files...'))
    9999        Tria=np.loadtxt('carre1.tria',int)
    100100        Coor=np.loadtxt('carre1.coor',float)
     
    107107        numberofelements2=md.mesh.numberofelements
    108108        t2=time.time()
    109         print("%s%d%s\n\n" % (' done (',t2-t1,' seconds)'))
     109        print(("%s%d%s\n\n" % (' done (',t2-t1,' seconds)')))
    110110
    111111        #display number of elements
    112         print("\n%s %i" % ('      inital number of elements:',numberofelements1))
    113         print("\n%s %i\n\n" % ('      new    number of elements:',numberofelements2))
     112        print(("\n%s %i" % ('      inital number of elements:',numberofelements1)))
     113        print(("\n%s %i\n\n" % ('      new    number of elements:',numberofelements2)))
    114114
    115115        #clean up:
  • issm/trunk-jpl/src/py3/coordsystems/gmtmask.py

    r23677 r23709  
    2121
    2222        if recursive:
    23                 print('             recursing: num vertices #'+str(lenlat))
     23                print(('             recursing: num vertices #'+str(lenlat)))
    2424        else:
    25                 print('gmtmask: num vertices #'+str(lenlat))
     25                print(('gmtmask: num vertices #'+str(lenlat)))
    2626       
    2727        #Check lat and long size is not more than 50,000 If so, recursively call gmtmask:
  • issm/trunk-jpl/src/py3/dev/issmversion.py

    r23670 r23709  
    1111
    1212print(' ')
    13 print(IssmConfig('PACKAGE_NAME')[0]+' Version '+IssmConfig('PACKAGE_VERSION')[0])
    14 print('(website: '+IssmConfig('PACKAGE_URL')[0]+' contact: '+IssmConfig('PACKAGE_BUGREPORT')[0]+')')
     13print((IssmConfig('PACKAGE_NAME')[0]+' Version '+IssmConfig('PACKAGE_VERSION')[0]))
     14print(('(website: '+IssmConfig('PACKAGE_URL')[0]+' contact: '+IssmConfig('PACKAGE_BUGREPORT')[0]+')'))
    1515print(' ')
    16 print('Build date: '+IssmConfig('PACKAGE_BUILD_DATE')[0])
     16print(('Build date: '+IssmConfig('PACKAGE_BUILD_DATE')[0]))
    1717print('Copyright (c) 2009-2018 California Institute of Technology')
    1818print(' ')
  • issm/trunk-jpl/src/py3/exp/expcoarsen.py

    r23670 r23709  
    2323                raise OSError("expcoarsen error message: file '%s' not found!" % oldfile)
    2424        if os.path.exists(newfile):
    25                 choice=input('A file ' + newfile + ' already exists, do you want to modify it? (y/n)')
     25                choice=eval(input('A file ' + newfile + ' already exists, do you want to modify it? (y/n)'))
    2626                if choice not in 'y':
    2727                        print('no modification done ... exiting')
  • issm/trunk-jpl/src/py3/geometry/NowickiProfile.py

    r23677 r23709  
    2828
    2929        #upstream of the GL
    30         for i in range(np.size(x) / 2):
     30        for i in range(int(np.size(x)/2)):
    3131                ss = np.roots([1, 4 * lamda * beta, 0, 0, 6 * lamda * ms * x[i]**2 +
    3232                                12 * lamda * q * x[i] - hg**4 - 4 * lamda * beta * hg**3])
     
    3838
    3939        #downstream of the GL
    40         for i in range(np.size(x) / 2, np.size(x)):
     40        for i in range(int(np.size(x)/2), int(np.size(x))):
    4141                h[i] = (x[i] / (4. * (delta+1) * q) + hg**(-2))**(-0.5) # ice thickness for ice shelf from (3.1)
    4242                b[i] = sea - h[i] * (1. / (1+delta))
  • issm/trunk-jpl/src/py3/io/loadmodel.py

    r23670 r23709  
    11from loadvars import loadvars
    2 from dbm import whichdb
     2from dbm.ndbm import whichdb
    33from netCDF4 import Dataset
    44
     
    2727        #recover model on file and name it md
    2828        struc=loadvars(path)
    29         name=[key for key in struc.keys()]
     29        name=[key for key in list(struc.keys())]
    3030        if len(name)>1:
    3131                raise IOError("loadmodel error message: file '%s' contains several variables. Only one model should be present." % path)
  • issm/trunk-jpl/src/py3/io/loadvars.py

    r23670 r23709  
    77from os import path
    88from collections import OrderedDict
    9 from dbm import whichdb
     9from dbm.ndbm import whichdb
    1010from model import *
    1111
     
    5757
    5858        if whichdb(filename):
    59                 print("Loading variables from file '%s'." % filename)
     59                print(("Loading variables from file '%s'." % filename))
    6060
    6161                my_shelf = shelve.open(filename,'r') # 'r' for read-only
    6262                if nvdict:
    63                         for name in nvdict.keys():
     63                        for name in list(nvdict.keys()):
    6464                                try:
    6565                                        nvdict[name] = my_shelf[name]
    66                                         print("Variable '%s' loaded." % name)
     66                                        print(("Variable '%s' loaded." % name))
    6767                                except KeyError:
    6868                                        value = None
    69                                         print("Variable '%s' not found." % name)
     69                                        print(("Variable '%s' not found." % name))
    7070
    7171                else:
    72                         for name in my_shelf.keys():
     72                        for name in list(my_shelf.keys()):
    7373                                nvdict[name] = my_shelf[name]
    74                                 print("Variable '%s' loaded." % name)
     74                                print(("Variable '%s' loaded." % name))
    7575
    7676                my_shelf.close()
  • issm/trunk-jpl/src/py3/io/savevars.py

    r19895 r23709  
    4646
    4747        if os.path.exists(filename):
    48                 print("Shelving variables to existing file '%s'." % filename)
     48                print(("Shelving variables to existing file '%s'." % filename))
    4949        else:
    50                 print("Shelving variables to new file '%s'." % filename)
     50                print(("Shelving variables to new file '%s'." % filename))
    5151
    5252        my_shelf = shelve.open(filename,'c') # 'c' for create if not exist, else 'n' for new
    5353
    54         for name,value in nvdict.items():
     54        for name,value in list(nvdict.items()):
    5555                try:
    5656                        my_shelf[name] = value
    57                         print("Variable '%s' shelved." % name)
     57                        print(("Variable '%s' shelved." % name))
    5858                except TypeError:
    59                         print("Variable '%s' not shelved." % name)
     59                        print(("Variable '%s' not shelved." % name))
    6060
    6161        my_shelf.close()
  • issm/trunk-jpl/src/py3/mech/thomasparams.py

    r23670 r23709  
    126126        pos=np.nonzero(np.abs((np.abs(a)-2.))<1.e-3)
    127127        if len(pos)>0:
    128                 print('Warning: ', len(pos), ' vertices have alpha within 1e-3 of -2')
     128                print(('Warning: ', len(pos), ' vertices have alpha within 1e-3 of -2'))
    129129        a[pos]=-2+1e-3
    130130
  • issm/trunk-jpl/src/py3/mesh/bamg.py

    r23670 r23709  
    572572
    573573        if num:
    574                 print("WARNING: %d points outside the domain outline have been removed" % num)
     574                print(("WARNING: %d points outside the domain outline have been removed" % num))
    575575
    576576        """
  • issm/trunk-jpl/src/py3/mesh/triangle.py

    r23670 r23709  
    3737        #Check that mesh was not already run, and warn user:
    3838        if md.mesh.numberofelements:
    39                 choice = input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')
     39                choice = eval(input('This model already has a mesh. Are you sure you want to go ahead? (y/n)'))
    4040                if not m.strcmp(choice,'y'):
    4141                        print('no meshing done ... exiting')
  • issm/trunk-jpl/src/py3/miscellaneous/fielddisplay.py

    r23670 r23709  
    6767                offset+='   '
    6868
    69                 for structure_field,sfield in field.items():
     69                for structure_field,sfield in list(field.items()):
    7070                        string+=parsedisplay(offset,str(structure_field),sfield,'')+'\n'
    7171
  • issm/trunk-jpl/src/py3/modules/MeshPartition.py

    r23677 r23709  
    1515'''
    1616        if md == None or numpartitions == None:
    17                 print(MeshPartition.__doc__)
     17                print((MeshPartition.__doc__))
    1818                raise RuntimeError('Wrong usage (see above)')
    1919
  • issm/trunk-jpl/src/py3/os/issmscpin.py

    r19895 r23709  
    4343                                raise OSError("issmscpin error message: could not find ISSM_DIR_WIN environment variable.")
    4444
    45                         username=input('Username: (quoted string) ')
    46                         key=input('Key: (quoted string) ')
     45                        username=eval(input('Username: (quoted string) '))
     46                        key=eval(input('Key: (quoted string) '))
    4747
    4848                        for package in packages:
  • issm/trunk-jpl/src/py3/os/issmscpout.py

    r19895 r23709  
    3636                                raise OSError("issmscpout error message: could not find ISSM_DIR_WIN environment variable.")
    3737
    38                         username=input('Username: (quoted string) ')
    39                         key=input('Key: (quoted string) ')
     38                        username=eval(input('Username: (quoted string) '))
     39                        key=eval(input('Key: (quoted string) '))
    4040
    4141                        for package in packages:
  • issm/trunk-jpl/src/py3/os/issmssh.py

    r23670 r23709  
    2929                                raise OSError("issmssh error message: could not find ISSM_DIR_WIN environment variable.")
    3030
    31                         username=input('Username: (quoted string) ')
    32                         key=input('Key: (quoted string) ')
     31                        username=eval(input('Username: (quoted string) '))
     32                        key=eval(input('Key: (quoted string) '))
    3333
    3434                        subprocess.call('%s/externalpackages/ssh/plink.exe -ssh -l "%s" -pw "%s" %s "%s"' % (ISSM_DIR,username,key,host,command),shell=True);
  • issm/trunk-jpl/src/py3/parameterization/setflowequation.py

    r23670 r23709  
    1111           'SIA','SSA','HO','L1L2','FS' and 'fill' are the possible options
    1212           that must be followed by the corresponding exp file or flags list
    13            It can either be a domain file (argus type, .exp extension), or an array of element flags. 
    14            If user wants every element outside the domain to be 
     13           It can either be a domain file (argus type, .exp extension), or an array of element flags.
     14           If user wants every element outside the domain to be
    1515           setflowequationd, add '~' to the name of the domain file (ex: '~HO.exp');
    1616           an empty string '' will be considered as an empty domain
     
    9696
    9797        #Then complete with NoneApproximation or the other model used if there is no FS
    98         if any(FSflag): 
     98        if any(FSflag):
    9999                if   any(HOflag):    #fill with HO
    100100                        HOflag[~FSflag]=True
     
    103103                        SSAflag[~FSflag]=True
    104104                        nodeonSSA[md.mesh.elements[np.where(SSAflag),:]-1]=True
    105                 else:    #fill with none 
     105                else:    #fill with none
    106106                        noneflag[np.where(~FSflag)]=True
    107107
     
    285285
    286286        return md
    287 
  • issm/trunk-jpl/src/py3/parameterization/setmask.py

    r23670 r23709  
    1010        SETMASK - establish boundaries between grounded and floating ice.
    1111
    12            By default, ice is considered grounded. The contour floatingicename defines nodes 
    13            for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 
     12           By default, ice is considered grounded. The contour floatingicename defines nodes
     13           for which ice is floating. The contour groundedicename defines nodes inside an floatingice,
    1414           that are grounded (ie: ice rises, islands, etc ...)
    1515           All input files are in the Argus format (extension .exp).
     
    3939        #Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
    4040        elementonfloatingice = FlagElements(md, floatingicename)
    41         elementongroundedice = FlagElements(md, groundedicename) 
     41        elementongroundedice = FlagElements(md, groundedicename)
    4242
    43         #Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 
    44         #arrays come from domain outlines that can intersect one another: 
     43        #Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous
     44        #arrays come from domain outlines that can intersect one another:
    4545
    4646        elementonfloatingice = np.logical_and(elementonfloatingice,np.logical_not(elementongroundedice))
  • issm/trunk-jpl/src/py3/plot/plot_manager.py

    r23670 r23709  
    8080                        return
    8181                else:
    82                         print("WARNING: '%s' is not implemented or is not a valid string for option 'data'" % data)
     82                        print(("WARNING: '%s' is not implemented or is not a valid string for option 'data'" % data))
    8383        # }}}
    8484        # {{{ Gridded plot TODO
  • issm/trunk-jpl/src/py3/plot/plot_overlay.py

    r23670 r23709  
    111111                        lon_0=0
    112112                else:
    113                         hemisphere=input('epsg code {} is not supported chose your hemisphere (1 for North, -1 for south)'.format(mesh.epsg))
     113                        hemisphere=eval(input('epsg code {} is not supported chose your hemisphere (1 for North, -1 for south)'.format(mesh.epsg)))
    114114
    115115                lat,lon=xy2ll(xlim,ylim,hemisphere,lon_0,st_lat)
  • issm/trunk-jpl/src/py3/plot/processdata.py

    r23670 r23709  
    5757                options.addfielddefault('clim',[lb,ub])
    5858                options.addfielddefault('cmap_set_under','1')
    59                 print("WARNING: nan's treated as", nanfill, "by default.  Change using pairoption 'nan',nan_fill_value in plotmodel call")
     59                print(("WARNING: nan's treated as", nanfill, "by default.  Change using pairoption 'nan',nan_fill_value in plotmodel call"))
    6060  # }}} 
    6161        # {{{ log
     
    118118                spccol=options.getfieldvalue('spccol',0)
    119119                print('multiple-column spc field; specify column to plot using option "spccol"')
    120                 print('column ', spccol, ' plotted for time: ', procdata[-1,spccol])
     120                print(('column ', spccol, ' plotted for time: ', procdata[-1,spccol]))
    121121                procdata=procdata[0:-1,spccol]
    122122   
  • issm/trunk-jpl/src/py3/qmu/dakota_in_data.py

    r23677 r23709  
    11#move this stuff elsewhere
    22from helpers import *
    3 from dakota_in_write import dakota_in_write
    4 from dakota_in_params import dakota_in_params
     3
     4from dakota_in_write import *
     5from dakota_in_params import *
     6from MatlabFuncs import *
    57
    68def dakota_in_data(dmeth,variables,responses,dparams,filei,*args):
     
    4345        #  get default set of parameters
    4446        params=dakota_in_params(struct())
    45 
    4647        #  merge specified parameters into default set, whether or not
    4748        #  they already exist
    4849        fnames=fieldnames(dparams)
    4950
    50         for i in range(np.size(fnames)):
    51                 if not isfield(params,fnames[i]):
    52                         print('WARNING: dakota_in_data:unknown_param: No parameter '+str(fnames[i])+' in default parameter set.')
    53                         exec(('params.%s = vars(dparams)[fnames[i]]')%(fnames[i]))
     51        for fieldname in fnames:
     52                if not isfield(params,fieldname):
     53                        print('WARNING: dakota_in_data:unknown_param: No parameter {} in default parameter set.'.format(str(fieldname)))
     54                exec('params.{} = vars(dparams)[fieldname]'.format(fieldname))
    5455
    5556        # use matlab even though we are running python
  • issm/trunk-jpl/src/py3/qmu/dakota_in_params.py

    r23677 r23709  
    182182
    183183        return params
    184 
  • issm/trunk-jpl/src/py3/qmu/dakota_in_write.py

    r23677 r23709  
    174174                str_name = dmeth.variables[j]
    175175
    176                 # organize so that multiple instances of the same qmu class 
    177                 # (2 different variable instances of "normal_uncertain" for example) 
     176                # organize so that multiple instances of the same qmu class
     177                # (2 different variable instances of "normal_uncertain" for example)
    178178                # are in the same dakota_write call regardless of individual size;
    179179                # but that each class has its own dakota_write call
     
    213213        elif params.system+params.fork+params.direct > 1:
    214214                raise RuntimeError('Too many interfaces selected.')
    215 
    216215        if params.system or params.fork:
    217216                param_write(fidi,'\t','asynchronous','','\n',params)
     
    230229                if len(params.input_filter) != 0:
    231230                        param_write(fidi,'\t  ','input_filter','    = ','\n',params)
    232                
     231
    233232                if len(params.output_filter) != 0:
    234233                        param_write(fidi,'\t  ','output_filter','   = ','\n',params)
    235                
     234
    236235                param_write(fidi,'\t  ','failure_capture','   ','\n',params)
    237236                param_write(fidi,'\t  ','deactivate','        ','\n',params)
    238                 param_write(fidi,'\t  ','parameters_file',' = ','\n',params)
    239                 param_write(fidi,'\t  ','results_file','    = ','\n',params)
     237                param_write(fidi,'\t  ','parameters_file',' =  \'','\'\n',params)
     238                param_write(fidi,'\t  ','results_file',' =  \'','\'\n',params)
    240239                param_write(fidi,'\t  ','verbatim', '','\n',params)
    241240                param_write(fidi,'\t  ','aprepro', '','\n',params)
     
    257256                        if ext != '':
    258257                                ext='.py'
    259                
     258
    260259                        params.analysis_components=fullfile(pathstr,name+ext)
    261260                        param_write(fidi,'\t  ','analysis_components',' = \'','\'\n',params)
    262                
     261
    263262                if len(params.input_filter) != 0:
    264263                        param_write(fidi,'\t  ','input_filter','    = ','\n',params)
    265                
     264
    266265                if len(params.output_filter) != 0:
    267266                        param_write(fidi,'\t  ','output_filter','   = ','\n',params)
    268                
     267
    269268                param_write(fidi,'\t  ','failure_capture','   ','\n',params)
    270269                param_write(fidi,'\t  ','deactivate','        ','\n',params)
     
    312311                elif (params.numerical_gradients+params.analytic_gradients > 1):
    313312                        raise RuntimeError('Too many gradients selected.')
    314                
     313
    315314                if params.numerical_gradients:
    316315                        param_write(fidi,'\t','numerical_gradients','','\n',params)
     
    329328        else:
    330329                fidi.write('\tno_hessians\n')
    331 
    332 
    333 
  • issm/trunk-jpl/src/py3/qmu/param_write.py

    r23677 r23709  
    77'''
    88        if not isfield(params,pname):
    9                 print('WARNING: param_write:param_not_found: Parameter '+str(pname)+' not found in structure.')
     9                print('WARNING: param_write:param_not_found: Parameter {} not found in structure.'.format(pname))
    1010                return
    1111
     
    1919
    2020        elif type(params_pname) in [str]:
    21                 fidi.write(sbeg+str(pname)+smid+params_pname+s)
     21                fidi.write(sbeg+pname+smid+params_pname+s)
    2222
    2323        elif type(params_pname) in [int, float]:
    2424                fidi.write(sbeg+str(pname)+smid+str(params_pname)+s)
    25 
    26 
    27 
  • issm/trunk-jpl/src/py3/qmu/rlev_write.py

    r23677 r23709  
    11import numpy as np
     2#move this later
    23from helpers import *
    3 from vector_write import vector_write
    4 from param_write import param_write
    5 from response_function import *
     4from vector_write import *
     5from param_write import *
     6#import relevent qmu classes
     7from MatlabArray import *
    68
    79def rlevi_write(fidi,ltype,levels):
     
    2022
    2123        fidi.write('\n')
    22 
    2324        fidi.write('\t  '+str(ltype)+' =\n')
    2425
     
    3738  function to write response levels
    3839'''
     40        from response_function import *
    3941
    4042        if len(dresp) == 0 or len(fieldnames(dresp[0])) == 0:
     
    7779                        grell.extend(grelli)
    7880
     81
    7982        # write response levels
     83
    8084        respl=allempty(respl)
    8185        probl=allempty(probl)
  • issm/trunk-jpl/src/py3/qmu/setupdesign/QmuSetupVariables.py

    r23677 r23709  
    1 from uniform_uncertain import uniform_uncertain
    2 from normal_uncertain import normal_uncertain
     1from MatlabFuncs import *
     2from uniform_uncertain import*
     3from normal_uncertain import *
    34from copy import deepcopy
    45
     
    910
    1011        #decide whether this is a distributed variable, which will drive whether we expand it into npart values,
    11         #or if we just carry it forward as is.
     12        #or if we just carry it forward as is. 
    1213
    1314        #ok, key off according to type of descriptor:
     
    1819                        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)):
    1920                                raise RuntimeError('QmuSetupDesign error message: upper and lower should be either a scalar or a "npart" length vector')
    20 
     21                       
    2122                elif isinstance(variables,normal_uncertain):
    2223                        if type(variables.stddev) in [list,np.ndarray] and len(variables.stddev) > md.qmu.numberofpartitions:
    2324                                raise RuntimeError('QmuSetupDesign error message: stddev should be either a scalar or a "npart" length vector')
    2425
    25                 #ok, dealing with semi-discrete distributed variable. Distribute according to how many
     26                #ok, dealing with semi-discrete distributed variable. Distribute according to how many 
    2627                #partitions we want
    2728
     
    7677
    7778        return dvar
     79       
  • issm/trunk-jpl/src/py3/qmu/vlist_write.py

    r23677 r23709  
    22#move this later
    33from helpers import *
    4 from vector_write import vector_write
    5 from normal_uncertain import normal_uncertain
     4
     5from vector_write import *
     6
     7from uniform_uncertain import *
     8from normal_uncertain import *
    69
    710def check(a,l,p):
     
    3841        if dvar == None:
    3942                return
     43        #from uniform_uncertain import *
    4044        func = eval(cstring)
    4145
  • issm/trunk-jpl/src/py3/solve/loadresultsfromcluster.py

    r23670 r23709  
    3737                        md=loadresultsfromdisk(md,md.miscellaneous.name+'.outbin')
    3838                else:
    39                         print('WARNING, outbin file is empty for run '+md.miscellaneous.name)
     39                        print(('WARNING, outbin file is empty for run '+md.miscellaneous.name))
    4040        elif not md.qmu.isdakota:
    41                 print('WARNING, outbin file does not exist '+md.miscellaneous.name)
     41                print(('WARNING, outbin file does not exist '+md.miscellaneous.name))
    4242               
    4343        #erase the log and output files
     
    8888                os.remove(filename+extension)
    8989        except OSError:
    90                 print('WARNING, no '+extension+'  is present for run '+filename)
     90                print(('WARNING, no '+extension+'  is present for run '+filename))
  • issm/trunk-jpl/src/py3/solve/marshall.py

    r23670 r23709  
    1212        """
    1313        if md.verbose.solution:
    14                 print("marshalling file '%s.bin'." % md.miscellaneous.name)
     14                print(("marshalling file '%s.bin'." % md.miscellaneous.name))
    1515
    1616        #open file for binary writing
  • issm/trunk-jpl/src/py3/solve/waitonlock.py

    r23670 r23709  
    2727
    2828                print('solution launched on remote cluster. log in to detect job completion.')
    29                 choice=input('Is the job successfully completed? (y/n) ')
     29                choice=eval(input('Is the job successfully completed? (y/n) '))
    3030                if not m.strcmp(choice,'y'):
    3131                        print('Results not loaded... exiting')
     
    4444                etime=0
    4545                ispresent=0
    46                 print("waiting for '%s' hold on... (Ctrl+C to exit)" % filename)
     46                print(("waiting for '%s' hold on... (Ctrl+C to exit)" % filename))
    4747
    4848                #loop till file .lock exist or time is up
Note: See TracChangeset for help on using the changeset viewer.