Changeset 2655 for inundation/fit_interpolate/test_interpolate.py
- Timestamp:
- Apr 4, 2006, 3:49:42 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/fit_interpolate/test_interpolate.py
r2651 r2655 20 20 from coordinate_transforms.geo_reference import Geo_reference 21 21 from shallow_water import Domain, Transmissive_boundary 22 from utilities.numerical_tools import mean 22 from utilities.numerical_tools import mean, INF 23 23 from data_manager import get_dataobject 24 24 from geospatial_data.geospatial_data import Geospatial_data … … 237 237 assert allclose(sum(results, axis=1), 1.0) 238 238 239 #FIXME - have to change this test to check default info 240 def NO_test_arbitrary_datapoints_some_outside(self): 239 def test_arbitrary_datapoints_some_outside(self): 241 240 """Try arbitrary datapoints one outside the triangle. 242 241 That one should be ignored … … 253 252 data = [ [0.2, 1.5], [0.123, 1.768], [1.43, 0.44], [5.0, 7.0]] 254 253 255 256 interp = Interpolate(points, vertices, data, precrop = True) 257 258 results = interp._build_interpolation_matrix_A(data).todense() 259 assert allclose(sum(results, axis=1), 1.0) 260 261 interp = Interpolate(points, vertices, data, precrop = False) 254 interp = Interpolate(points, vertices, data) 262 255 results = interp._build_interpolation_matrix_A(data).todense() 263 256 assert allclose(sum(results, axis=1), [1,1,1,0]) … … 301 294 assert allclose(A, answer) 302 295 303 296 #FIXME - tests are hopefully failing due to points outsdie the 297 # mesh 304 298 def test_interpolate_attributes_to_points(self): 305 299 v0 = [0.0, 0.0] … … 442 436 443 437 z = interp.interpolate(f, point_coords) 444 answer = [ [0., 0., 0., 0.]]# (-1,-1)438 answer = array([ [INF, INF, INF, INF]]) # (-1,-1) 445 439 446 440 #print "***********" … … 452 446 # of the mesh? Not currently. 453 447 454 assert allclose(z, answer) 455 448 for i in range(4): 449 self.failUnless( z[0,i] == answer[0,i], 'Fail!') 450 456 451 def test_interpolate_attributes_to_pointsIV(self): 457 452 a = [-1.0, 0.0] … … 594 589 595 590 def test_interpolation_interface_time_only(self): 596 """Test spatio-temporal interpolation 597 Test that spatio temporal function performs the correct 598 interpolations in both time and space 599 """ 591 592 # Test spatio-temporal interpolation 593 # Test that spatio temporal function performs the correct 594 # interpolations in both time and space 595 600 596 601 597 … … 667 663 668 664 def test_interpolation_interface_spatial_only(self): 669 """Test spatio-temporal interpolation with constant time 670 """ 671 665 # Test spatio-temporal interpolation with constant time 666 672 667 #Three timesteps 673 668 time = [1.0, 5.0, 6.0] … … 728 723 729 724 def test_interpolation_interface(self): 730 """Test spatio-temporal interpolation 731 Test that spatio temporal function performs the correct 732 interpolations in both time and space 733 """ 734 725 # Test spatio-temporal interpolation 726 # Test that spatio temporal function performs the correct 727 # interpolations in both time and space 728 735 729 736 730 #Three timesteps … … 793 787 794 788 795 def qtest_interpolation_interface(self):789 def test_points_outside_the_polygon(self): 796 790 a = [-1.0, 0.0] 797 791 b = [3.0, 4.0] … … 815 809 [-0.9, -1.5], 816 810 [0.5, -1.9], 817 [999999, 9999999]] 811 [999999, 9999999]] # point Outside poly 818 812 geo_data = Geospatial_data(data_points = point_coords) 819 813 … … 827 821 2*linear_function(point_coords) ] 828 822 answer = transpose(answer) 823 answer[11,:] = [INF, INF] 829 824 #print "z",z 830 #print "answer",answer 831 assert allclose(z, answer) 832 825 #print "answer _ fixed",answer 826 assert allclose(z[0:10], answer[0:10]) 827 self.failUnless( z[11,1] == answer[11,1], 'Fail!') 828 self.failUnless( z[11,0] == answer[11,0], 'Fail!') 829 830 831 def test_points_outside_the_polygon(self): 832 a = [-1.0, 0.0] 833 b = [3.0, 4.0] 834 c = [4.0, 1.0] 835 d = [-3.0, 2.0] #3 836 e = [-1.0, -2.0] 837 f = [1.0, -2.0] #5 838 839 vertices = [a, b, c, d,e,f] 840 triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc 841 842 point_coords = [[-2.0, 2.0], 843 [-1.0, 1.0], 844 [9999.0, 9999.0], # point Outside poly 845 [-9999.0, 1.0], # point Outside poly 846 [2.0, 1.0], 847 [0.0, 0.0], 848 [1.0, 0.0], 849 [0.0, -1.0], 850 [-0.2, -0.5], 851 [-0.9, -1.5], 852 [0.5, -1.9], 853 [999999, 9999999]] # point Outside poly 854 geo_data = Geospatial_data(data_points = point_coords) 855 856 interp = Interpolate(vertices, triangles) 857 f = array([linear_function(vertices),2*linear_function(vertices) ]) 858 f = transpose(f) 859 #print "f",f 860 z = interp.interpolate(f, geo_data) 861 #z = interp.interpolate(f, point_coords) 862 answer = [linear_function(point_coords), 863 2*linear_function(point_coords) ] 864 answer = transpose(answer) 865 answer[2,:] = [INF, INF] 866 answer[3,:] = [INF, INF] 867 answer[11,:] = [INF, INF] 868 #print "z",z 869 #print "answer _ fixed",answer 870 assert allclose(z[0:1], answer[0:1]) 871 assert allclose(z[4:10], answer[4:10]) 872 for i in [2,3,11]: 873 self.failUnless( z[i,1] == answer[11,1], 'Fail!') 874 self.failUnless( z[i,0] == answer[11,0], 'Fail!') 833 875 834 876 #------------------------------------------------------------- 835 877 if __name__ == "__main__": 878 879 #suite = unittest.makeSuite(Test_Interpolate,'test') 836 880 suite = unittest.makeSuite(Test_Interpolate,'test') 881 #suite = unittest.makeSuite(Test_Interpolate,'test_points_outside_the_polygon') 837 882 runner = unittest.TextTestRunner(verbosity=1) 838 883 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.