Changeset 9323
- Timestamp:
- Sep 4, 2014, 6:45:53 PM (10 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py
r9319 r9323 384 384 nodes = num.array([a, b, c, d, e, f]) 385 385 386 387 386 # bac, bce, ecf, dbe 388 387 triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.int) -
trunk/anuga_core/source/anuga/fit_interpolate/fit.py
r8970 r9323 527 527 """ 528 528 529 from load_mesh.loadASCII import import_mesh_file, \529 from anuga.load_mesh.loadASCII import import_mesh_file, \ 530 530 export_mesh_file, concatinate_attributelist 531 531 -
trunk/anuga_core/source/anuga/load_mesh/loadASCII.py
r8780 r9323 70 70 71 71 from anuga.file.netcdf import NetCDFFile 72 from anuga.utilities.numerical_tools import ensure_numeric 72 73 73 74 import numpy as num … … 96 97 #FIXME No test for ValueError 97 98 except (TitleError, SyntaxError, IndexError, ValueError): 98 msg = 'File could not be opened'99 msg = 'File %s could not be opened' % ofile 99 100 raise IOError, msg 101 100 102 return dict 101 103 … … 350 352 else: 351 353 regionmaxareas.append(float(fragments[0])) 352 except IndexError, e:354 except (ValueError, IndexError), e: 353 355 regionmaxareas.append(None) 354 356 … … 376 378 vertices = gen_dict['vertices'] 377 379 vertices_attributes = gen_dict['vertex_attributes'] 380 378 381 try: 379 382 vertices_attribute_titles = gen_dict['vertex_attribute_titles'] … … 381 384 #FIXME is this the best way? 382 385 if vertices_attributes == [] or vertices_attributes[0] == []: 383 386 vertices_attribute_titles = [] 384 387 else: 385 388 raise KeyError, e 389 386 390 387 391 triangles = gen_dict['triangles'] … … 400 404 numVertAttrib = "0" 401 405 else: 402 numVertAttrib = str(len(vertices_attributes[0])) 406 #numVertAttrib = str(len(vertices_attributes[0])) 407 try: 408 numVertAttrib = str(len(vertices_attributes[0])) 409 except TypeError: 410 vertices_attributes = [ [entry] for entry in vertices_attributes] 411 numVertAttrib = str(len(vertices_attributes[0])) 412 413 403 414 404 415 fd.write(numVert + " " + numVertAttrib + -
trunk/anuga_core/source/anuga/load_mesh/test_loadASCII.py
r8120 r9323 37 37 self.dict['vertex_attribute_titles'] = ['bed elevation', 'height'] 38 38 self.dict['geo_reference'] = Geo_reference(56, 1.9, 1.9) 39 40 41 self.dict_1 = {} 42 self.dict_1['outline_segments'] = [(0, 1), (1, 2), (0, 2), (0, 3)] 43 self.dict_1['outline_segment_tags'] = ['50', '40', '30', '20'] 44 self.dict_1['holes'] = [(0.2, 0.6)] 45 self.dict_1['point_attributes'] = [[5], [4], [3], [2]] 46 self.dict_1['regions'] = [(0.3, 0.3), (0.3, 0.4)] 47 self.dict_1['region_tags'] = ['1.3', 'yeah'] 48 self.dict_1['region_max_areas'] = [36.0, -7.1] 49 self.dict_1['points'] = [(0.0, 0.0), (0.0, 4.0), (4.0, 0.0), (1.0, 1.0)] 50 self.dict_1['vertices'] = [(0.0, 0.0), (0.0, 4.0), (4.0, 0.0), 51 (1.0, 1.0), (2.0, 2.0)] 52 self.dict_1['triangles'] = [(3, 2, 4), (1, 0, 3), (3, 4,1), (2, 3, 0)] 53 self.dict_1['segments'] = [(0, 1), (1, 4), (2, 0), (0, 3), (4, 2)] 54 self.dict_1['triangle_tags'] = ['1.3', '1.3', '1.3', '1.3'] 55 self.dict_1['vertex_attributes'] = [[1.2], [1.2], [1.2], 56 [1.2], [1.2]] 57 self.dict_1['triangle_neighbors'] = [[-1, 2, 3], [3, 2, -1], 58 [-1, 1, 0], [1, -1, 0]] 59 self.dict_1['segment_tags'] = ['50', '40', '30', '20', '40'] 60 self.dict_1['vertex_attribute_titles'] = ['height'] 61 self.dict_1['geo_reference'] = Geo_reference(56, 1.9, 1.9) 39 62 40 63 self.sparse_dict = {} … … 201 224 202 225 os.remove(fileName) 226 227 228 def test_export_mesh_1_file(self): 229 meshDict = self.dict_1 230 fileName = tempfile.mktemp('.tsh') 231 export_mesh_file(fileName, meshDict) 232 loadedDict = import_mesh_file(fileName) 233 234 235 self.failUnless(num.alltrue(num.array(meshDict['vertices']) == 236 num.array(loadedDict['vertices'])), 237 'test_export_mesh_file failed. Test 1') 238 self.failUnless(num.alltrue(num.array(meshDict['triangles']) == 239 num.array(loadedDict['triangles'])), 240 'test_export_mesh_file failed. Test 2') 241 self.failUnless(num.alltrue(num.array(meshDict['segments']) == 242 num.array(loadedDict['segments'])), 243 'test_export_mesh_file failed. Test 3') 244 self.failUnless(num.alltrue(num.array(meshDict['triangle_tags']) == 245 num.array(loadedDict['triangle_tags'])), 246 'test_export_mesh_file failed. Test 4') 247 248 self.failUnless(meshDict['vertex_attributes'] == 249 loadedDict['vertex_attributes'], 250 'test_export_mesh_file failed. Test 5') 251 self.failUnless(num.alltrue(num.array(meshDict['triangle_neighbors']) == 252 num.array(loadedDict['triangle_neighbors'])), 253 'test_export_mesh_file failed. Test 6') 254 self.failUnless(num.alltrue(num.array(meshDict['segment_tags']) == 255 num.array(loadedDict['segment_tags'])), 256 'test_export_mesh_file failed. Test 7') 257 self.failUnless(num.alltrue(num.array(meshDict['vertex_attribute_titles']) == 258 num.array(loadedDict['vertex_attribute_titles'])), 259 'test_export_mesh_file failed. Test 8') 260 self.failUnless(num.alltrue(num.array(meshDict['geo_reference']) == 261 num.array(loadedDict['geo_reference'])), 262 'test_export_mesh_file failed. Test 9') 263 264 265 #os.remove(fileName) 203 266 204 267 def test_read_write_tsh_file(self):
Note: See TracChangeset
for help on using the changeset viewer.