Changeset 2787
- Timestamp:
- May 1, 2006, 4:01:21 PM (19 years ago)
- Location:
- inundation/fit_interpolate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/fit_interpolate/interpolate.py
r2750 r2787 10 10 - if there are no global vars functions can be moved around alot easier 11 11 12 * What will be the public interface to this class? 13 14 TO DO 15 * geo-ref (in interpolate_block) 12 * The public interface 13 __init__ 14 interpolate 15 interpolate_block 16 16 17 """ 17 18 … … 199 200 See interpolate for doc info. 200 201 """ 202 if isinstance(point_coordinates,Geospatial_data): 203 point_coordinates = point_coordinates.get_data_points( \ 204 absolute = True) 201 205 if point_coordinates is not None: 202 206 self._A =self._build_interpolation_matrix_A(point_coordinates, -
inundation/fit_interpolate/test_interpolate.py
r2755 r2787 598 598 assert allclose(z, answer) 599 599 600 def test_interpolate_geo_spatial(self): 601 a = [-1.0, 0.0] 602 b = [3.0, 4.0] 603 c = [4.0, 1.0] 604 d = [-3.0, 2.0] #3 605 e = [-1.0, -2.0] 606 f = [1.0, -2.0] #5 607 608 vertices = [a, b, c, d,e,f] 609 triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc 610 611 612 point_coords_absolute = [[-2.0, 2.0], 613 [-1.0, 1.0], 614 [0.0, 2.0], 615 [1.0, 1.0], 616 [2.0, 1.0], 617 [0.0, 0.0], 618 [1.0, 0.0], 619 [0.0, -1.0], 620 [-0.2, -0.5], 621 [-0.9, -1.5], 622 [0.5, -1.9], 623 [3.0, 1.0]] 624 625 geo = Geo_reference(57,100, 500) 626 point_coords = geo.change_points_geo_ref(point_coords_absolute) 627 point_coords = Geospatial_data(point_coords,geo_reference = geo) 628 629 interp = Interpolate(vertices, triangles) 630 f = array([linear_function(vertices),2*linear_function(vertices) ]) 631 f = transpose(f) 632 #print "f",f 633 for blocking_max in range(14): 634 #if True: 635 # blocking_max = 5 636 z = interp.interpolate(f, point_coords, 637 start_blocking_len=blocking_max) 638 answer = [linear_function(point_coords.get_data_points( \ 639 absolute = True)), 640 2*linear_function(point_coords.get_data_points( \ 641 absolute = True)) ] 642 answer = transpose(answer) 643 #print "z",z 644 #print "answer",answer 645 assert allclose(z, answer) 646 647 f = array([linear_function(vertices),2*linear_function(vertices), 648 2*linear_function(vertices) - 100 ]) 649 f = transpose(f) 650 #print "f",f 651 for blocking_max in range(14): 652 #if True: 653 # blocking_max = 5 654 z = interp.interpolate(f, point_coords, 655 start_blocking_len=blocking_max) 656 answer = array([linear_function(point_coords.get_data_points( \ 657 absolute = True)), 658 2*linear_function(point_coords.get_data_points( \ 659 absolute = True)) , 660 2*linear_function(point_coords.get_data_points( \ 661 absolute = True))-100 ]) 662 z = transpose(z) 663 #print "z",z 664 #print "answer",answer 665 assert allclose(z, answer) 666 667 def test_interpolate_geo_spatial(self): 668 a = [-1.0, 0.0] 669 b = [3.0, 4.0] 670 c = [4.0, 1.0] 671 d = [-3.0, 2.0] #3 672 e = [-1.0, -2.0] 673 f = [1.0, -2.0] #5 674 675 vertices = [a, b, c, d,e,f] 676 triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc 677 678 679 point_coords_absolute = [[-2.0, 2.0], 680 [-1.0, 1.0], 681 [0.0, 2.0], 682 [1.0, 1.0], 683 [2.0, 1.0], 684 [0.0, 0.0], 685 [1.0, 0.0], 686 [0.0, -1.0], 687 [-0.2, -0.5], 688 [-0.9, -1.5], 689 [0.5, -1.9], 690 [3.0, 1.0]] 691 692 geo = Geo_reference(57,100, 500) 693 point_coords = geo.change_points_geo_ref(point_coords_absolute) 694 point_coords = Geospatial_data(point_coords,geo_reference = geo) 695 696 interp = Interpolate(vertices, triangles) 697 f = array([linear_function(vertices),2*linear_function(vertices) ]) 698 f = transpose(f) 699 #print "f",f 700 z = interp.interpolate_block(f, point_coords) 701 answer = [linear_function(point_coords.get_data_points( \ 702 absolute = True)), 703 2*linear_function(point_coords.get_data_points( \ 704 absolute = True)) ] 705 answer = transpose(answer) 706 #print "z",z 707 #print "answer",answer 708 assert allclose(z, answer) 709 600 710 def test_interpolate_reuse(self): 601 711 a = [-1.0, 0.0]
Note: See TracChangeset
for help on using the changeset viewer.