Changeset 436
- Timestamp:
- Oct 21, 2004, 5:54:28 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/least_squares.py
r428 r436 25 25 from LinearAlgebra import solve_linear_equations 26 26 from scipy import sparse 27 from cg_solve import conjugate_gradient 27 from cg_solve import conjugate_gradient, VectorShapeError 28 28 29 29 try: … … 130 130 alpha = alpha) 131 131 132 vertex_attributes = interp.fit (point_attributes)132 vertex_attributes = interp.fit_points(point_attributes) 133 133 return vertex_attributes 134 134 … … 212 212 #Build n x m interpolation matrix 213 213 m = self.mesh.coordinates.shape[0] #Nbr of basis functions (1/vertex) 214 n = point_coordinates.shape[0] #Nbr of data points 215 214 n = point_coordinates.shape[0] #Nbr of data points 215 216 216 #self.A = zeros((n,m), Float) 217 217 self.A = sparse.dok_matrix() … … 394 394 #FIXME: Should we store the result here for later use? (ON) 395 395 396 396 def fit_points(self, z): 397 """ 398 Like fit, but more robust when each point has two or more attributes 399 """ 400 try: 401 return self.fit(z) 402 except VectorShapeError, e: 403 # broadcasting is not supported. 404 405 #Convert input to Numeric arrays 406 z = array(z).astype(Float) 407 408 #Build n x m interpolation matrix 409 m = self.mesh.coordinates.shape[0] #Number of vertices 410 n = z.shape[1] #Number of data points 411 412 f = zeros((m,n), Float) 413 #f = sparse.dok_matrix() # even though it wont be sparse? 414 415 for i in range(z.shape[1]): 416 f[:,i] = self.fit(z[:,i]) 417 return f 418 419 397 420 def interpolate(self, f): 398 421 """Compute predicted values at data points implied in self.A. -
inundation/ga/storm_surge/pyvolution/test_least_squares.py
r430 r436 162 162 data_coords = [d1, d2, d3] 163 163 164 interp = Interpolation(points, triangles, data_coords, alpha=5.0e- 7)164 interp = Interpolation(points, triangles, data_coords, alpha=5.0e-20) 165 165 z = [z1, z2, z3] 166 166 f = interp.fit(z) … … 241 241 interp = Interpolation(points, triangles, data_coords, alpha=0.0) 242 242 z = [z1, z2, z3] 243 f = interp.fit (z)243 f = interp.fit_points(z) 244 244 answer = [[0,0], [5., 10.], [5., 10.]] 245 245 assert allclose(f, answer)
Note: See TracChangeset
for help on using the changeset viewer.