Changeset 1102
- Timestamp:
- Mar 17, 2005, 7:12:46 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/data_manager.py
r1090 r1102 1183 1183 minlon = None, maxlon = None, 1184 1184 mint = None, maxt = None, mean_stage = 0, 1185 origin = None, zscale = 1, 1185 origin = None, zscale = 1, 1186 fail_on_NaN = True, 1187 NaN_filler = 0, 1186 1188 elevation = -100): #FIXME: Bathymetry should be obtained 1187 1189 #from MOST somehow. … … 1277 1279 uspeed = file_u.variables['UA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lon 1278 1280 vspeed = file_v.variables['VA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lat 1281 1282 #Get missing values 1283 nan_ha = file_h.variables['HA'].missing_value[0] 1284 nan_ua = file_u.variables['UA'].missing_value[0] 1285 nan_va = file_v.variables['VA'].missing_value[0] 1286 1287 1288 #Cleanup 1289 from Numeric import sometrue 1290 1291 missing = (amplitudes == nan_ha) 1292 if sometrue (missing): 1293 if fail_on_NaN: 1294 msg = 'NetCDFFile %s contains missing values'\ 1295 %(basename_in+'_ha.nc') 1296 raise msg 1297 else: 1298 amplitudes = amplitudes*(missing==0) + missing*NaN_filler 1299 1300 missing = (uspeed == nan_ua) 1301 if sometrue (missing): 1302 if fail_on_NaN: 1303 msg = 'NetCDFFile %s contains missing values'\ 1304 %(basename_in+'_ua.nc') 1305 raise msg 1306 else: 1307 uspeed = uspeed*(missing==0) + missing*NaN_filler 1308 1309 missing = (vspeed == nan_va) 1310 if sometrue (missing): 1311 if fail_on_NaN: 1312 msg = 'NetCDFFile %s contains missing values'\ 1313 %(basename_in+'_va.nc') 1314 raise msg 1315 else: 1316 vspeed = vspeed*(missing==0) + missing*NaN_filler 1317 1318 1319 1320 ####### 1321 1322 1279 1323 1280 1324 number_of_times = times.shape[0] … … 1322 1366 1323 1367 1324 if verbose: print 'Store to SWW file %s' %swwname1325 1368 # NetCDF file definition 1326 1369 outfile = NetCDFFile(swwname, 'w') … … 1385 1428 1386 1429 1430 if verbose: print 'Making triangular grid' 1387 1431 #Check zone boundaries 1388 1432 refzone, _, _ = redfearn(latitudes[0],longitudes[0]) … … 1444 1488 outfile.variables['z'][:] = z 1445 1489 outfile.variables['elevation'][:] = z #FIXME HACK 1446 outfile.variables['time'][:] = times 1490 outfile.variables['time'][:] = times - times[0] #Store time relative 1447 1491 outfile.variables['volumes'][:] = volumes.astype(Int32) #On Opteron 64 1448 1492 … … 1455 1499 1456 1500 1457 1458 for j in range(len(times)): 1501 if verbose: print 'Converting quantities' 1502 n = len(times) 1503 for j in range(n): 1504 if verbose and j%((n+10)/10)==0: print ' Doing %d of %d' %(j, n) 1459 1505 i = 0 1460 1506 for k in range(number_of_latitudes): #Y direction … … 1478 1524 print ' Lower left corner: [%f, %f]'\ 1479 1525 %(xllcorner, yllcorner) 1526 print ' Start time: %f' %times[0] 1480 1527 print ' Extent:' 1481 1528 print ' x [m] in [%f, %f], len(x) == %d'\ -
inundation/ga/storm_surge/pyvolution/domain.py
r1087 r1102 72 72 self.starttime = 0 #Physical starttime if any (0 is 1 Jan 1970 00:00:00) 73 73 #Origin in UTM coordinates 74 #FIXME: This should be set if read by a msh file 74 75 self.zone = zone 75 76 self.xllcorner = xllcorner -
inundation/ga/storm_surge/pyvolution/generic_boundary_conditions.py
r900 r1102 245 245 return self.F(t, point_id = i) 246 246 else: 247 return self.F(t) #FIXME: What should the semantics be? 247 #raise 'Boundary call without point_id not implemented' 248 #FIXME: What should the semantics be? 249 return self.F(t) 248 250 249 251 -
inundation/ga/storm_surge/pyvolution/util.py
r1093 r1102 209 209 210 210 if domain is not None: 211 msg = 'WARNING: Start time as specified in domain (% s)'\211 msg = 'WARNING: Start time as specified in domain (%f)'\ 212 212 %domain.starttime 213 msg += ' is earlier than the starttime of file %s : %s.'\213 msg += ' is earlier than the starttime of file %s (%f).'\ 214 214 %(self.filename, self.starttime) 215 msg += ' Modifyingstarttime accordingly.'215 msg += ' Modifying domain starttime accordingly.' 216 216 if self.starttime > domain.starttime: 217 #FIXME: Print depending on some verbosity setting 218 #print msg 217 if verbose: print msg 219 218 domain.starttime = self.starttime #Modifying model time 219 if verbose: print 'Domain starttime is now set to %f' %domain.starttime 220 220 221 221 #Read all data in and produce values for desired data points at each timestep … … 237 237 238 238 #Get variables 239 if verbose: print 'Get vari bles'239 if verbose: print 'Get variables' 240 240 x = fid.variables['x'][:] 241 241 y = fid.variables['y'][:] … … 298 298 print ' Lower left corner: [%f, %f]'\ 299 299 %(self.xllcorner, self.yllcorner) 300 print ' Start time: %f' %self.starttime 300 print ' Start time (file): %f' %self.starttime 301 #print ' Start time (domain): %f' %domain.starttime 301 302 print ' Extent:' 302 303 print ' x in [%f, %f], len(x) == %d'\ … … 366 367 tau = self.domain.starttime-self.starttime+t 367 368 else: 369 #print 'DOMAIN IS NONE!!!!!!!!!' 368 370 tau = t 369 371 … … 375 377 msg = 'Time interval derived from file %s [%s:%s]'\ 376 378 %(self.filename, self.T[0], self.T[1]) 377 msg += ' does not match model time: %s' %tau 379 msg += ' does not match model time: %s\n' %tau 380 msg += 'Domain says its starttime == %f' %(self.domain.starttime) 378 381 379 382 if tau < self.T[0]: raise msg … … 514 517 if self.starttime > domain.starttime: 515 518 #FIXME: Print depending on some verbosity setting 516 # print msg519 ##if verbose: print msg 517 520 domain.starttime = self.starttime #Modifying model time 518 521
Note: See TracChangeset
for help on using the changeset viewer.