Changeset 353
- Timestamp:
- Oct 1, 2004, 1:51:12 PM (21 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/HUSK.txt
r297 r353 1 Have the quantity label e.g. elevation, associated with the data in sww files. 1 2 2 3 Do data manager for non-smooth data + tests. Smooth is OK (7/9) -
inundation/ga/storm_surge/pyvolution/least_squares.py
r346 r353 379 379 fit_to_mesh_file(mesh_file, point_file, mesh_output_file, alpha) 380 380 381 382 383 384 385 386 387 388 389 390 391 -
inundation/ga/storm_surge/pyvolution/test_data_manager.py
r282 r353 221 221 assert V[4,2] == 3 222 222 223 224 223 225 224 fid.close() 226 225 … … 258 257 time = fid.variables['time'] 259 258 stage = fid.variables['stage'] 260 259 261 260 262 261 Q = self.domain.quantities['level'] … … 401 400 402 401 402 def test_sww_DSG(self): 403 """Not a test, rather a look at the sww format 404 """ 405 406 import time, os 407 from Numeric import array, zeros, allclose, Float, concatenate 408 from Scientific.IO.NetCDF import NetCDFFile 409 410 self.domain.filename = 'datatest' + str(time.time()) 411 self.domain.format = 'sww' 412 self.domain.smooth = True 413 self.domain.reduction = mean 414 415 sww = get_dataobject(self.domain) 416 sww.store_connectivity() 417 sww.store_timestep('level') 418 419 #Check contents 420 #Get NetCDF 421 fid = NetCDFFile(sww.filename, 'r') 422 423 # Get the variables 424 x = fid.variables['x'] 425 y = fid.variables['y'] 426 z = fid.variables['z'] 427 428 volumes = fid.variables['volumes'] 429 time = fid.variables['time'] 430 431 # 2D 432 stage = fid.variables['stage'] 433 434 X = x[:] 435 Y = y[:] 436 Z = z[:] 437 V = volumes[:] 438 T = time[:] 439 S = stage[:,:] 440 441 # print "****************************" 442 # print "X ",X 443 # print "****************************" 444 # print "Y ",Y 445 # print "****************************" 446 # print "Z ",Z 447 # print "****************************" 448 # print "V ",V 449 # print "****************************" 450 # print "Time ",T 451 # print "****************************" 452 # print "Stage ",S 453 # print "****************************" 454 455 456 457 458 fid.close() 459 460 #Cleanup 461 os.remove(sww.filename) 462 403 463 #------------------------------------------------------------- 404 464 if __name__ == "__main__": -
inundation/ga/storm_surge/pyvolution/test_least_squares.py
r352 r353 5 5 6 6 from least_squares import * 7 from Numeric import allclose, array 7 from Numeric import allclose, array, transpose 8 8 9 9 def distance(x, y): … … 292 292 #print "answer",answer 293 293 assert allclose(z, answer) 294 295 294 295 def test_interpolate_attributes_to_pointsIII(self): 296 v0 = [0.0, 0.0] 297 v1 = [0.0, 5.0] 298 v2 = [5.0, 0.0] 299 300 vertices = [v0, v1, v2] 301 triangles = [ [1,0,2] ] #bac 302 303 d0 = [1.0, 1.0] 304 d1 = [1.0, 2.0] 305 d2 = [3.0,1.0] 306 point_coords = [ d0, d1, d2] 307 308 interp = Interpolation(vertices, triangles, point_coords) 309 f = [ [0., 0.], [5., 10.], [5., 10.]] #linear_function(vertices) 310 #print "f",f 311 312 z = interp.interpolate(f) 313 answer = [ [2., 4.], [3., 6.], [4., 8.]] 314 315 #print "***********" 316 #print "z",z 317 #print "answer",answer 318 #print "***********" 319 320 assert allclose(z, answer) 321 322 def test_interpolate_attributes_to_pointsIV(self): 323 a = [-1.0, 0.0] 324 b = [3.0, 4.0] 325 c = [4.0,1.0] 326 d = [-3.0, 2.0] #3 327 e = [-1.0,-2.0] 328 f = [1.0, -2.0] #5 329 330 vertices = [a, b, c, d,e,f] 331 triangles = [[0,1,3],[1,0,2],[0,4,5], [0,5,2]] #abd bac aef afc 332 333 334 point_coords = [[-2.0, 2.0], 335 [-1.0, 1.0], 336 [0.0,2.0], 337 [1.0, 1.0], 338 [2.0, 1.0], 339 [0.0,0.0], 340 [1.0, 0.0], 341 [0.0, -1.0], 342 [-0.2,-0.5], 343 [-0.9, -1.5], 344 [0.5, -1.9], 345 [3.0,1.0]] 346 347 interp = Interpolation(vertices, triangles, point_coords) 348 f = array([linear_function(vertices),2*linear_function(vertices) ]) 349 f = transpose(f) 350 #print "f",f 351 z = interp.interpolate(f) 352 answer = [linear_function(point_coords), 353 354 2*linear_function(point_coords) ] 355 answer = transpose(answer) 356 #print "z",z 357 #print "answer",answer 358 assert allclose(z, answer) 296 359 297 360 def test_smooth_attributes_to_mesh_function(self):
Note: See TracChangeset
for help on using the changeset viewer.