Changeset 8541
- Timestamp:
- Aug 30, 2012, 10:35:14 AM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file_conversion/sww2dem.py
r8137 r8541 330 330 if verbose: log.critical('Interpolating') 331 331 grid_values = interp.interpolate(result, grid_points).flatten() 332 outside_indices = interp.get_outside_poly_indices() 332 333 333 334 if verbose: … … 336 337 337 338 # Assign NODATA_value to all points outside bounding polygon (from interpolation mesh) 338 P = interp.mesh.get_boundary_polygon() 339 outside_indices = outside_polygon(grid_points, P, closed=True) 339 340 # P = interp.mesh.get_boundary_polygon() 341 # outside_indices = outside_polygon(grid_points, P, closed=True) 340 342 341 343 for i in outside_indices: -
trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py
r8149 r8541 371 371 372 372 373 def get_outside_poly_indices(self): 374 """ 375 Return index of those data points outside (and in holes) 376 the mesh 377 378 Precondition: interpolation or interpolation_block has been called 379 """ 380 return self.outside_poly_indices 381 382 373 383 def _get_point_data_z(self, f, verbose=False): 374 384 """ … … 413 423 if verbose: log.critical('Getting indices inside mesh boundary') 414 424 415 # Quick test against boundary, but will not deal with holes in the mesh 425 # Quick test against boundary, but will not deal with holes in the mesh, 426 # that is done below 416 427 inside_boundary_indices, outside_poly_indices = \ 417 428 in_and_outside_polygon(point_coordinates, -
trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r8124 r8541 1715 1715 self.failUnless( z[i,0] == answer[11,0], 'Fail!') 1716 1716 1717 1718 1719 1720 def test_points_in_hole(self): 1721 1722 v0 = [0.0, 0.0] 1723 v1 = [1.0/3.0, 0.0] 1724 v2 = [2.0/3.0, 0.0] 1725 v3 = [1.0, 0.0] 1726 v4 = [0.0, 1.0/3.0] 1727 v5 = [1.0/3.0, 1.0/3.0] 1728 v6 = [2.0/3.0, 1.0/3.0] 1729 v7 = [1.0, 1.0/3.0] 1730 v8 = [0.0, 2.0/3.0] 1731 v9 = [1.0/3.0, 2.0/3.0] 1732 v10 = [2.0/3.0, 2.0/3.0] 1733 v11 = [1.0, 2.0/3.0] 1734 v12 = [0.0, 1.0] 1735 v13 = [1.0/3.0, 1.0] 1736 v14 = [2.0/3.0, 1.0] 1737 v15 = [1.0, 1.0] 1738 1739 1740 vertices = [v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15] 1741 1742 triangles = [[1,4,0], [1,5,4], [2,5,1], [2,6,5], [3,6,2], [3,7,6], 1743 [5,8,4], [5,9,8], [7,10,6], [7,11,10], 1744 [9,12,8], [9,13,12], [10,13,9], [10,14,13], [11,14,10], [11,15,14]] 1745 1746 1747 1748 1749 point_coords = [[0.25, 0.25], 1750 [0.25, 0.2], 1751 [10.0, 12.0], # point Outside poly 1752 [0.5, 0.5], # point in hole 1753 [0.5, 0.4], # point in hole 1754 [0.0, 0.0], 1755 [1.0, 0.0]] 1756 1757 geo_data = Geospatial_data(data_points = point_coords) 1758 1759 interp = Interpolate(vertices, triangles) 1760 f = num.array([linear_function(vertices),2*linear_function(vertices)]) 1761 f = num.transpose(f) 1762 #print "f",f 1763 z = interp.interpolate(f, geo_data) 1764 #z = interp.interpolate(f, point_coords) 1765 answer = [linear_function(point_coords), 1766 2*linear_function(point_coords) ] 1767 answer = num.transpose(answer) 1768 answer[2,:] = [NAN, NAN] 1769 answer[3,:] = [NAN, NAN] 1770 answer[4,:] = [NAN, NAN] 1771 #print "z",z 1772 #print "answer _ fixed",answer 1773 assert num.allclose(z[0:1], answer[0:1]) 1774 assert num.allclose(z[5:6], answer[5:6]) 1775 for i in [2,3,4]: 1776 self.failUnless( z[i,1] == answer[2,1], 'Fail!') 1777 self.failUnless( z[i,0] == answer[2,0], 'Fail!') 1778 1779 1717 1780 def test_interpolate_sww2csv(self): 1718 1781
Note: See TracChangeset
for help on using the changeset viewer.