Changeset 2577
- Timestamp:
- Mar 22, 2006, 5:28:24 PM (17 years ago)
- Location:
- inundation/fit_interpolate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/fit_interpolate/interpolate.py
r2573 r2577 32 32 from utilities.numerical_tools import ensure_numeric, mean, INF 33 33 from utilities.polygon import inside_polygon 34 from geospatial_data.geospatial_data import Geospatial_data 34 35 35 36 from search_functions import search_tree_of_vertices … … 188 189 point_coordinates: Interpolate mesh data to these positions. 189 190 List of coordinate pairs [x, y] of 190 data points (or an nx2 Numeric array) 191 data points or an nx2 Numeric array or a Geospatial_data object 192 191 193 If point_coordinates is absent, the points inputted last time 192 194 this method was called are used, if possible. … … 198 200 """ 199 201 #print "point_coordinates interpolate.interpolate",point_coordinates 200 # Can I interpolate, based on previous point_coordinates? 202 # Can I interpolate, based on previous point_coordinates? 203 if isinstance(point_coordinates,Geospatial_data): 204 point_coordinates = point_coordinates.get_data_points( \ 205 absolute = True) 206 201 207 if point_coordinates is None: 202 208 if self._A_can_be_reused is True and \ -
inundation/fit_interpolate/test_interpolate.py
r2563 r2577 22 22 from utilities.numerical_tools import mean 23 23 from data_manager import get_dataobject 24 from geospatial_data.geospatial_data import Geospatial_data 24 25 25 26 def distance(x, y): … … 792 793 raise 'Should raise exception' 793 794 794 795 def BADtest_interpolate_sww(self): 796 """Not a unit test, rather a system test for interpolate_sww 797 This function is obsolete 798 """ 799 800 self.domain.filename = 'datatest' + str(time.time()) 801 self.domain.format = 'sww' 802 self.domain.smooth = True 803 self.domain.reduction = mean 804 805 sww = get_dataobject(self.domain) 806 sww.store_connectivity() 807 sww.store_timestep('stage') 808 self.domain.time = 2. 809 sww.store_timestep('stage') 810 811 #print "self.domain.filename",self.domain.filename 812 interp = interpolate_sww(sww.filename, [0.0, 2.0], 813 [[0,1],[0.5,0.5]], 814 ['stage']) 815 #assert allclose(interp,[0.0,2.0]) 816 817 #Cleanup 818 os.remove(sww.filename) 795 796 def qtest_interpolation_interface(self): 797 a = [-1.0, 0.0] 798 b = [3.0, 4.0] 799 c = [4.0, 1.0] 800 d = [-3.0, 2.0] #3 801 e = [-1.0, -2.0] 802 f = [1.0, -2.0] #5 803 804 vertices = [a, b, c, d,e,f] 805 triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc 806 807 point_coords = [[-2.0, 2.0], 808 [-1.0, 1.0], 809 [0.0, 2.0], 810 [1.0, 1.0], 811 [2.0, 1.0], 812 [0.0, 0.0], 813 [1.0, 0.0], 814 [0.0, -1.0], 815 [-0.2, -0.5], 816 [-0.9, -1.5], 817 [0.5, -1.9], 818 [999999, 9999999]] 819 geo_data = Geospatial_data(data_points = point_coords) 820 821 interp = Interpolate(vertices, triangles) 822 f = array([linear_function(vertices),2*linear_function(vertices) ]) 823 f = transpose(f) 824 #print "f",f 825 z = interp.interpolate(f, geo_data) 826 #z = interp.interpolate(f, point_coords) 827 answer = [linear_function(point_coords), 828 2*linear_function(point_coords) ] 829 answer = transpose(answer) 830 #print "z",z 831 #print "answer",answer 832 assert allclose(z, answer) 833 819 834 820 835 #------------------------------------------------------------- 821 836 if __name__ == "__main__": 822 suite = unittest.makeSuite(Test_Interpolate,' test')837 suite = unittest.makeSuite(Test_Interpolate,'qtest') 823 838 runner = unittest.TextTestRunner(verbosity=1) 824 839 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.