Changeset 4135 for anuga_core/source/anuga
- Timestamp:
- Jan 5, 2007, 4:03:44 PM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r4130 r4135 741 741 triangles = self.domain.triangles #FIXME 742 742 743 744 # FIXME handle attribute name745 743 vertex_attributes = fit_to_mesh(coordinates, triangles,filename, 746 alpha=alpha) #, max_read_lines=max_read_lines) 744 alpha=alpha, 745 attribute_name = attribute_name, 746 use_cache = use_cache) 747 #, max_read_lines=max_read_lines) 747 748 748 749 #Call underlying method using array values -
anuga_core/source/anuga/fit_interpolate/fit.py
r4130 r4135 304 304 verbose=False, 305 305 point_origin=None, 306 attribute_name=None, 306 307 max_read_lines=500): 307 308 """Fit a smooth surface to given 1d array of data points z. … … 320 321 # use blocking to load in the point info 321 322 if type(point_coordinates_or_filename) == types.StringType: 323 msg = "Don't set a point origin when reading from a file" 324 assert point_origin is None, msg 322 325 filename = point_coordinates_or_filename 323 326 for geo_block in Geospatial_data(filename, … … 326 329 # build the array 327 330 points = geo_block.get_data_points(absolute=True) 328 z = geo_block.get_attributes( )331 z = geo_block.get_attributes(attribute_name=attribute_name) 329 332 self.build_fit_subset(points, z) 330 333 point_coordinates = None … … 423 426 data_origin=None, 424 427 max_read_lines=None, 428 attribute_name=None, 425 429 use_cache = False): 426 430 """ … … 472 476 interp = Fit(vertex_coordinates, 473 477 triangles, 474 verbose =verbose,475 mesh_origin =mesh_origin,478 verbose=verbose, 479 mesh_origin=mesh_origin, 476 480 alpha=alpha) 477 481 … … 480 484 point_origin=data_origin, 481 485 max_read_lines=max_read_lines, 486 attribute_name=attribute_name, 482 487 verbose=verbose) 483 488 -
anuga_core/source/anuga/fit_interpolate/test_fit.py
r4130 r4135 240 240 assert allclose(f, answer) 241 241 242 def test_fit_ 2_mesh(self):242 def test_fit_to_mesh(self): 243 243 244 244 a = [-1.0, 0.0] … … 272 272 f = fit_to_mesh(vertices, triangles,fileName, 273 273 alpha=0.0, max_read_lines=2) 274 answer = linear_function(vertices) 275 #print "f\n",f 276 #print "answer\n",answer 277 assert allclose(f, answer) 278 279 def test_fit_to_mesh_2_atts(self): 280 281 a = [-1.0, 0.0] 282 b = [3.0, 4.0] 283 c = [4.0,1.0] 284 d = [-3.0, 2.0] #3 285 e = [-1.0,-2.0] 286 f = [1.0, -2.0] #5 287 288 vertices = [a, b, c, d,e,f] 289 triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc 290 291 292 fileName = tempfile.mktemp(".ddd") 293 file = open(fileName,"w") 294 # the 2nd att name is wacky so it's the first key off a hash table 295 file.write(" x,y, elevation, afriqction \n\ 296 -2.0, 2.0, 0., 0.\n\ 297 -1.0, 1.0, 0., 0.\n\ 298 0.0, 2.0 , 2., 20.\n\ 299 1.0, 1.0 , 2., 20.\n\ 300 2.0, 1.0 ,3., 30. \n\ 301 0.0, 0.0 , 0., 0.\n\ 302 1.0, 0.0 , 1., 10.\n\ 303 0.0, -1.0, -1., -10.\n\ 304 -0.2, -0.5, -0.7, -7.\n\ 305 -0.9, -1.5, -2.4, -24. \n\ 306 0.5, -1.9, -1.4, -14. \n\ 307 3.0, 1.0 , 4., 40. \n") 308 file.close() 309 310 f = fit_to_mesh(vertices, triangles,fileName, 311 alpha=0.0, 312 attribute_name='elevation', max_read_lines=2) 274 313 answer = linear_function(vertices) 275 314 #print "f\n",f -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r4129 r4135 838 838 # It might not be a problem with the header 839 839 #raise TitleAmountError 840 raise IOError 840 msg = "File load error. There might be a problem with the file header" 841 raise IOError, msg 841 842 for i,num in enumerate(numbers): 842 843 num.strip() … … 844 845 #attributes.append(float(num)) 845 846 att_dict.setdefault(header[i],[]).append(float(num)) 847 #except IOError: 846 848 except ValueError: 847 849 raise SyntaxError -
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r4129 r4135 943 943 944 944 os.remove(fileName) 945 946 def test_load_csv_bad(self): 947 """ 948 space delimited 949 """ 950 import os 951 952 fileName = tempfile.mktemp(".txt") 953 file = open(fileName,"w") 954 file.write(" elevation , speed \n\ 955 1.0, 0.0, 10.0, 0.0\n\ 956 0.0, 1.0, 0.0, 10.0\n\ 957 1.0, 0.0 ,10.4, 40.0\n") 958 file.close() 959 960 results = Geospatial_data(fileName, max_read_lines=2, 961 load_file_now=False) 962 963 # Blocking 964 geo_list = [] 965 try: 966 for i in results: 967 geo_list.append(i) 968 except IOError: 969 pass 970 else: 971 msg = 'bad file did not raise error!' 972 raise msg 973 os.remove(fileName) 945 974 946 975 def test_export_xya_file(self):
Note: See TracChangeset
for help on using the changeset viewer.