Changeset 4013


Ignore:
Timestamp:
Nov 20, 2006, 4:16:43 PM (16 years ago)
Author:
duncan
Message:

testing that origin works in urs2sww

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r3975 r4013  
    47124712        # the elevation
    47134713        assert allclose(-elevation, y)  #Meters
    4714 
    47154714       
    47164715        fid.close()
    4717 
    4718 
    47194716        self.delete_mux(files)
    47204717        os.remove(sww_file)
    47214718       
     4719 
     4720    def test_urs2sww_origin(self):
     4721        tide = 1
     4722        base_name, files = self.create_mux()
     4723        urs2sww(base_name
     4724                , origin=(0,0,0)
     4725                , mean_stage=tide
     4726                , remove_nc_files=False
     4727                )
     4728        sww_file = base_name + '.sww'
     4729       
     4730        #Let's interigate the sww file
     4731        # Note, the sww info is not gridded.  It is point data.
     4732        fid = NetCDFFile(sww_file)
     4733
     4734        #  x and y are absolute
     4735        x = fid.variables['x'][:]
     4736        y = fid.variables['y'][:]
     4737        geo_reference = Geo_reference(NetCDFObject=fid)
     4738
     4739       
     4740        #Check that first coordinate is correctly represented       
     4741        #Work out the UTM coordinates for first point
     4742        zone, e, n = redfearn(-34.5, 150.66667)       
     4743       
     4744        assert allclose([x[0],y[0]], [e,n])
     4745
     4746       
     4747        #Check first value
     4748        stage = fid.variables['stage'][:]
     4749        xmomentum = fid.variables['xmomentum'][:]
     4750        ymomentum = fid.variables['ymomentum'][:]
     4751        elevation = fid.variables['elevation'][:]
     4752        assert allclose(stage[0,0], e +tide)  #Meters
     4753
     4754        #Check the momentums - ua
     4755        #momentum = velocity*(stage-elevation)
     4756        #momentum = velocity*(stage+elevation)
     4757        # -(-elevation) since elevation is inverted in mux files
     4758        # = n*(e+tide+n) based on how I'm writing these files
     4759        answer = n*(e+tide+n)
     4760        actual = xmomentum[0,0]
     4761        assert allclose(answer, actual)  #Meters
     4762
     4763        # check the stage values, first time step.
     4764        # These arrays are equal since the Easting values were used as
     4765        # the stage
     4766        assert allclose(stage[0], x +tide)  #Meters
     4767
     4768        # check the elevation values.
     4769        # -ve since urs measures depth, sww meshers height,
     4770        # these arrays are equal since the northing values were used as
     4771        # the elevation
     4772        assert allclose(-elevation, y)  #Meters
     4773       
     4774        fid.close()
     4775        self.delete_mux(files)
     4776        os.remove(sww_file)
    47224777       
    47234778    def test_lon_lat2grid(self):
Note: See TracChangeset for help on using the changeset viewer.