Ignore:
Timestamp:
Jan 20, 2006, 10:06:24 AM (19 years ago)
Author:
duncan
Message:

add test with different geo-refs in mesh and points files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/test_least_squares.py

    r2141 r2260  
    14831483        export_mesh_file(mesh_file,mesh_dic)
    14841484
    1485         #FIXME - make this test the georef in the points file as well.
    14861485        # create an .xya file
    14871486        point_file = tempfile.mktemp(".xya")
    14881487        fd = open(point_file,'w')
    14891488        fd.write("elevation, stage \n 1.0, 1.0,2.,4 \n 1.0, 3.0,4,8 \n 3.0,1.0,4.,8 \n")
     1489        fd.close()
     1490
     1491        mesh_output_file = tempfile.mktemp(".tsh")
     1492        fit_to_mesh_file(mesh_file,
     1493                         point_file,
     1494                         mesh_output_file,
     1495                         alpha = 0.0)
     1496        # load in the .tsh file we just wrote
     1497        mesh_dic = import_mesh_file(mesh_output_file)
     1498        #print "mesh_dic",mesh_dic
     1499        ans =[[0.0, 0.0],
     1500              [5.0, 10.0],
     1501              [5.0,10.0]]
     1502        assert allclose(mesh_dic['vertex_attributes'],ans)
     1503
     1504        self.failUnless(mesh_dic['vertex_attribute_titles']  ==
     1505                        ['elevation','stage'],
     1506                        'test_fit_to_mesh_file failed')
     1507
     1508        #clean up
     1509        os.remove(mesh_file)
     1510        os.remove(point_file)
     1511        os.remove(mesh_output_file)
     1512
     1513    def test_fit_to_mesh_file4(self):
     1514        from load_mesh.loadASCII import import_mesh_file, \
     1515             export_mesh_file
     1516        import tempfile
     1517        import os
     1518
     1519        # create a .tsh file, no user outline
     1520        mesh_dic = {}
     1521        mesh_dic['vertices'] = [[0.76, 0.76],
     1522                                          [0.76, 5.76],
     1523                                          [5.76, 0.76]]
     1524        mesh_dic['triangles'] =  [[0, 2, 1]]
     1525        mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]]
     1526        mesh_dic['triangle_tags'] = ['']
     1527        mesh_dic['vertex_attributes'] = [[], [], []]
     1528        mesh_dic['vertiex_attribute_titles'] = []
     1529        mesh_dic['triangle_neighbors'] = [[-1, -1, -1]]
     1530        mesh_dic['segment_tags'] = ['external',
     1531                                                  'external',
     1532                                                  'external']
     1533        mesh_dic['geo_reference'] = Geo_reference(56,-0.76,-0.76)
     1534        mesh_file = tempfile.mktemp(".tsh")
     1535        export_mesh_file(mesh_file,mesh_dic)
     1536
     1537        geo_ref = Geo_reference(56,-200,-400)
     1538        # create an .xya file
     1539        point_file = tempfile.mktemp(".xya")
     1540        fd = open(point_file,'w')
     1541        fd.write("elevation, stage \n 201.0, 401.0,2.,4 \n 201.0, 403.0,4,8 \n 203.0, 401.0,4.,8 \n")
     1542        geo_ref.write_ASCII(fd)
    14901543        fd.close()
    14911544
Note: See TracChangeset for help on using the changeset viewer.