Changeset 5189
- Timestamp:
- Apr 2, 2008, 11:36:59 AM (17 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r5115 r5189 1945 1945 %(min(times), max(times), len(times)) 1946 1946 print ' Quantities [SI units]:' 1947 # Comment out for reduced memory consumption 1947 1948 for name in ['stage', 'xmomentum', 'ymomentum']: 1948 1949 q = fid.variables[name][:].flat … … 1960 1961 try: 1961 1962 q = fid.variables[quantity][:] 1963 1964 1962 1965 except: 1963 1966 quantity_dict = {} … … 1966 1969 #Convert quantity expression to quantities found in sww file 1967 1970 q = apply_expression_to_dictionary(quantity, quantity_dict) 1968 1971 #print "q.shape",q.shape 1969 1972 if len(q.shape) == 2: 1970 1973 #q has a time component and needs to be reduced along … … 2163 2166 fid.close() 2164 2167 return basename_out 2168 2165 2169 2166 2170 #Backwards compatibility … … 5849 5853 return iterate_over 5850 5854 5855 def points2polygon(points_file, 5856 minimum_triangle_angle=3.0): 5857 """ 5858 WARNING: This function is not fully working. 5859 5860 Function to return a polygon returned from alpha shape, given a points file. 5861 5862 WARNING: Alpha shape returns multiple polygons, but this function only returns one polygon. 5863 5864 """ 5865 from anuga.pmesh.mesh import Mesh, importMeshFromFile 5866 from anuga.shallow_water import Domain 5867 from anuga.pmesh.mesh_interface import create_mesh_from_regions 5868 5869 mesh = importMeshFromFile(points_file) 5870 mesh.auto_segment() 5871 mesh.exportASCIIsegmentoutlinefile("outline.tsh") 5872 mesh2 = importMeshFromFile("outline.tsh") 5873 mesh2.generate_mesh(maximum_triangle_area=1000000000, minimum_triangle_angle=minimum_triangle_angle, verbose=False) 5874 mesh2.export_mesh_file('outline_meshed.tsh') 5875 domain = Domain("outline_meshed.tsh", use_cache = False) 5876 polygon = domain.get_boundary_polygon() 5877 return polygon 5851 5878 5852 5879 #------------------------------------------------------------- … … 5858 5885 import os 5859 5886 os.umask(umask) 5860 -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5175 r5189 25 25 from anuga.coordinate_transforms.geo_reference import Geo_reference, \ 26 26 DEFAULT_ZONE 27 from anuga.geospatial_data.geospatial_data import Geospatial_data 27 28 28 29 class Test_Data_Manager(unittest.TestCase): … … 2752 2753 from Numeric import array, zeros, allclose, Float, concatenate, NewAxis 2753 2754 from Scientific.IO.NetCDF import NetCDFFile 2754 from anuga.geospatial_data.geospatial_data import Geospatial_data2755 2756 2755 # Used for points that lie outside mesh 2757 2756 NODATA_value = 1758323 … … 7391 7390 assert (file_line2 == 'goodbye screen catcher\n') 7392 7391 7392 7393 def test_points2polygon(self): 7394 att_dict = {} 7395 pointlist = array([[1.0, 0.0],[0.0, 1.0],[0.0, 0.0]]) 7396 att_dict['elevation'] = array([10.1, 0.0, 10.4]) 7397 att_dict['brightness'] = array([10.0, 1.0, 10.4]) 7398 7399 fileName = tempfile.mktemp(".csv") 7400 7401 G = Geospatial_data(pointlist, att_dict) 7402 7403 G.export_points_file(fileName) 7404 7405 polygon = points2polygon(fileName) 7406 7407 # This test may fail if the order changes 7408 assert (polygon == [[0.0, 0.0],[1.0, 0.0],[0.0, 1.0]]) 7393 7409 7394 7410
Note: See TracChangeset
for help on using the changeset viewer.