Changeset 23709
- Timestamp:
- 02/11/19 04:14:06 (6 years ago)
- Location:
- issm/trunk-jpl/src/py3
- Files:
-
- 64 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/py3/archive/arch.py
r23689 r23709 95 95 96 96 print('Source file: ') 97 print( '\t{0}'.format(filename))97 print(('\t{0}'.format(filename))) 98 98 print('Variables: ') 99 99 100 100 result=read_field(fid) 101 101 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']))) 105 105 # go to next result 106 106 result=read_field(fid) -
issm/trunk-jpl/src/py3/array/MatlabArray.py
r23677 r23709 29 29 ''' 30 30 if type(ain) != type(aval): 31 print( allequal.__doc__)31 print((allequal.__doc__)) 32 32 raise RuntimeError("ain and aval must be of the same type") 33 33 -
issm/trunk-jpl/src/py3/classes/SMBgemb.py
r23677 r23709 14 14 15 15 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 18 18 #of time steps. ) 19 19 … … 27 27 #ismelt 28 28 #isdensification 29 #isturbulentflux 30 31 #inputs: 29 #isturbulentflux 30 31 #inputs: 32 32 Ta = float('NaN') #2 m air temperature, in Kelvin 33 33 V = float('NaN') #wind speed (m/s-1) … … 37 37 eAir = float('NaN') #screen level vapor pressure [Pa] 38 38 pAir = float('NaN') #surface pressure [Pa] 39 40 39 Tmean = float('NaN') #mean annual temperature [K] 41 40 Vmean = float('NaN') #mean annual wind velocity [m s-1] 42 41 C = float('NaN') #mean annual snow accumulation [kg m-2 yr-1] 43 42 Tz = float('NaN') #height above ground at which temperature (T) was sampled [m] … … 47 46 aValue = float('NaN') #Albedo forcing at every element. Used only if aIdx == 0. 48 47 teValue = float('NaN') #Outward longwave radiation thermal emissivity forcing at every element (default in code is 1) 49 48 50 49 # Initialization of snow properties 51 50 Dzini = float('NaN') #cell depth (m) … … 60 59 Sizeini = float('NaN') #Number of layers 61 60 62 #settings: 61 #settings: 63 62 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 71 69 swIdx = float('NaN') # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1) 72 73 70 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) 89 84 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] 92 87 zY = float('NaN') # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)] 93 88 zMax = float('NaN') #initial max model depth (default is min(thickness,500)) [m] … … 95 90 outputFreq = float('NaN') #output frequency in days (default is monthly, 30) 96 91 97 #specific albedo parameters: 98 #Method 1 and 2: 92 #specific albedo parameters: 93 #Method 1 and 2: 99 94 aSnow = float('NaN') # new snow albedo (0.64 - 0.89) 100 95 aIce = float('NaN') # range 0.27-0.58 for old snow 101 96 #Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo 102 97 cldFrac = float('NaN') # average cloud amount 103 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) 107 102 adThresh = float('NaN') # Apply aIdx method to all areas with densities below this value, 108 109 103 # or else apply direct input value from aValue, allowing albedo to be altered. 104 # Default value is rho water (1023 kg m-3). 110 105 111 106 #densities: … … 114 109 #thermo: 115 110 ThermoDeltaTScaling = float('NaN') #scaling factor to multiply the thermal diffusion timestep (delta t) 116 111 117 112 requested_outputs = [] 118 113 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. 122 117 #elev: this is taken from the ISSM surface itself. 123 118 … … 128 123 #string = "#s\n#s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 129 124 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)')) 132 126 string = "%s\n%s"%(string,fielddisplay(self,'isgraingrowth','run grain growth module (default true)')) 133 127 string = "%s\n%s"%(string,fielddisplay(self,'isalbedo','run albedo module (default true)')) … … 147 141 string = "%s\n%s"%(string,fielddisplay(self,'Tmean','mean annual temperature [K]')) 148 142 string = "%s\n%s"%(string,fielddisplay(self,'C','mean annual snow accumulation [kg m-2 yr-1]')) 149 143 string = "%s\n%s"%(string,fielddisplay(self,'Vmean','mean annual temperature [m s-1] (default 10 m/s)')) 150 144 string = "%s\n%s"%(string,fielddisplay(self,'Tz','height above ground at which temperature (T) was sampled [m]')) 151 145 string = "%s\n%s"%(string,fielddisplay(self,'Vz','height above ground at which wind (V) eas sampled [m]')) … … 161 155 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.')) 162 156 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]'])) 169 162 string = "%s\n%s"%(string,fielddisplay(self,'teValue','Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)')) 170 171 163 #snow properties init 172 164 string = "%s\n%s"%(string,fielddisplay(self,'Dzini','Initial cell depth when restart [m]')) … … 180 172 string = "%s\n%s"%(string,fielddisplay(self,'Tini','Initial snow temperature when restart [K]')) 181 173 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: 184 176 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)): 185 177 string = "%s\n%s"%(string,fielddisplay(self,'aSnow','new snow albedo (0.64 - 0.89)')) … … 195 187 string = "%s\n%s"%(string,fielddisplay(self,'t0dry','warm snow timescale (30) [d]')) 196 188 string = "%s\n%s"%(string,fielddisplay(self,'K','time scale temperature coef. (7) [d]')) 197 189 198 190 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]')) 199 191 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)'])); 215 205 string = "%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 216 206 return string … … 247 237 self.isdensification = 1 248 238 self.isturbulentflux = 1 249 239 250 240 self.aIdx = 1 251 241 self.swIdx = 1 252 242 self.denIdx = 2 253 243 self.dsnowIdx = 1 254 244 self.zTop = 10*np.ones((mesh.numberofelements,)) 255 245 self.dzTop = .05* np.ones((mesh.numberofelements,)) … … 258 248 self.ThermoDeltaTScaling = 1/11.0 259 249 260 261 250 self.Vmean = 10*np.ones((mesh.numberofelements,)) 251 262 252 self.zMax = 250*np.ones((mesh.numberofelements,)) 263 253 self.zMin = 130*np.ones((mesh.numberofelements,)) … … 268 258 self.aSnow = 0.85 269 259 self.aIce = 0.48 270 self.cldFrac = 0.1 260 self.cldFrac = 0.1 271 261 self.t0wet = 15 272 262 self.t0dry = 30 … … 276 266 self.teValue = np.ones((mesh.numberofelements,)); 277 267 self.aValue = self.aSnow*np.ones(mesh.numberofelements,); 278 268 279 269 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)) 281 271 self.Reini = 2.5*np.ones((mesh.numberofelements,2)) 282 272 self.Gdnini = 0.0*np.ones((mesh.numberofelements,2)) … … 286 276 self.Aini = self.aSnow*np.ones((mesh.numberofelements,2)) 287 277 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 290 280 self.Sizeini = 2*np.ones((mesh.numberofelements,)) 291 281 #}}} … … 310 300 311 301 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 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) 316 306 317 307 md = checkfield(md,'fieldname','smb.teValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1); … … 320 310 md = checkfield(md,'fieldname','smb.swIdx','NaN',1,'Inf',1,'values',[0,1]) 321 311 md = checkfield(md,'fieldname','smb.denIdx','NaN',1,'Inf',1,'values',[1,2,3,4,5,6,7]) 322 312 md = checkfield(md,'fieldname','smb.dsnowIdx','NaN',1,'Inf',1,'values',[0,1,2,3,4]) 323 313 324 314 md = checkfield(md,'fieldname','smb.zTop','NaN',1,'Inf',1,'> = ',0) … … 326 316 md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0) 327 317 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 329 319 md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'> = ',0,'< = ',1) 330 320 md = checkfield(md,'fieldname','smb.ThermoDeltaTScaling','NaN',1,'Inf',1,'> = ',0,'< = ',1) … … 342 332 md = checkfield(md,'fieldname','smb.t0dry','NaN',1,'Inf',1,'> = ',30,'< = ',30) 343 333 md = checkfield(md,'fieldname','smb.K','NaN',1,'Inf',1,'> = ',7,'< = ',7) 344 334 345 335 346 336 #check zTop is < local thickness: … … 348 338 if np.any(he<self.zTop): 349 339 error('SMBgemb consistency check error: zTop should be smaller than local ice thickness') 350 340 351 341 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1) 352 342 return md … … 358 348 359 349 WriteData(fid,prefix,'name','md.smb.model','data',8,'format','Integer') 360 350 361 351 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isgraingrowth','format','Boolean') 362 352 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isalbedo','format','Boolean') … … 367 357 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isdensification','format','Boolean') 368 358 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isturbulentflux','format','Boolean') 369 359 370 360 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Ta','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 371 361 WriteData(fid,prefix,'object',self,'class','smb','fieldname','V','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) … … 374 364 WriteData(fid,prefix,'object',self,'class','smb','fieldname','P','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 375 365 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) 377 367 378 368 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tmean','format','DoubleMat','mattype',2) 379 369 WriteData(fid,prefix,'object',self,'class','smb','fieldname','C','format','DoubleMat','mattype',2) 380 370 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vmean','format','DoubleMat','mattype',2) 381 371 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tz','format','DoubleMat','mattype',2) 382 372 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vz','format','DoubleMat','mattype',2) … … 387 377 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMax','format','DoubleMat','mattype',2) 388 378 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMin','format','DoubleMat','mattype',2) 389 379 390 380 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIdx','format','Integer') 391 381 WriteData(fid,prefix,'object',self,'class','smb','fieldname','swIdx','format','Integer') 392 382 WriteData(fid,prefix,'object',self,'class','smb','fieldname','denIdx','format','Integer') 393 383 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dsnowIdx','format','Integer') 394 384 WriteData(fid,prefix,'object',self,'class','smb','fieldname','InitDensityScaling','format','Double') 395 385 WriteData(fid,prefix,'object',self,'class','smb','fieldname','ThermoDeltaTScaling','format','Double') … … 405 395 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aValue','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 406 396 WriteData(fid,prefix,'object',self,'class','smb','fieldname','teValue','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 407 397 408 398 #snow properties init 409 399 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dzini','format','DoubleMat','mattype',3) … … 418 408 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Sizeini','format','IntMat','mattype',2) 419 409 420 #figure out dt from forcings: 410 #figure out dt from forcings: 421 411 time = self.Ta[-1] #assume all forcings are on the same time step 422 412 dtime = np.diff(time,n=1,axis=0) 423 413 dt = min(dtime) / yts 424 414 425 415 WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts) 426 416 427 417 # Check if smb_dt goes evenly into transient core time step 428 418 if (md.timestepping.time_step % dt >= 1e-10): 429 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 431 421 #process requested outputs 432 422 outputs = self.requested_outputs … … 435 425 outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:] 436 426 outputs =outputscopy 437 427 438 428 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray') 439 429 # }}} 440 -
issm/trunk-jpl/src/py3/classes/bamggeom.py
r23670 r23709 25 25 elif len(args) == 1: 26 26 object=args[0] 27 for field in object.keys():27 for field in list(object.keys()): 28 28 if field in vars(self): 29 29 setattr(self,field,object[field]) -
issm/trunk-jpl/src/py3/classes/bamgmesh.py
r23670 r23709 32 32 elif len(args) == 1: 33 33 object=args[0] 34 for field in object.keys():34 for field in list(object.keys()): 35 35 if field in vars(self): 36 36 setattr(self,field,object[field]) -
issm/trunk-jpl/src/py3/classes/frictioncoulomb.py
r23670 r23709 5 5 6 6 class frictioncoulomb(object): 7 8 7 """ 8 FRICTIONCOULOMB class definition 9 9 10 11 12 10 Usage: 11 frictioncoulomb=frictioncoulomb() 12 """ 13 13 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 #}}} 23 24 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 #}}} 27 48 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 #}}} 53 52 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 57 57 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 # }}} 69 70 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') 70 84 # }}} 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 5 5 6 6 class frictionshakti(object): 7 8 7 """ 8 FRICTIONSHAKTI class definition 9 9 10 11 12 10 Usage: 11 friction=frictionshakti() 12 """ 13 13 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 #}}} 18 19 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 #}}} 22 25 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 #}}} 34 30 35 #Early return36 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:37 return md31 def setdefaultparameters(self): # {{{ 32 return self 33 #}}} 38 34 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 41 39 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) 42 48 # }}} 43 def marshall(self,prefix,md,fid): # {{{44 yts=md.constants.yts45 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 30 30 #}}} 31 31 def __repr__(self): # {{{ 32 33 32 string=' hydrologyshakti solution parameters:' 34 33 string="%s\n%s"%(string,fielddisplay(self,'head','subglacial hydrology water head (m)')) … … 45 44 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 46 45 return string 47 #}}} 46 #}}} 47 48 48 def extrude(self,md): # {{{ 49 49 return self 50 50 #}}} 51 51 52 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) 53 54 self.relaxation=1 54 55 self.storage=0 … … 56 57 return self 57 58 #}}} 59 58 60 def defaultoutputs(self,md): # {{{ 59 61 list = ['HydrologyHead','HydrologyGapHeight','EffectivePressure','HydrologyBasalFlux','DegreeOfChannelization'] … … 62 64 63 65 def checkconsistency(self,md,solution,analyses): # {{{ 64 65 66 #Early return 66 67 if 'HydrologyShaktiAnalysis' not in analyses: … … 76 77 md = checkfield(md,'fieldname','hydrology.neumannflux','timeseries',1,'NaN',1,'Inf',1) 77 78 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) 79 80 md = checkfield(md,'fieldname','hydrology.storage','>=',0) 80 81 md = checkfield(md,'fieldname','hydrology.requested_outputs','stringrow',1) 81 82 82 return md 83 83 # }}} 84 84 85 def marshall(self,prefix,md,fid): # {{{ 85 86 yts=md.constants.yts -
issm/trunk-jpl/src/py3/classes/massfluxatgate.py
r23670 r23709 46 46 #}}} 47 47 def checkconsistency(self,md,solution,analyses): # {{{ 48 48 49 49 if not isinstance(self.name, str): 50 50 raise RuntimeError("massfluxatgate error message: 'name' field should be a string!") 51 51 52 52 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 55 55 OutputdefinitionStringArray=[] 56 56 for i in range(1,100): 57 57 x='Outputdefinition'+str(i) 58 58 OutputdefinitionStringArray.append(x) 59 59 60 60 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!: 63 63 if not os.path.isfile(self.profilename): 64 64 raise RuntimeError("massfluxatgate error message: file name for profile corresponding to gate does not point to a legitimate file on disk!") … … 67 67 # }}} 68 68 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: 71 71 self.segments=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,self.profilename)[0] 72 72 73 #ok, marshall name and segments: 73 #ok, marshall name and segments: 74 74 WriteData(fid,prefix,'data',self.name,'name','md.massfluxatgate.name','format','String'); 75 75 WriteData(fid,prefix,'data',self.definitionstring,'name','md.massfluxatgate.definitionstring','format','String'); -
issm/trunk-jpl/src/py3/classes/matestar.py
r23677 r23709 14 14 15 15 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 = '' 33 32 34 #giaivins: 33 #giaivins: 35 34 lithosphere_shear_modulus = 0. 36 35 lithosphere_density = 0. … … 41 40 earth_density = 0 42 41 43 42 #set default parameters: 44 43 self.setdefaultparameters() 45 44 #}}} 45 46 46 def __repr__(self): # {{{ 47 47 string=" Materials:" 48 49 48 string="%s\n%s"%(string,fielddisplay(self,'rho_ice','ice density [kg/m^3]')) 50 49 string="%s\n%s"%(string,fielddisplay(self,'rho_water','ocean water density [kg/m^3]')) … … 68 67 string="%s\n%s"%(string,fielddisplay(self,'mantle_density','Mantle density [g/cm^-3]')) 69 68 string="%s\n%s"%(string,fielddisplay(self,'earth_density','Mantle density [kg/m^-3]')) 70 71 69 return string 72 70 #}}} 71 73 72 def extrude(self,md): # {{{ 74 73 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node') 75 74 self.rheology_Ec=project3d(md,'vector',self.rheology_Ec,'type','node') 76 75 self.rheology_Es=project3d(md,'vector',self.rheology_Es,'type','node') 77 76 return self 78 77 #}}} 78 79 79 def setdefaultparameters(self): # {{{ 80 80 #ice density (kg/m^3) 81 81 self.rho_ice=917. 82 83 82 #ocean water density (kg/m^3) 84 83 self.rho_water=1023. 85 86 84 #fresh water density (kg/m^3) 87 85 self.rho_freshwater=1000. 88 89 86 #water viscosity (N.s/m^2) 90 self.mu_water=0.001787 91 87 self.mu_water=0.001787 92 88 #ice heat capacity cp (J/kg/K) 93 89 self.heatcapacity=2093. 94 95 90 #ice latent heat of fusion L (J/kg) 96 91 self.latentheat=3.34*10**5 97 98 92 #ice thermal conductivity (W/m/K) 99 93 self.thermalconductivity=2.4 100 101 94 #wet ice thermal conductivity (W/m/K) 102 95 self.temperateiceconductivity=.24 103 104 96 #the melting point of ice at 1 atmosphere of pressure in K 105 97 self.meltingpoint=273.15 106 107 98 #rate of change of melting point with pressure (K/Pa) 108 99 self.beta=9.8*10**-8 109 110 100 #mixed layer (ice-water interface) heat capacity (J/kg/K) 111 101 self.mixed_layer_capacity=3974. 112 113 102 #thermal exchange velocity (ice-water interface) (m/s) 114 103 self.thermal_exchange_velocity=1.00*10**-4 115 116 104 #Rheology law: what is the temperature dependence of B with T 117 105 #available: none, paterson and arrhenius 118 106 self.rheology_law='Paterson' 119 120 107 # GIA: 121 108 self.lithosphere_shear_modulus = 6.7*10**10 # (Pa) … … 123 110 self.mantle_shear_modulus = 1.45*10**11 # (Pa) 124 111 self.mantle_density = 3.34 # (g/cm^-3) 125 126 112 #SLR 127 113 self.earth_density= 5512 # average density of the Earth, (kg/m^3) … … 129 115 return self 130 116 #}}} 117 131 118 def checkconsistency(self,md,solution,analyses): # {{{ 132 119 md = checkfield(md,'fieldname','materials.rho_ice','>',0) … … 144 131 md = checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1) 145 132 md = checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1) 133 146 134 if 'SealevelriseAnalysis' in analyses: 147 135 md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1) … … 149 137 return md 150 138 # }}} 139 151 140 def marshall(self,prefix,md,fid): # {{{ 152 141 WriteData(fid,prefix,'name','md.materials.type','data',2,'format','Integer') … … 167 156 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_Es','format','DoubleMat','mattype',1) 168 157 WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String') 169 170 158 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double') 171 159 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 6 6 7 7 class mismipbasalforcings(object): 8 """ 9 8 """ 9 MISMIP Basal Forcings class definition 10 10 11 12 13 11 Usage: 12 mismipbasalforcings=mismipbasalforcings() 13 """ 14 14 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() 16 22 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)): 45 43 self.geothermalflux=np.zeros((md.mesh.numberofvertices)) 46 44 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]) 57 61 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]) 60 67 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!') 65 80 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') 81 87 # }}} 82 def marshall(self,prefix,md,fid): # {{{83 84 yts=md.constants.yts85 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 218 218 # }}} 219 219 def checkmessage(self,string): # {{{ 220 print( "model not consistent: ", string)220 print(("model not consistent: ", string)) 221 221 self.private.isconsistent=False 222 222 return self … … 419 419 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity)[0] 420 420 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) 422 422 md2.mesh.vertexonboundary[segments[:,0:2]-1]=True 423 423 md2.mesh.vertexonboundary=np.tile(md2.mesh.vertexonboundary,md2.mesh.numberoflayers) … … 449 449 if md1.results: 450 450 md2.results=results() 451 for solutionfield,field in md1.results.__dict__.items():451 for solutionfield,field in list(md1.results.__dict__.items()): 452 452 if isinstance(field,list): 453 453 setattr(md2.results,solutionfield,[]) … … 458 458 fieldr=getattr(md2.results,solutionfield)[i] 459 459 #get subfields 460 for solutionsubfield,subfield in fieldi.__dict__.items():460 for solutionsubfield,subfield in list(fieldi.__dict__.items()): 461 461 if np.size(subfield)==numberofvertices1: 462 462 setattr(fieldr,solutionsubfield,subfield[pos_node]) … … 472 472 fieldr=getattr(md2.results,solutionfield) 473 473 #get subfields 474 for solutionsubfield,subfield in field.__dict__.items():474 for solutionsubfield,subfield in list(field.__dict__.items()): 475 475 if np.size(subfield)==numberofvertices1: 476 476 setattr(fieldr,solutionsubfield,subfield[pos_node]) … … 482 482 #OutputDefinitions fields 483 483 if md1.outputdefinition.definitions: 484 for solutionfield,field in md1.outputdefinition.__dict__.items():484 for solutionfield,field in list(md1.outputdefinition.__dict__.items()): 485 485 if isinstance(field,list): 486 486 #get each definition … … 489 489 fieldr=getattr(md2.outputdefinition,solutionfield)[i] 490 490 #get subfields 491 for solutionsubfield,subfield in fieldi.__dict__.items():491 for solutionsubfield,subfield in list(fieldi.__dict__.items()): 492 492 if np.size(subfield)==numberofvertices1: 493 493 setattr(fieldr,solutionsubfield,subfield[pos_node]) … … 834 834 #OutputDefinitions 835 835 if md.outputdefinition.definitions: 836 for solutionfield,field in md.outputdefinition.__dict__.items():836 for solutionfield,field in list(md.outputdefinition.__dict__.items()): 837 837 if isinstance(field,list): 838 838 #get each definition … … 841 841 fieldr=getattr(md.outputdefinition,solutionfield)[i] 842 842 #get subfields 843 for solutionsubfield,subfield in fieldi.__dict__.items():843 for solutionsubfield,subfield in list(fieldi.__dict__.items()): 844 844 if np.size(subfield)==md.mesh.numberofvertices: 845 845 setattr(fieldr,solutionsubfield,project2d(md,subfield,1)) -
issm/trunk-jpl/src/py3/classes/organizer.py
r23670 r23709 6 6 from savevars import savevars 7 7 from model import model 8 from dbm import whichdb8 from dbm.ndbm import whichdb 9 9 import MatlabFuncs as m 10 10 … … 86 86 if os.path.exists(path): 87 87 struc=loadvars(path) 88 name=name=[key for key in struc.keys()]88 name=name=[key for key in list(struc.keys())] 89 89 md=struc.name[0] 90 90 else: … … 115 115 raise IOError("Could find neither '%s' nor '%s'" % (path,path2)) 116 116 else: 117 print( "--> Branching '%s' from trunk '%s'" % (self.prefix,self.trunkprefix))117 print(("--> Branching '%s' from trunk '%s'" % (self.prefix,self.trunkprefix))) 118 118 md=loadmodel(path2) 119 119 return md … … 142 142 if 0 in self.requestedsteps: 143 143 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']))) 146 146 147 147 #Ok, now if _currentstep is a member of steps, return true 148 148 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']))) 150 150 bool=True 151 151 … … 167 167 else: 168 168 name=os.path.join(self.repository,name) 169 print( "saving model as: '%s'" % name)169 print(("saving model as: '%s'" % name)) 170 170 171 171 #check that md is a model -
issm/trunk-jpl/src/py3/classes/pairoptions.py
r23689 r23709 30 30 if self.list: 31 31 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()): 33 33 #if isinstance(item[1],str): 34 34 s+=" field: {} value: '{}'\n".format((item[0],item[1])) … … 55 55 else: 56 56 #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))) 58 58 # }}} 59 59 def addfield(self,field,value): # {{{ … … 61 61 if isinstance(field,str): 62 62 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)))) 64 64 self.list[field] = value 65 65 # }}} … … 72 72 def AssignObjectFields(self,obj2): # {{{ 73 73 """ASSIGNOBJECTFIELDS - assign object fields from options""" 74 for item in self.list.items():74 for item in list(self.list.items()): 75 75 if item[0] in dir(obj2): 76 76 setattr(obj2,item[0],item[1]) 77 77 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)))) 79 79 return obj2 80 80 # }}} … … 150 150 #warn user if requested 151 151 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)) 153 153 # }}} 154 154 def marshall(self,md,fid,firstindex): # {{{ -
issm/trunk-jpl/src/py3/classes/plotoptions.py
r23691 r23709 23 23 if self.list: 24 24 s+=" list: (%ix%i)\n" % (len(self.list),2) 25 for item in self.list.items():25 for item in list(self.list.items()): 26 26 #s+=" options of plot number %i\n" % item 27 27 if isinstance(item[1],str): … … 50 50 else: 51 51 #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))) 53 53 54 54 #get figure number … … 125 125 j=j+1 126 126 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])) 128 128 #}}} -
issm/trunk-jpl/src/py3/classes/qmu/@dakota_method/dakota_method.py
r23677 r23709 1 1 #move this later 2 2 from helpers import * 3 4 from MatlabFuncs import * 3 5 import numpy as np 4 6 … … 44 46 45 47 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 =[] 52 54 #properites 53 self.params =struct()55 self.params =struct() 54 56 55 57 @staticmethod … … 75 77 #given argument was a way of constructing a method 76 78 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'] 119 120 120 121 mlist2=[] … … 122 123 if strncmpi(method,mlist[i],len(method)): 123 124 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 127 126 l = len(mlist2) 128 127 if l == 0: … … 134 133 135 134 # assign the default values for the method 135 # switch dm.method 136 136 if dm.method in ['dot_bfgs','dot_frcg']: 137 137 dm.type ='dot' 138 dm.variables=['continuous_design','continuous_state'] 138 dm.variables=['continuous_design', 139 'continuous_state'] 139 140 dm.lcspec =[] 140 141 dm.responses=['objective_function'] … … 151 152 elif dm.method in ['dot_mmfd','dot_slp','dot_sqp']: 152 153 dm.type ='dot' 153 dm.variables=['continuous_design','continuous_state'] 154 dm.variables=['continuous_design', 155 'continuous_state'] 154 156 dm.lcspec =['linear_inequality_constraint', 155 157 'linear_equality_constraint'] … … 236 238 dm.params.max_step=1000. 237 239 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']: 239 244 dm.type ='optpp' 240 245 dm.variables=['continuous_design', … … 455 460 dm.params.vol_boxsize_limit=1.0e-8 456 461 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 459 465 elif dm.method == 'moga': 460 466 dm.type ='jega' … … 501 507 dm.params.postprocessor_type=False 502 508 dm.params.orthogonal_distance=[0.01] 509 503 510 elif dm.method == 'soga': 504 511 dm.type ='jega' … … 563 570 dm.params.covariance=0 564 571 dm.params.regression_stressbalances=False 572 565 573 elif dm.method == 'nlssol_sqp': 566 574 dm.type ='lsq' … … 619 627 dm.responses=['response_function'] 620 628 dm.ghspec =[] 621 # not documented, but apparently works629 # not documented, but apparently works 622 630 dm.params.output=False 623 631 dm.params.seed=False … … 658 666 dm.responses=['response_function'] 659 667 dm.ghspec =['grad'] 660 # not documented, but may work668 # not documented, but may work 661 669 dm.params.output=False 662 670 dm.params.x_gaussian_process=False … … 860 868 861 869 else: 862 raise RuntimeError('Unimplemented method: '+str(dm.method)+'.')870 raise RuntimeError('Unimplemented method: {}.'.format(dm.method)) 863 871 864 872 # if more than one argument, issue warning -
issm/trunk-jpl/src/py3/classes/qmu/@dakota_method/dmeth_params_set.py
r23677 r23709 22 22 23 23 return dm 24 25 26 27 -
issm/trunk-jpl/src/py3/classes/qmu/@dakota_method/dmeth_params_write.py
r23677 r23709 1 1 from dakota_method import * 2 from MatlabFuncs import * 2 3 from IssmConfig import * 3 4 … … 21 22 # unfortunately this prevents merely looping through the fields 22 23 # of the parameters structure. 24 23 25 # write method-indepent controls 26 24 27 # param_write(fid,sbeg,'id_method',' = ','\n',dm.params) 25 28 # param_write(fid,sbeg,'model_pointer',' = ','\n',dm.params) 26 29 27 30 # write method-depent controls 31 32 #switch dm.type 28 33 if dm.type == 'dot': 29 34 param_write(fid,sbeg,'max_iterations',' = ','\n',dm.params) … … 95 100 raise RuntimeError('#s'' method must have only one algorithm.', 96 101 dm.method) 97 98 99 100 101 102 103 104 105 106 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) 107 112 108 113 elif dm.method == 'optpp_pds': 109 114 param_write(fid,sbeg,'search_scheme_size',' = ','\n',dm.params) 110 115 111 116 else: … … 137 142 param_write(fid,sbeg,'output',' ','\n',dm.params) 138 143 param_write(fid,sbeg,'scaling','','\n',dm.params) 139 140 144 param_write(fid,sbeg,'show_misc_options','','\n',dm.params) 141 145 param_write(fid,sbeg,'misc_options',' = ','\n',dm.params) … … 246 250 param_write(fid,sbeg,'niching_type',' = ','\n',dm.params) 247 251 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) 250 254 param_write(fid,sbeg,'radial',' = ','\n',dm.params) 251 255 param_write(fid,sbeg,'distance',' = ','\n',dm.params) … … 266 270 else: 267 271 raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.') 268 269 272 270 273 elif dm.type == 'lsq': … … 310 313 dm.params.trust_region + 311 314 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) 313 317 314 318 param_write(fid,sbeg,'value_based_line_search','','\n',dm.params) … … 348 352 if type(dm.params.mpp_search) == str: 349 353 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 351 357 param_write(fid,sbeg,'sqp','','\n',dm.params) 352 358 param_write(fid,sbeg,'nip','','\n',dm.params) … … 360 366 elif dm.method == 'nond_global_reliability': 361 367 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 363 371 param_write(fid,sbeg,'x_gaussian_process','','\n',dm.params) 364 372 param_write(fid,sbeg,'u_gaussian_process','','\n',dm.params) … … 399 407 raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.') 400 408 409 401 410 elif dm.type == 'dace': 402 411 #switch dm.method 403 412 if dm.method == 'dace': 404 413 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 406 417 param_write(fid,sbeg,'grid','','\n',dm.params) 407 418 param_write(fid,sbeg,'random','','\n',dm.params) … … 421 432 if (dm.params.halton + dm.params.hammersley != 1): 422 433 raise RuntimeError('#s'' method must have one and only one sequence type.',dm.method) 434 423 435 param_write(fid,sbeg,'halton','','\n',dm.params) 424 436 param_write(fid,sbeg,'hammersley','','\n',dm.params) … … 445 457 raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.') 446 458 447 448 459 elif dm.type == 'param': 449 460 param_write(fid,sbeg,'output',' ','\n',dm.params) … … 457 468 param_write(fid,sbeg,'step_length',' = ','\n',dm.params) 458 469 param_write(fid,sbeg,'num_steps',' = ','\n',dm.params) 470 459 471 elif not isempty(dm.params.step_vector): 460 472 param_write(fid,sbeg,'step_vector',' = ','\n',dm.params) … … 474 486 raise RuntimeError('Unrecognized '+dm.type+' method: '+dm.method+'.') 475 487 488 476 489 elif dm.type == 'bayes': 477 490 #switch dm.method 478 491 if dm.method == 'bayes_calibration': 479 480 481 482 483 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 # 485 498 param_write(fid,sbeg,'queso','','\n',dm.params) 486 499 param_write(fid,sbeg,'dream','','\n',dm.params) … … 501 514 # loop through each parameter field in the structure 502 515 fnames=fieldnames(params) 503 504 516 for i in range(np.size(fnames)): 505 517 param_write(fidi,sbeg,fnames[i],smid,s,params) … … 517 529 return 518 530 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]))) 520 532 return 521 533 … … 523 535 if type(vars(params)[pname]) == bool: 524 536 fidi.write(sbeg+str(pname)+s) 537 525 538 elif type(vars(params)[pname]) in [int,float]: 526 539 fidi.write(sbeg+str(pname)+smid+str(vars(params)[pname])+s) 540 527 541 elif type(vars(params)[pname]) == list: 528 542 fidi.write(sbeg+str(pname)+smid+str(vars(params)[pname][0])) … … 531 545 532 546 fidi.write(s) 547 533 548 elif type(vars(params)[pname]) == str: 534 549 fidi.write(sbeg+str(pname)+smid+str(vars(params)[pname])+s) 550 535 551 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]))) 537 553 return -
issm/trunk-jpl/src/py3/classes/qmu/calibration_function.py
r23677 r23709 1 1 import numpy as np 2 from rlist_write import rlist_write 2 from rlist_write import * 3 from MatlabArray import * 3 4 4 5 class calibration_function(object): … … 70 71 string += ' scale: '+str(self.scale) + '\n' 71 72 string += ' weight: '+str(self.weight) + '\n' 72 73 73 return string 74 74 75 75 # from here on, cf is either a single, or a 1d vector of, calibration_function 76 77 76 @staticmethod 78 77 def prop_desc(cf,dstr): … … 96 95 97 96 desc = allempty(desc) 98 99 97 return desc 100 98 -
issm/trunk-jpl/src/py3/classes/qmu/least_squares_term.py
r23677 r23709 1 1 import numpy as np 2 from rlist_write import rlist_write 2 from rlist_write import * 3 from MatlabArray import * 3 4 4 5 class least_squares_term(object): … … 58 59 for i in range(np.size(lst)): 59 60 if (np.size(args[2]) > 1): 60 lst[i].scale 61 lst[i].scale = args[2][i] 61 62 else: 62 lst[i].scale 63 lst[i].scale = args[2] 63 64 64 65 if (nargin >= 4): 65 66 for i in range(np.size(lst)): 66 67 if (np.size(args[3]) > 1): 67 lst[i].weight 68 lst[i].weight = args[3][i] 68 69 else: 69 lst[i].weight 70 lst[i].weight = args[3] 70 71 71 72 if (nargin > 4): … … 82 83 string += ' scale: '+str(self.scale) + '\n' 83 84 string += ' weight: '+str(self.weight) + '\n' 84 85 85 return string 86 86 … … 100 100 101 101 desc = allempty(desc) 102 103 102 return desc 104 103 … … 113 112 114 113 stype = allequal(stype,'none') 115 116 114 return stype 117 115 … … 126 124 127 125 scale = allequal(scale,1.) 128 129 126 return scale 130 127 … … 139 136 140 137 weight = allequal(weight,1.) 141 142 138 return weight 143 139 -
issm/trunk-jpl/src/py3/classes/qmu/normal_uncertain.py
r23677 r23709 1 1 import numpy as np 2 #from vlist_write import * 3 from MatlabArray import * 2 4 3 5 class normal_uncertain(object): … … 128 130 129 131 upper = allequal(upper,-np.inf) 130 131 132 return upper 132 133 … … 173 174 nuv = [struc_class(i,'normal_uncertain','nuv') for i in dvar] 174 175 176 # possible namespace pollution, the above import seems not to work 177 from vlist_write import vlist_write 175 178 # write variables 176 179 vlist_write(fidi,'normal_uncertain','nuv',nuv) -
issm/trunk-jpl/src/py3/classes/qmu/objective_function.py
r23677 r23709 1 1 import numpy as np 2 from rlist_write import rlist_write 2 from rlist_write import * 3 from MatlabArray import * 3 4 4 5 class objective_function(object): … … 29 30 def objective_function(*args): 30 31 nargin = len(args) 32 31 33 # create a default object 32 34 if nargin == 0: … … 40 42 shapec = array_size(*args[0:min(nargin,4)]) 41 43 of = [objective_function() for i in range(shapec[0]) for j in range(shapec[1])] 44 42 45 for i in range(np.size(of)): 43 46 if (np.size(args[0]) > 1): … … 72 75 return of 73 76 77 74 78 def __repr__(self): 75 79 # display the object … … 80 84 string += ' scale: ' +str(self.scale) + '\n' 81 85 string += ' weight: ' +str(self.weight) + '\n' 82 83 86 return string 84 87 … … 104 107 105 108 desc = allempty(desc) 106 107 109 return desc 108 110 … … 132 134 133 135 weight = allequal(weight,1.) 134 135 136 return weight 136 137 … … 145 146 146 147 stype = allequal(stype,'none') 147 148 148 return stype 149 149 … … 158 158 159 159 scale = allequal(scale,1.) 160 161 160 return scale 162 161 -
issm/trunk-jpl/src/py3/classes/qmu/response_function.py
r23677 r23709 1 1 import numpy as np 2 from rlist_write import * 3 from rlev_write import rlev_write 2 #from rlist_write import * 3 from rlev_write import * 4 from MatlabArray import * 4 5 5 6 #move this later … … 35 36 @staticmethod 36 37 def response_function(*args): 38 37 39 nargin = len(args) 38 40 # create a default object … … 75 77 return rf 76 78 77 78 79 def __repr__(self): 79 80 # display the object … … 109 110 110 111 desc = allempty(desc) 111 112 112 return desc 113 113 … … 149 149 150 150 respl = empty_nd_list(np.size(rf)) 151 152 151 probl = empty_nd_list(np.size(rf)) 153 154 152 rell = empty_nd_list(np.size(rf)) 155 156 153 grell = empty_nd_list(np.size(rf)) 157 154 … … 166 163 rell = allempty(rell) 167 164 grell = allempty(grell) 168 169 165 return [respl,probl,rell,grell] 170 166 -
issm/trunk-jpl/src/py3/classes/qmu/uniform_uncertain.py
r23677 r23709 1 1 import numpy as np 2 from vlist_write import vlist_write 2 #from vlist_write import * 3 3 from MatlabArray import * 4 4 … … 28 28 def uniform_uncertain(*args): 29 29 nargin = len(args) 30 30 31 # create a default object 31 32 if nargin == 0: … … 153 154 # collect only the variables of the appropriate class 154 155 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 156 158 # write variables 157 159 vlist_write(fidi,'uniform_uncertain','uuv',uuv) -
issm/trunk-jpl/src/py3/classes/results.py
r23670 r23709 25 25 s+="%s\n" % fielddisplay(self,'SolutionType',"solution type") 26 26 27 for name in self.__dict__.keys():27 for name in list(self.__dict__.keys()): 28 28 if name not in ['step','time','SolutionType','errlog','outlog']: 29 29 if isinstance(getattr(self,name),list): -
issm/trunk-jpl/src/py3/classes/rifts.py
r23670 r23709 47 47 md.checkmessage("model should be processed for rifts (run meshprocessrifts)!") 48 48 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]) 50 50 else: 51 51 if self.riftstruct and np.any(np.logical_not(isnans(self.riftstruct))): -
issm/trunk-jpl/src/py3/classes/toolkits.py
r23670 r23709 35 35 def __repr__(self): # {{{ 36 36 s ="List of toolkits options per analysis:\n\n" 37 for analysis in vars(self).keys():37 for analysis in list(vars(self).keys()): 38 38 s+="%s\n" % fielddisplay(self,analysis,'') 39 39 … … 56 56 # }}} 57 57 def checkconsistency(self,md,solution,analyses): # {{{ 58 for analysis in vars(self).keys():58 for analysis in list(vars(self).keys()): 59 59 if not getattr(self,analysis): 60 60 md.checkmessage("md.toolkits.%s is empty" % analysis) … … 83 83 84 84 #start writing options 85 for analysis in vars(self).keys():85 for analysis in list(vars(self).keys()): 86 86 options=getattr(self,analysis) 87 87 … … 89 89 fid.write("\n+%s\n" % analysis) #append a + to recognize it's an analysis enum 90 90 #now, write options 91 for optionname,optionvalue in options.items():91 for optionname,optionvalue in list(options.items()): 92 92 93 93 if not optionvalue: -
issm/trunk-jpl/src/py3/classes/verbose.py
r23670 r23709 67 67 #Cast to logicals 68 68 listproperties=vars(self) 69 for fieldname,fieldvalue in list properties.items():69 for fieldname,fieldvalue in list(listproperties.items()): 70 70 if isinstance(fieldvalue,bool) or isinstance(fieldvalue,(int,float)): 71 71 setattr(self,fieldname,bool(fieldvalue)) -
issm/trunk-jpl/src/py3/consistency/checkfield.py
r23689 r23709 1 1 import numpy as np 2 2 import os 3 from re import findall,split 3 4 from pairoptions import pairoptions 4 5 from operator import attrgetter … … 42 43 else: 43 44 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)) 46 56 # exec("field=md.{}".format(fieldname),namespace) 57 47 58 48 59 if isinstance(field,(bool,int,float)): … … 135 146 if options.exist('>='): 136 147 lowerbound = options.getfieldvalue('>=') 148 if type(lowerbound) is str: 149 lowerbound=attrgetter(lowerbound)(md) 137 150 if np.size(lowerbound)>1: #checking elementwise 138 151 if any(field<upperbound): … … 153 166 if options.exist('>'): 154 167 lowerbound=options.getfieldvalue('>') 168 if type(lowerbound) is str: 169 lowerbound=attrgetter(lowerbound)(md) 155 170 if np.size(lowerbound)>1: #checking elementwise 156 171 if any(field<=upperbound): … … 172 187 if options.exist('<='): 173 188 upperbound=options.getfieldvalue('<=') 189 if type(upperbound) is str: 190 upperbound=attrgetter(upperbound)(md) 174 191 if np.size(upperbound)>1: #checking elementwise 175 192 if any(field>upperbound): … … 189 206 if options.exist('<'): 190 207 upperbound=options.getfieldvalue('<') 208 if type(upperbound) is str: 209 upperbound=attrgetter(upperbound)(md) 191 210 if np.size(upperbound)>1: #checking elementwise 192 211 if any(field>=upperbound): -
issm/trunk-jpl/src/py3/contrib/defleurian/netCDF/export_netCDF.py
r23677 r23709 12 12 if path.exists(filename): 13 13 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: ')) 15 15 if newname=='delete': 16 16 remove(filename) -
issm/trunk-jpl/src/py3/contrib/defleurian/paraview/enveloppeVTK.py
r23677 r23709 28 28 if os.path.exists(filename): 29 29 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: ')) 31 31 if newname=='delete': 32 32 filelist = glob.glob(filename+'/*') -
issm/trunk-jpl/src/py3/contrib/defleurian/paraview/enveloppeVTK_bleeding.py
r23677 r23709 32 32 if os.path.exists(filename): 33 33 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: ')) 35 35 if newname=='delete': 36 36 filelist = glob.glob(filename+'/*') -
issm/trunk-jpl/src/py3/contrib/defleurian/paraview/exportVTK.py
r23677 r23709 28 28 if os.path.exists(filename): 29 29 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: ')) 31 31 if newname=='delete': 32 32 filelist = glob.glob(filename+'/*') … … 193 193 for node in range(0,num_of_points): 194 194 #paraview does not like NaN, replacing 195 print( other_struct.__dict__[field][node])195 print((other_struct.__dict__[field][node])) 196 196 if np.isnan(other_struct.__dict__[field][node]): 197 197 fid.write('%e\n' % -9999.9999) -
issm/trunk-jpl/src/py3/contrib/morlighem/bamg/YamsCall.py
r23677 r23709 29 29 #Compute Hessian 30 30 t1=time.time() 31 print( "%s" % ' computing Hessian...')31 print(("%s" % ' computing Hessian...')) 32 32 hessian=ComputeHessian(md.mesh.elements,md.mesh.x,md.mesh.y,field,'node') 33 33 t2=time.time() 34 print( "%s%d%s\n" % (' done (',t2-t1,' seconds)'))34 print(("%s%d%s\n" % (' done (',t2-t1,' seconds)'))) 35 35 36 36 #Compute metric 37 37 t1=time.time() 38 print( "%s" % ' computing metric...')38 print(("%s" % ' computing metric...')) 39 39 metric=ComputeMetric(hessian,scale,epsilon,hmin,hmax,np.empty(0,int)) 40 40 t2=time.time() 41 print( "%s%d%s\n" % (' done (',t2-t1,' seconds)'))41 print(("%s%d%s\n" % (' done (',t2-t1,' seconds)'))) 42 42 43 43 #write files 44 44 t1=time.time() 45 print( "%s" % ' writing initial mesh files...')45 print(("%s" % ' writing initial mesh files...')) 46 46 np.savetxt('carre0.met',metric) 47 47 … … 80 80 f.close() 81 81 t2=time.time() 82 print( "%s%d%s\n" % (' done (',t2-t1,' seconds)'))82 print(("%s%d%s\n" % (' done (',t2-t1,' seconds)'))) 83 83 84 84 #call yams 85 print( "%s\n" % ' call Yams...')85 print(("%s\n" % ' call Yams...')) 86 86 if m.ispc(): 87 87 #windows … … 96 96 #plug new mesh 97 97 t1=time.time() 98 print( "\n%s" % ' reading final mesh files...')98 print(("\n%s" % ' reading final mesh files...')) 99 99 Tria=np.loadtxt('carre1.tria',int) 100 100 Coor=np.loadtxt('carre1.coor',float) … … 107 107 numberofelements2=md.mesh.numberofelements 108 108 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)'))) 110 110 111 111 #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))) 114 114 115 115 #clean up: -
issm/trunk-jpl/src/py3/coordsystems/gmtmask.py
r23677 r23709 21 21 22 22 if recursive: 23 print( ' recursing: num vertices #'+str(lenlat))23 print((' recursing: num vertices #'+str(lenlat))) 24 24 else: 25 print( 'gmtmask: num vertices #'+str(lenlat))25 print(('gmtmask: num vertices #'+str(lenlat))) 26 26 27 27 #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 11 11 12 12 print(' ') 13 print( IssmConfig('PACKAGE_NAME')[0]+' Version '+IssmConfig('PACKAGE_VERSION')[0])14 print( '(website: '+IssmConfig('PACKAGE_URL')[0]+' contact: '+IssmConfig('PACKAGE_BUGREPORT')[0]+')')13 print((IssmConfig('PACKAGE_NAME')[0]+' Version '+IssmConfig('PACKAGE_VERSION')[0])) 14 print(('(website: '+IssmConfig('PACKAGE_URL')[0]+' contact: '+IssmConfig('PACKAGE_BUGREPORT')[0]+')')) 15 15 print(' ') 16 print( 'Build date: '+IssmConfig('PACKAGE_BUILD_DATE')[0])16 print(('Build date: '+IssmConfig('PACKAGE_BUILD_DATE')[0])) 17 17 print('Copyright (c) 2009-2018 California Institute of Technology') 18 18 print(' ') -
issm/trunk-jpl/src/py3/exp/expcoarsen.py
r23670 r23709 23 23 raise OSError("expcoarsen error message: file '%s' not found!" % oldfile) 24 24 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)')) 26 26 if choice not in 'y': 27 27 print('no modification done ... exiting') -
issm/trunk-jpl/src/py3/geometry/NowickiProfile.py
r23677 r23709 28 28 29 29 #upstream of the GL 30 for i in range( np.size(x) / 2):30 for i in range(int(np.size(x)/2)): 31 31 ss = np.roots([1, 4 * lamda * beta, 0, 0, 6 * lamda * ms * x[i]**2 + 32 32 12 * lamda * q * x[i] - hg**4 - 4 * lamda * beta * hg**3]) … … 38 38 39 39 #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))): 41 41 h[i] = (x[i] / (4. * (delta+1) * q) + hg**(-2))**(-0.5) # ice thickness for ice shelf from (3.1) 42 42 b[i] = sea - h[i] * (1. / (1+delta)) -
issm/trunk-jpl/src/py3/io/loadmodel.py
r23670 r23709 1 1 from loadvars import loadvars 2 from dbm import whichdb2 from dbm.ndbm import whichdb 3 3 from netCDF4 import Dataset 4 4 … … 27 27 #recover model on file and name it md 28 28 struc=loadvars(path) 29 name=[key for key in struc.keys()]29 name=[key for key in list(struc.keys())] 30 30 if len(name)>1: 31 31 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 7 7 from os import path 8 8 from collections import OrderedDict 9 from dbm import whichdb9 from dbm.ndbm import whichdb 10 10 from model import * 11 11 … … 57 57 58 58 if whichdb(filename): 59 print( "Loading variables from file '%s'." % filename)59 print(("Loading variables from file '%s'." % filename)) 60 60 61 61 my_shelf = shelve.open(filename,'r') # 'r' for read-only 62 62 if nvdict: 63 for name in nvdict.keys():63 for name in list(nvdict.keys()): 64 64 try: 65 65 nvdict[name] = my_shelf[name] 66 print( "Variable '%s' loaded." % name)66 print(("Variable '%s' loaded." % name)) 67 67 except KeyError: 68 68 value = None 69 print( "Variable '%s' not found." % name)69 print(("Variable '%s' not found." % name)) 70 70 71 71 else: 72 for name in my_shelf.keys():72 for name in list(my_shelf.keys()): 73 73 nvdict[name] = my_shelf[name] 74 print( "Variable '%s' loaded." % name)74 print(("Variable '%s' loaded." % name)) 75 75 76 76 my_shelf.close() -
issm/trunk-jpl/src/py3/io/savevars.py
r19895 r23709 46 46 47 47 if os.path.exists(filename): 48 print( "Shelving variables to existing file '%s'." % filename)48 print(("Shelving variables to existing file '%s'." % filename)) 49 49 else: 50 print( "Shelving variables to new file '%s'." % filename)50 print(("Shelving variables to new file '%s'." % filename)) 51 51 52 52 my_shelf = shelve.open(filename,'c') # 'c' for create if not exist, else 'n' for new 53 53 54 for name,value in nvdict.items():54 for name,value in list(nvdict.items()): 55 55 try: 56 56 my_shelf[name] = value 57 print( "Variable '%s' shelved." % name)57 print(("Variable '%s' shelved." % name)) 58 58 except TypeError: 59 print( "Variable '%s' not shelved." % name)59 print(("Variable '%s' not shelved." % name)) 60 60 61 61 my_shelf.close() -
issm/trunk-jpl/src/py3/mech/thomasparams.py
r23670 r23709 126 126 pos=np.nonzero(np.abs((np.abs(a)-2.))<1.e-3) 127 127 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')) 129 129 a[pos]=-2+1e-3 130 130 -
issm/trunk-jpl/src/py3/mesh/bamg.py
r23670 r23709 572 572 573 573 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)) 575 575 576 576 """ -
issm/trunk-jpl/src/py3/mesh/triangle.py
r23670 r23709 37 37 #Check that mesh was not already run, and warn user: 38 38 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)')) 40 40 if not m.strcmp(choice,'y'): 41 41 print('no meshing done ... exiting') -
issm/trunk-jpl/src/py3/miscellaneous/fielddisplay.py
r23670 r23709 67 67 offset+=' ' 68 68 69 for structure_field,sfield in field.items():69 for structure_field,sfield in list(field.items()): 70 70 string+=parsedisplay(offset,str(structure_field),sfield,'')+'\n' 71 71 -
issm/trunk-jpl/src/py3/modules/MeshPartition.py
r23677 r23709 15 15 ''' 16 16 if md == None or numpartitions == None: 17 print( MeshPartition.__doc__)17 print((MeshPartition.__doc__)) 18 18 raise RuntimeError('Wrong usage (see above)') 19 19 -
issm/trunk-jpl/src/py3/os/issmscpin.py
r19895 r23709 43 43 raise OSError("issmscpin error message: could not find ISSM_DIR_WIN environment variable.") 44 44 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) ')) 47 47 48 48 for package in packages: -
issm/trunk-jpl/src/py3/os/issmscpout.py
r19895 r23709 36 36 raise OSError("issmscpout error message: could not find ISSM_DIR_WIN environment variable.") 37 37 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) ')) 40 40 41 41 for package in packages: -
issm/trunk-jpl/src/py3/os/issmssh.py
r23670 r23709 29 29 raise OSError("issmssh error message: could not find ISSM_DIR_WIN environment variable.") 30 30 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) ')) 33 33 34 34 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 11 11 'SIA','SSA','HO','L1L2','FS' and 'fill' are the possible options 12 12 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 15 15 setflowequationd, add '~' to the name of the domain file (ex: '~HO.exp'); 16 16 an empty string '' will be considered as an empty domain … … 96 96 97 97 #Then complete with NoneApproximation or the other model used if there is no FS 98 if any(FSflag): 98 if any(FSflag): 99 99 if any(HOflag): #fill with HO 100 100 HOflag[~FSflag]=True … … 103 103 SSAflag[~FSflag]=True 104 104 nodeonSSA[md.mesh.elements[np.where(SSAflag),:]-1]=True 105 else: #fill with none 105 else: #fill with none 106 106 noneflag[np.where(~FSflag)]=True 107 107 … … 285 285 286 286 return md 287 -
issm/trunk-jpl/src/py3/parameterization/setmask.py
r23670 r23709 10 10 SETMASK - establish boundaries between grounded and floating ice. 11 11 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, 14 14 that are grounded (ie: ice rises, islands, etc ...) 15 15 All input files are in the Argus format (extension .exp). … … 39 39 #Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{ 40 40 elementonfloatingice = FlagElements(md, floatingicename) 41 elementongroundedice = FlagElements(md, groundedicename) 41 elementongroundedice = FlagElements(md, groundedicename) 42 42 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: 45 45 46 46 elementonfloatingice = np.logical_and(elementonfloatingice,np.logical_not(elementongroundedice)) -
issm/trunk-jpl/src/py3/plot/plot_manager.py
r23670 r23709 80 80 return 81 81 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)) 83 83 # }}} 84 84 # {{{ Gridded plot TODO -
issm/trunk-jpl/src/py3/plot/plot_overlay.py
r23670 r23709 111 111 lon_0=0 112 112 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))) 114 114 115 115 lat,lon=xy2ll(xlim,ylim,hemisphere,lon_0,st_lat) -
issm/trunk-jpl/src/py3/plot/processdata.py
r23670 r23709 57 57 options.addfielddefault('clim',[lb,ub]) 58 58 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")) 60 60 # }}} 61 61 # {{{ log … … 118 118 spccol=options.getfieldvalue('spccol',0) 119 119 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])) 121 121 procdata=procdata[0:-1,spccol] 122 122 -
issm/trunk-jpl/src/py3/qmu/dakota_in_data.py
r23677 r23709 1 1 #move this stuff elsewhere 2 2 from helpers import * 3 from dakota_in_write import dakota_in_write 4 from dakota_in_params import dakota_in_params 3 4 from dakota_in_write import * 5 from dakota_in_params import * 6 from MatlabFuncs import * 5 7 6 8 def dakota_in_data(dmeth,variables,responses,dparams,filei,*args): … … 43 45 # get default set of parameters 44 46 params=dakota_in_params(struct()) 45 46 47 # merge specified parameters into default set, whether or not 47 48 # they already exist 48 49 fnames=fieldnames(dparams) 49 50 50 for i in range(np.size(fnames)):51 if not isfield(params,f names[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)) 54 55 55 56 # use matlab even though we are running python -
issm/trunk-jpl/src/py3/qmu/dakota_in_params.py
r23677 r23709 182 182 183 183 return params 184 -
issm/trunk-jpl/src/py3/qmu/dakota_in_write.py
r23677 r23709 174 174 str_name = dmeth.variables[j] 175 175 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) 178 178 # are in the same dakota_write call regardless of individual size; 179 179 # but that each class has its own dakota_write call … … 213 213 elif params.system+params.fork+params.direct > 1: 214 214 raise RuntimeError('Too many interfaces selected.') 215 216 215 if params.system or params.fork: 217 216 param_write(fidi,'\t','asynchronous','','\n',params) … … 230 229 if len(params.input_filter) != 0: 231 230 param_write(fidi,'\t ','input_filter',' = ','\n',params) 232 231 233 232 if len(params.output_filter) != 0: 234 233 param_write(fidi,'\t ','output_filter',' = ','\n',params) 235 234 236 235 param_write(fidi,'\t ','failure_capture',' ','\n',params) 237 236 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) 240 239 param_write(fidi,'\t ','verbatim', '','\n',params) 241 240 param_write(fidi,'\t ','aprepro', '','\n',params) … … 257 256 if ext != '': 258 257 ext='.py' 259 258 260 259 params.analysis_components=fullfile(pathstr,name+ext) 261 260 param_write(fidi,'\t ','analysis_components',' = \'','\'\n',params) 262 261 263 262 if len(params.input_filter) != 0: 264 263 param_write(fidi,'\t ','input_filter',' = ','\n',params) 265 264 266 265 if len(params.output_filter) != 0: 267 266 param_write(fidi,'\t ','output_filter',' = ','\n',params) 268 267 269 268 param_write(fidi,'\t ','failure_capture',' ','\n',params) 270 269 param_write(fidi,'\t ','deactivate',' ','\n',params) … … 312 311 elif (params.numerical_gradients+params.analytic_gradients > 1): 313 312 raise RuntimeError('Too many gradients selected.') 314 313 315 314 if params.numerical_gradients: 316 315 param_write(fidi,'\t','numerical_gradients','','\n',params) … … 329 328 else: 330 329 fidi.write('\tno_hessians\n') 331 332 333 -
issm/trunk-jpl/src/py3/qmu/param_write.py
r23677 r23709 7 7 ''' 8 8 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)) 10 10 return 11 11 … … 19 19 20 20 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) 22 22 23 23 elif type(params_pname) in [int, float]: 24 24 fidi.write(sbeg+str(pname)+smid+str(params_pname)+s) 25 26 27 -
issm/trunk-jpl/src/py3/qmu/rlev_write.py
r23677 r23709 1 1 import numpy as np 2 #move this later 2 3 from helpers import * 3 from vector_write import vector_write 4 from param_write import param_write 5 from response_function import * 4 from vector_write import * 5 from param_write import * 6 #import relevent qmu classes 7 from MatlabArray import * 6 8 7 9 def rlevi_write(fidi,ltype,levels): … … 20 22 21 23 fidi.write('\n') 22 23 24 fidi.write('\t '+str(ltype)+' =\n') 24 25 … … 37 38 function to write response levels 38 39 ''' 40 from response_function import * 39 41 40 42 if len(dresp) == 0 or len(fieldnames(dresp[0])) == 0: … … 77 79 grell.extend(grelli) 78 80 81 79 82 # write response levels 83 80 84 respl=allempty(respl) 81 85 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 1 from MatlabFuncs import * 2 from uniform_uncertain import* 3 from normal_uncertain import * 3 4 from copy import deepcopy 4 5 … … 9 10 10 11 #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. 12 13 13 14 #ok, key off according to type of descriptor: … … 18 19 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)): 19 20 raise RuntimeError('QmuSetupDesign error message: upper and lower should be either a scalar or a "npart" length vector') 20 21 21 22 elif isinstance(variables,normal_uncertain): 22 23 if type(variables.stddev) in [list,np.ndarray] and len(variables.stddev) > md.qmu.numberofpartitions: 23 24 raise RuntimeError('QmuSetupDesign error message: stddev should be either a scalar or a "npart" length vector') 24 25 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 26 27 #partitions we want 27 28 … … 76 77 77 78 return dvar 79 -
issm/trunk-jpl/src/py3/qmu/vlist_write.py
r23677 r23709 2 2 #move this later 3 3 from helpers import * 4 from vector_write import vector_write 5 from normal_uncertain import normal_uncertain 4 5 from vector_write import * 6 7 from uniform_uncertain import * 8 from normal_uncertain import * 6 9 7 10 def check(a,l,p): … … 38 41 if dvar == None: 39 42 return 43 #from uniform_uncertain import * 40 44 func = eval(cstring) 41 45 -
issm/trunk-jpl/src/py3/solve/loadresultsfromcluster.py
r23670 r23709 37 37 md=loadresultsfromdisk(md,md.miscellaneous.name+'.outbin') 38 38 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)) 40 40 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)) 42 42 43 43 #erase the log and output files … … 88 88 os.remove(filename+extension) 89 89 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 12 12 """ 13 13 if md.verbose.solution: 14 print( "marshalling file '%s.bin'." % md.miscellaneous.name)14 print(("marshalling file '%s.bin'." % md.miscellaneous.name)) 15 15 16 16 #open file for binary writing -
issm/trunk-jpl/src/py3/solve/waitonlock.py
r23670 r23709 27 27 28 28 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) ')) 30 30 if not m.strcmp(choice,'y'): 31 31 print('Results not loaded... exiting') … … 44 44 etime=0 45 45 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)) 47 47 48 48 #loop till file .lock exist or time is up
Note:
See TracChangeset
for help on using the changeset viewer.