Changeset 4382
- Timestamp:
- Apr 16, 2007, 4:41:47 PM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/pmesh/mesh.py
r4182 r4382 25 25 26 26 27 class NoTrianglesError(exceptions.Exception): pass 27 28 28 29 #import load_mesh … … 3103 3104 """Reverses the transformation of region_strings2ints 3104 3105 """ 3106 if region_list == []: 3107 raise NoTrianglesError 3105 3108 if region_list[0] != []: 3106 3109 for i in xrange(len(region_list)): -
anuga_core/source/anuga/shallow_water/data_manager.py
r4381 r4382 73 73 convert_from_latlon_to_utm 74 74 from anuga.coordinate_transforms.geo_reference import Geo_reference 75 from anuga.geospatial_data.geospatial_data import Geospatial_data 75 from anuga.geospatial_data.geospatial_data import Geospatial_data,\ 76 ensure_absolute 76 77 from anuga.config import minimum_storable_height as default_minimum_storable_height 77 78 from anuga.utilities.numerical_tools import ensure_numeric, mean … … 4390 4391 NORTH_VELOCITY_LABEL = '_waveheight-n-mux' 4391 4392 def urs_ungridded2sww(basename_in='o', basename_out=None, verbose=False, 4392 mint=None, maxt=None, 4393 mean_stage=0, 4394 origin = None, 4395 zscale=1): 4393 mint=None, maxt=None, 4394 mean_stage=0, 4395 origin=None, 4396 hole_points_UTM=None, 4397 zscale=1): 4396 4398 """ 4397 4399 Convert URS C binary format for wave propagation to … … 4449 4451 +ve value in grid A and a -ve value in grid B. 4450 4452 """ 4451 from anuga.pmesh.mesh import Mesh 4453 from anuga.pmesh.mesh import Mesh, NoTrianglesError 4452 4454 4453 4455 files_in = [basename_in + WAVEHEIGHT_MUX_LABEL, … … 4487 4489 mesh.add_vertices(points_utm) 4488 4490 mesh.auto_segment() 4489 mesh.generate_mesh(minimum_triangle_angle=0.0, verbose=False) 4491 if hole_points_UTM is not None: 4492 point = ensure_absolute(hole_points_UTM) 4493 mesh.add_hole(point[0], point[1]) 4494 try: 4495 mesh.generate_mesh(minimum_triangle_angle=0.0, verbose=False) 4496 except NoTrianglesError: 4497 # This is a bit of a hack, going in and changing the 4498 # data structure. 4499 mesh.holes = [] 4500 mesh.generate_mesh(minimum_triangle_angle=0.0, verbose=False) 4490 4501 mesh_dic = mesh.Mesh2MeshList() 4491 4502 -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4381 r4382 5582 5582 self.delete_mux(files) 5583 5583 os.remove(sww_file) 5584 5585 5586 def test_urs_ungridded_hole (self): 5587 5588 #Zone: 50 5589 #Easting: 240992.578 Northing: 7620442.472 5590 #Latitude: -21 30 ' 0.00000 '' Longitude: 114 30 ' 0.00000 '' 5591 lat_long = [[-20.5, 114.5], 5592 [-20.6, 114.6], 5593 [-20.5, 115.], 5594 [-20.6, 115.], 5595 [-20.5, 115.5], 5596 [-20.6, 115.4], 5597 5598 [-21., 114.5], 5599 [-21., 114.6], 5600 [-21., 115.5], 5601 [-21., 115.4], 5602 5603 [-21.5, 114.5], 5604 [-21.4, 114.6], 5605 [-21.5, 115.], 5606 [-21.4, 115.], 5607 [-21.5, 115.5], 5608 [-21.4, 115.4] 5609 ] 5610 time_step_count = 6 5611 time_step = 100 5612 tide = 9000000 5613 base_name, files = self.write_mux(lat_long, 5614 time_step_count, time_step) 5615 #Easting: 292110.784 Northing: 7676551.710 5616 #Latitude: -21 0 ' 0.00000 '' Longitude: 115 0 ' 0.00000 '' 5617 5618 urs_ungridded2sww(base_name, mean_stage=-240992.0, 5619 hole_points_UTM=[ 292110.784, 7676551.710 ]) 5620 5621 # now I want to check the sww file ... 5622 sww_file = base_name + '.sww' 5623 5624 #Let's interigate the sww file 5625 # Note, the sww info is not gridded. It is point data. 5626 fid = NetCDFFile(sww_file) 5627 5628 number_of_volumes = fid.variables['volumes'] 5629 #print "number_of_volumes",len(number_of_volumes) 5630 assert allclose(12, len(number_of_volumes)) 5631 5632 fid.close() 5633 self.delete_mux(files) 5634 #print "sww_file", sww_file 5635 os.remove(sww_file) 5636 5637 def test_urs_ungridded_holeII(self): 5638 5639 # Check that if using a hole that returns no triangles, 5640 # urs_ungridded2sww removes the hole label. 5641 5642 lat_long = [[-20.5, 114.5], 5643 [-20.6, 114.6], 5644 [-20.5, 115.5], 5645 [-20.6, 115.4], 5646 5647 5648 [-21.5, 114.5], 5649 [-21.4, 114.6], 5650 [-21.5, 115.5], 5651 [-21.4, 115.4] 5652 ] 5653 time_step_count = 6 5654 time_step = 100 5655 tide = 9000000 5656 base_name, files = self.write_mux(lat_long, 5657 time_step_count, time_step) 5658 #Easting: 292110.784 Northing: 7676551.710 5659 #Latitude: -21 0 ' 0.00000 '' Longitude: 115 0 ' 0.00000 '' 5660 5661 urs_ungridded2sww(base_name, mean_stage=-240992.0, 5662 hole_points_UTM=[ 292110.784, 7676551.710 ]) 5663 5664 # now I want to check the sww file ... 5665 sww_file = base_name + '.sww' 5666 fid = NetCDFFile(sww_file) 5667 5668 volumes = fid.variables['volumes'] 5669 #print "number_of_volumes",len(volumes) 5670 5671 fid.close() 5672 os.remove(sww_file) 5673 5674 urs_ungridded2sww(base_name, mean_stage=-240992.0) 5675 5676 # now I want to check the sww file ... 5677 sww_file = base_name + '.sww' 5678 fid = NetCDFFile(sww_file) 5679 5680 volumes_again = fid.variables['volumes'] 5681 #print "number_of_volumes",len(volumes_again) 5682 assert allclose(len(volumes_again), 5683 len(volumes)) 5684 fid.close() 5685 os.remove(sww_file) 5686 self.delete_mux(files) 5584 5687 5585 5688 def test_urs_ungridded2sww_mint_maxt (self): … … 5873 5976 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sww') 5874 5977 #suite = unittest.makeSuite(Test_Data_Manager,'cache_test_URS_points_needed_and_urs_ungridded2sww') 5875 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs 2sww_momentum')5978 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_hole') 5876 5979 suite = unittest.makeSuite(Test_Data_Manager,'test') 5877 5980 runner = unittest.TextTestRunner() #verbosity=2)
Note: See TracChangeset
for help on using the changeset viewer.