Ignore:
Timestamp:
Jan 17, 2009, 7:36:16 PM (15 years ago)
Author:
ole
Message:

Implemented interpolate_polyline in C. Hopefully, the STS file boundary will now run much faster.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/fit_interpolate/test_interpolate.py

    r6186 r6189  
    18461846        assert num.allclose(z, answer)
    18471847       
    1848        
    1849     def test_interpolate_polyline(self):
    1850         """test_interpolate_polyline(self):
    1851        
    1852         This test is added under the assumption that the function interpolate_polyline implemented by
    1853         John Jakeman works. It has been exercised somewhat by tests of sts boundary, but never before separately.
    1854         """
    1855        
    1856         f = num.array([58.06150614, 58.06150614, 58.06150614])
    1857         vertex_coordinates = num.array([[0., 0., ],
    1858                                         [4.04092634, 1106.11074699],
    1859                                         [8.08836552, 2212.16910609]])
    1860         gauge_neighbour_id = [1, 2, -1]
    1861         point_coordinates = num.array([[2.21870766e+03, 1.09802864e+03],
    1862                                        [1.62739645e+03, 2.20626983e+03],
    1863                                        [5.20084967e+02, 2.21030386e+03],
    1864                                        [6.06464546e+00, 1.65913993e+03],
    1865                                        [1.61934862e+03, -5.88143836e+00],
    1866                                        [5.11996623e+02, -1.85956061e+00],
    1867                                        [2.02046270e+00, 5.53055373e+02]])
    1868                              
    1869         z_ref = [0., 0., 0., 58.06150614, 0., 0., 58.06150614]
    1870        
    1871         z = interpolate_polyline(f, vertex_coordinates, gauge_neighbour_id, point_coordinates)
    1872         assert num.allclose(z, z_ref)
    1873        
    1874         # Another f
    1875         f = num.array([58.06150614, 158.06150614, 258.06150614])
    1876         z_ref = [0., 0., 0., 208.06150645, 0., 0., 108.0615061]       
    1877         z = interpolate_polyline(f, vertex_coordinates, gauge_neighbour_id, point_coordinates)
    1878         assert num.allclose(z, z_ref)       
    1879                        
    1880 
    1881         # Other and simpler numbers
    1882         f = num.array([1, 5, 13])       
    1883         vertex_coordinates = num.array([[0., 0., ],
    1884                                         [4., 4.],
    1885                                         [8., 8.]])       
    1886         point_coordinates = num.array([[0.1, 0.1],
    1887                                        [3.5, 3.5],
    1888                                        [4.0, 4.0],
    1889                                        [5.2, 5.2],
    1890                                        [7.0, 7.0],
    1891                                        [8.3, 8.3]])
    1892         gauge_neighbour_id = [1, 2, -1]
    1893                                                
    1894         z = interpolate_polyline(f, vertex_coordinates, gauge_neighbour_id, point_coordinates)
    1895         z_ref = [1.1, 4.5, 5., 7.4, 11., 0.]
    1896         #print z
    1897         assert num.allclose(z, z_ref)               
    1898        
    1899         # Test exception thrown for one point
    1900         f = num.array([5])               
    1901         vertex_coordinates = num.array([[4., 4.]])             
    1902         try: 
    1903             z = interpolate_polyline(f, vertex_coordinates, gauge_neighbour_id, point_coordinates)
    1904         except Exception:
    1905             pass
    1906         else:
    1907             raise Exception, 'One point should have raised exception'
    19081848                       
    19091849#-------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.