Changeset 3529


Ignore:
Timestamp:
Aug 25, 2006, 11:19:49 AM (17 years ago)
Author:
duncan
Message:

minimum_allowed_depth is now an attribute of domain

Location:
anuga_core/source/anuga/pyvolution
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/pyvolution/data_manager.py

    r3514 r3529  
    6767from anuga.coordinate_transforms.geo_reference import Geo_reference
    6868from anuga.geospatial_data.geospatial_data import Geospatial_data
    69 
     69from anuga.config import minimum_allowed_depth
    7070
    7171def make_filename(s):
     
    252252        Data_format.__init__(self, domain, 'sww', mode)
    253253
     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
    254258
    255259        # NetCDF file definition
     
    478482                    #print z[:]
    479483                    #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))
    481486                    stage[i,:] = A.astype(self.precision)
    482487                elif name == 'xmomentum':
  • anuga_core/source/anuga/pyvolution/shallow_water.py

    r3514 r3529  
    6363
    6464from anuga.utilities.numerical_tools import gradient, mean
    65 
     65from anuga.config import minimum_allowed_depth
    6666
    6767
     
    126126        self.format = 'sww'
    127127        self.set_store_vertices_uniquely(False)
    128 
     128        self.minimum_allowed_depth = minimum_allowed_depth
    129129        self.quantities_to_be_stored = ['stage','xmomentum','ymomentum']
    130130
  • anuga_core/source/anuga/pyvolution/test_data_manager.py

    r3514 r3529  
    459459
    460460
    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):
    463511        """Not a test, rather a look at the sww format
    464512        """
     
    49444992#-------------------------------------------------------------
    49454993if __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')
    49474995    suite = unittest.makeSuite(Test_Data_Manager,'test')
    49484996    runner = unittest.TextTestRunner()
Note: See TracChangeset for help on using the changeset viewer.