Changeset 3529
- Timestamp:
- Aug 25, 2006, 11:19:49 AM (17 years ago)
- Location:
- anuga_core/source/anuga/pyvolution
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/pyvolution/data_manager.py
r3514 r3529 67 67 from anuga.coordinate_transforms.geo_reference import Geo_reference 68 68 from anuga.geospatial_data.geospatial_data import Geospatial_data 69 69 from anuga.config import minimum_allowed_depth 70 70 71 71 def make_filename(s): … … 252 252 Data_format.__init__(self, domain, 'sww', mode) 253 253 254 if hasattr(domain, 'minimum_allowed_depth'): 255 self.minimum_allowed_depth = domain.minimum_allowed_depth 256 else: 257 self.minimum_allowed_depth = minimum_allowed_depth 254 258 255 259 # NetCDF file definition … … 478 482 #print z[:] 479 483 #print A-z[:] 480 A = choose( A-z[:] >= minimum_allowed_depth, (z[:], A)) 484 A = choose( A-z[:] >= self.minimum_allowed_depth, 485 (z[:], A)) 481 486 stage[i,:] = A.astype(self.precision) 482 487 elif name == 'xmomentum': -
anuga_core/source/anuga/pyvolution/shallow_water.py
r3514 r3529 63 63 64 64 from anuga.utilities.numerical_tools import gradient, mean 65 65 from anuga.config import minimum_allowed_depth 66 66 67 67 … … 126 126 self.format = 'sww' 127 127 self.set_store_vertices_uniquely(False) 128 128 self.minimum_allowed_depth = minimum_allowed_depth 129 129 self.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] 130 130 -
anuga_core/source/anuga/pyvolution/test_data_manager.py
r3514 r3529 459 459 460 460 461 462 def test_sww_DSG(self): 461 def test_sww_minimum_allowed_depth(self): 462 """Test that sww information can be written correctly 463 multiple timesteps using a different reduction operator (min) 464 """ 465 466 import time, os 467 from Numeric import array, zeros, allclose, Float, concatenate 468 from Scientific.IO.NetCDF import NetCDFFile 469 470 self.domain.filename = 'datatest' + str(id(self)) 471 self.domain.format = 'sww' 472 self.domain.smooth = True 473 self.domain.reduction = min 474 self.domain.minimum_allowed_depth = 100 475 476 sww = get_dataobject(self.domain) 477 sww.store_connectivity() 478 sww.store_timestep('stage') 479 480 self.domain.evolve_to_end(finaltime = 0.01) 481 sww.store_timestep('stage') 482 483 484 #Check contents 485 #Get NetCDF 486 fid = NetCDFFile(sww.filename, 'r') 487 488 489 # Get the variables 490 x = fid.variables['x'] 491 y = fid.variables['y'] 492 z = fid.variables['elevation'] 493 time = fid.variables['time'] 494 stage = fid.variables['stage'] 495 496 #Check values 497 Q = self.domain.quantities['stage'] 498 Q0 = Q.vertex_values[:,0] 499 Q1 = Q.vertex_values[:,1] 500 Q2 = Q.vertex_values[:,2] 501 502 A = stage[1,:] 503 assert allclose(stage[1,:], z[:]) 504 fid.close() 505 506 #Cleanup 507 os.remove(sww.filename) 508 509 510 def Not_a_test_sww_DSG(self): 463 511 """Not a test, rather a look at the sww format 464 512 """ … … 4944 4992 #------------------------------------------------------------- 4945 4993 if __name__ == "__main__": 4946 #suite = unittest.makeSuite(Test_Data_Manager,'test_ exposure_csv_loading_x_y2')4994 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_minimum_allowed_depth') 4947 4995 suite = unittest.makeSuite(Test_Data_Manager,'test') 4948 4996 runner = unittest.TextTestRunner()
Note: See TracChangeset
for help on using the changeset viewer.