Changeset 2891 for inundation/pyvolution/test_data_manager.py
- Timestamp:
- May 17, 2006, 12:11:37 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/test_data_manager.py
r2658 r2891 1996 1996 1997 1997 #Export to ers files 1998 #sww2ers(self.domain.filename,1999 # quantity = 'elevation',2000 # cellsize = cellsize,2001 # verbose = False)2002 2003 1998 sww2dem(self.domain.filename, 2004 1999 quantity = 'elevation', … … 2049 2044 os.remove(self.domain.filename + '_elevation') 2050 2045 os.remove(self.domain.filename + '_elevation.ers') 2046 2047 2048 2049 def test_sww2pts_centroids(self): 2050 """Test that sww information can be converted correctly to pts data at specified coordinates 2051 - in this case, the centroids. 2052 """ 2053 2054 import time, os 2055 from Numeric import array, zeros, allclose, Float, concatenate, NewAxis 2056 from Scientific.IO.NetCDF import NetCDFFile 2057 from geospatial_data import Geospatial_data 2058 2059 # Used for points that lie outside mesh 2060 NODATA_value = 1758323 2061 2062 # Setup 2063 self.domain.filename = 'datatest' 2064 2065 ptsfile = self.domain.filename + '_elevation.pts' 2066 swwfile = self.domain.filename + '.sww' 2067 2068 self.domain.set_datadir('.') 2069 self.domain.format = 'sww' 2070 self.smooth = True #self.set_store_vertices_uniquely(False) 2071 self.domain.set_quantity('elevation', lambda x,y: -x-y) 2072 2073 self.domain.geo_reference = Geo_reference(56,308500,6189000) 2074 2075 sww = get_dataobject(self.domain) 2076 sww.store_connectivity() 2077 sww.store_timestep('stage') 2078 2079 self.domain.evolve_to_end(finaltime = 0.01) 2080 sww.store_timestep('stage') 2081 2082 # Check contents in NetCDF 2083 fid = NetCDFFile(sww.filename, 'r') 2084 2085 # Get the variables 2086 x = fid.variables['x'][:] 2087 y = fid.variables['y'][:] 2088 elevation = fid.variables['elevation'][:] 2089 time = fid.variables['time'][:] 2090 stage = fid.variables['stage'][:] 2091 2092 volumes = fid.variables['volumes'][:] 2093 2094 2095 # Invoke interpolation for vertex points 2096 points = concatenate( (x[:,NewAxis],y[:,NewAxis]), axis=1 ) 2097 sww2pts(self.domain.filename, 2098 quantity = 'elevation', 2099 data_points = points, 2100 NODATA_value = NODATA_value, 2101 verbose = False) 2102 ref_point_values = elevation 2103 point_values = Geospatial_data(ptsfile).get_attributes() 2104 #print 'P', point_values 2105 #print 'Ref', ref_point_values 2106 assert allclose(point_values, ref_point_values) 2107 2108 2109 2110 # Invoke interpolation for centroids 2111 points = self.domain.get_centroid_coordinates() 2112 #print points 2113 sww2pts(self.domain.filename, 2114 quantity = 'elevation', 2115 data_points = points, 2116 NODATA_value = NODATA_value, 2117 verbose = False) 2118 ref_point_values = [-0.5, -0.5, -1, -1, -1, -1, -1.5, -1.5] #At centroids 2119 2120 2121 point_values = Geospatial_data(ptsfile).get_attributes() 2122 #print 'P', point_values 2123 #print 'Ref', ref_point_values 2124 assert allclose(point_values, ref_point_values) 2125 2126 2127 2128 fid.close() 2129 2130 #Cleanup 2131 os.remove(sww.filename) 2132 os.remove(ptsfile) 2133 2051 2134 2052 2135
Note: See TracChangeset
for help on using the changeset viewer.