- Timestamp:
- Apr 23, 2010, 4:46:14 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/test_gauge.py
r7690 r7693 301 301 302 302 303 #def test_sww2csv_gauge_point_off_mesh(self):304 #from anuga.pmesh.mesh import Mesh305 #from anuga.shallow_water import Domain, Transmissive_boundary306 #from csv import reader,writer307 #import time308 #import string309 310 #"""Most of this test was copied from test_interpolate311 #test_interpole_sww2csv312 313 #This is testing the sww2csv_gauges function with one gauge off the mesh, by creating a sww file and314 #then exporting the gauges and checking the results.315 316 #This tests the correct values for when a gauge is off the mesh, which is important for parallel.317 #"""318 319 #domain = self.domain320 # self._create_sww()303 def test_sww2csv_gauge_point_off_mesh(self): 304 from anuga.pmesh.mesh import Mesh 305 from anuga.shallow_water import Domain, Transmissive_boundary 306 from csv import reader,writer 307 import time 308 import string 309 310 """Most of this test was copied from test_interpolate 311 test_interpole_sww2csv 312 313 This is testing the sww2csv_gauges function with one gauge off the mesh, by creating a sww file and 314 then exporting the gauges and checking the results. 315 316 This tests the correct values for when a gauge is off the mesh, which is important for parallel. 317 """ 318 319 domain = self.domain 320 sww = self._create_sww() 321 321 322 # # test the function 323 # points = [[50.0,1.],[50.5,-20.25]] 324 325 # # points_file = tempfile.mktemp(".csv") 326 # points_file = 'test_point.csv' 327 # file_id = open(points_file,"w") 328 # file_id.write("name,easting,northing \n\ 329 # point1, 50.0, 1.0\n\ 330 # point2, 50.5, 20.25\n") 331 # file_id.close() 332 333 # sww2csv_gauges(sww.filename, 334 # points_file, 335 # quantities=['stage', 'elevation'], 336 # use_cache=False, 337 # verbose=False) 338 339 # point1_answers_array = [[0.0,1.0,-5.0], [2.0,10.0,-5.0]] 340 # point1_filename = 'gauge_point1.csv' 341 # point1_handle = file(point1_filename) 342 # point1_reader = reader(point1_handle) 343 # point1_reader.next() 344 345 # line=[] 346 # for i,row in enumerate(point1_reader): 347 # # print 'i',i,'row',row 348 # # note the 'hole' (element 1) below - skip the new 'hours' field 349 # line.append([float(row[0]),float(row[2]),float(row[3])]) 350 # #print 'line',line[i],'point1',point1_answers_array[i] 351 # assert num.allclose(line[i], point1_answers_array[i]) 352 353 # point2_answers_array = [[0.0,1.0,-0.5], [2.0,10.0,-0.5]] 354 # point2_filename = 'gauge_point2.csv' 355 # point2_handle = file(point2_filename) 356 # point2_reader = reader(point2_handle) 357 # point2_reader.next() 358 359 # line=[] 360 # for i,row in enumerate(point2_reader): 361 # # print 'i',i,'row',row 362 # # note the 'hole' (element 1) below - skip the new 'hours' field 363 # line.append([float(row[0]),float(row[2]),float(row[3])]) 364 # # print 'line',line[i],'point1',point1_answers_array[i] 365 # assert num.allclose(line[i], point2_answers_array[i]) 366 367 # # clean up 368 # point1_handle.close() 369 # point2_handle.close() 370 # os.remove(points_file) 371 # # os.remove(point1_filename) 372 # # os.remove(point2_filename) 322 # test the function 323 points = [[50.0,1.],[50.5,-20.25]] 324 325 # points_file = tempfile.mktemp(".csv") 326 points_file = 'test_point.csv' 327 file_id = open(points_file,"w") 328 file_id.write("name,easting,northing \n\ 329 offmesh1, 50.0, 1.0\n\ 330 offmesh2, 50.5, 20.25\n") 331 file_id.close() 332 333 points_files = ['offmesh1.csv', 'offmesh2.csv'] 334 335 for point_filename in points_files: 336 if os.path.exists(point_filename): os.remove(point_filename) 337 338 sww2csv_gauges(self.sww.filename, 339 points_file, 340 quantities=['stage', 'elevation', 'bearing'], 341 use_cache=False, 342 verbose=False) 343 344 for point_filename in points_files: 345 assert not os.path.exists(point_filename) 346 347 os.remove(points_file) 373 348 374 349
Note: See TracChangeset
for help on using the changeset viewer.