- Timestamp:
- Mar 6, 2007, 10:56:39 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4284 r4295 5436 5436 os.remove(sww_file) 5437 5437 5438 def test_urs_ungridded2sww_mint_maxt (self): 5439 5440 #Zone: 50 5441 #Easting: 240992.578 Northing: 7620442.472 5442 #Latitude: -21 30 ' 0.00000 '' Longitude: 114 30 ' 0.00000 '' 5443 lat_long = [[-21.5,114.5],[-21,114.5],[-21,115]] 5444 time_step_count = 6 5445 time_step = 100 5446 tide = 9000000 5447 base_name, files = self.write_mux(lat_long, 5448 time_step_count, time_step) 5449 urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343), 5450 mint=101, maxt=500) 5451 5452 # now I want to check the sww file ... 5453 sww_file = base_name + '.sww' 5454 5455 #Let's interigate the sww file 5456 # Note, the sww info is not gridded. It is point data. 5457 fid = NetCDFFile(sww_file) 5458 5459 # Make x and y absolute 5460 x = fid.variables['x'][:] 5461 y = fid.variables['y'][:] 5462 geo_reference = Geo_reference(NetCDFObject=fid) 5463 points = geo_reference.get_absolute(map(None, x, y)) 5464 points = ensure_numeric(points) 5465 x = points[:,0] 5466 y = points[:,1] 5467 5468 #Check that first coordinate is correctly represented 5469 #Work out the UTM coordinates for first point 5470 zone, e, n = redfearn(lat_long[0][0], lat_long[0][1]) 5471 assert allclose([x[0],y[0]], [e,n]) 5472 5473 #Check the time vector 5474 times = fid.variables['time'][:] 5475 5476 times_actual = [200,300,400,500] 5477 5478 assert allclose(ensure_numeric(times), 5479 ensure_numeric(times_actual)) 5480 5481 #Check first value 5482 stage = fid.variables['stage'][:] 5483 xmomentum = fid.variables['xmomentum'][:] 5484 ymomentum = fid.variables['ymomentum'][:] 5485 elevation = fid.variables['elevation'][:] 5486 assert allclose(stage[0,0], e +tide) #Meters 5487 5488 #Check the momentums - ua 5489 #momentum = velocity*(stage-elevation) 5490 #momentum = velocity*(stage+elevation) 5491 # -(-elevation) since elevation is inverted in mux files 5492 # = n*(e+tide+n) based on how I'm writing these files 5493 answer = n*(e+tide+n) 5494 actual = xmomentum[0,0] 5495 assert allclose(answer, actual) #Meters 5496 5497 # check the stage values, first time step. 5498 # These arrays are equal since the Easting values were used as 5499 # the stage 5500 assert allclose(stage[0], x +tide) #Meters 5501 # check the elevation values. 5502 # -ve since urs measures depth, sww meshers height, 5503 # these arrays are equal since the northing values were used as 5504 # the elevation 5505 assert allclose(-elevation, y) #Meters 5506 5507 fid.close() 5508 self.delete_mux(files) 5509 os.remove(sww_file) 5510 5511 def test_urs_ungridded2sww_mint_maxtII (self): 5512 5513 #Zone: 50 5514 #Easting: 240992.578 Northing: 7620442.472 5515 #Latitude: -21 30 ' 0.00000 '' Longitude: 114 30 ' 0.00000 '' 5516 lat_long = [[-21.5,114.5],[-21,114.5],[-21,115]] 5517 time_step_count = 6 5518 time_step = 100 5519 tide = 9000000 5520 base_name, files = self.write_mux(lat_long, 5521 time_step_count, time_step) 5522 urs_ungridded2sww(base_name, mean_stage=tide, origin =(50,23432,4343), 5523 mint=0, maxt=100000) 5524 5525 # now I want to check the sww file ... 5526 sww_file = base_name + '.sww' 5527 5528 #Let's interigate the sww file 5529 # Note, the sww info is not gridded. It is point data. 5530 fid = NetCDFFile(sww_file) 5531 5532 # Make x and y absolute 5533 geo_reference = Geo_reference(NetCDFObject=fid) 5534 points = geo_reference.get_absolute(map(None, fid.variables['x'][:], 5535 fid.variables['y'][:])) 5536 points = ensure_numeric(points) 5537 x = points[:,0] 5538 5539 #Check the time vector 5540 times = fid.variables['time'][:] 5541 5542 times_actual = [0,100,200,300,400,500] 5543 assert allclose(ensure_numeric(times), 5544 ensure_numeric(times_actual)) 5545 5546 #Check first value 5547 stage = fid.variables['stage'][:] 5548 assert allclose(stage[0], x +tide) 5549 5550 fid.close() 5551 self.delete_mux(files) 5552 os.remove(sww_file) 5553 5554 def test_urs_ungridded2sww_mint_maxtIII (self): 5555 5556 #Zone: 50 5557 #Easting: 240992.578 Northing: 7620442.472 5558 #Latitude: -21 30 ' 0.00000 '' Longitude: 114 30 ' 0.00000 '' 5559 lat_long = [[-21.5,114.5],[-21,114.5],[-21,115]] 5560 time_step_count = 6 5561 time_step = 100 5562 tide = 9000000 5563 base_name, files = self.write_mux(lat_long, 5564 time_step_count, time_step) 5565 try: 5566 urs_ungridded2sww(base_name, mean_stage=tide, 5567 origin =(50,23432,4343), 5568 mint=301, maxt=399) 5569 except: 5570 pass 5571 else: 5572 self.failUnless(0 ==1, 'Bad input did not throw exception error!') 5573 5574 self.delete_mux(files) 5575 5438 5576 def test_URS_points_needed_and_urs_ungridded2sww(self): 5439 5577 # This doesn't actually check anything
Note: See TracChangeset
for help on using the changeset viewer.