Changeset 3768
 Timestamp:
 Oct 13, 2006, 12:13:34 PM (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

anuga_core/source/anuga/fit_interpolate/interpolate.py
r3689 r3768 35 35 from anuga.utilities.numerical_tools import ensure_numeric, mean, NAN 36 36 from anuga.utilities.polygon import in_and_outside_polygon 37 from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_absolute 37 from anuga.geospatial_data.geospatial_data import Geospatial_data 38 from anuga.geospatial_data.geospatial_data import ensure_absolute 38 39 from anuga.fit_interpolate.search_functions import search_tree_of_vertices 39 40 from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate … … 120 121 # FIXME (Ole): Need an input check that dimensions are compatible 121 122 122 # FIXME (Ole): Why is the interpolation matrix rebuilt everytime the method is called123 # even if interpolation points are unchanged.123 # FIXME (Ole): Why is the interpolation matrix rebuilt everytime the 124 # method is called even if interpolation points are unchanged. 124 125 125 126 #print "point_coordinates interpolate.interpolate", point_coordinates … … 168 169 len(point_coordinates), 169 170 start_blocking_len): 171 170 172 t = self.interpolate_block(f, point_coordinates[start:end], 171 173 verbose=verbose) … … 174 176 z = concatenate((z,t)) 175 177 start = end 178 176 179 end = len(point_coordinates) 177 180 t = self.interpolate_block(f, point_coordinates[start:end], … … 179 182 z = concatenate((z,t)) 180 183 return z 181 182 184 183 185 def interpolate_block(self, f, point_coordinates = None, verbose=False): … … 213 215 z[i] = NAN 214 216 return z 215 216 217 217 218 def _build_interpolation_matrix_A(self, … … 364 365 velocity_y_writer.writerow(velocity_ys) 365 366 367 366 368 class Interpolation_function: 367 369 """Interpolation_interface  creates callable object f(t, id) or f(t,x,y) … … 398 400 If None, return average value 399 401 """ 400 401 402 402 403 403 404 def __init__(self, … … 467 468 self.index = 0 # Initial time index 468 469 self.precomputed_values = {} 469 470 471 472 473 470 474 471 … … 504 501 if verbose: print 'Interpolate' 505 502 for i, t in enumerate(self.time): 506 # Interpolate quantities at this timestep503 # Interpolate quantities at this timestep 507 504 if verbose and i%((p+10)/10)==0: 508 505 print ' time step %d of %d' %(i, p) … … 510 507 for name in quantity_names: 511 508 if len(quantities[name].shape) == 2: 512 result = interpol.interpolate(quantities[name][i,:], 513 point_coordinates = \ 514 self.interpolation_points) 509 Q = quantities[name][i,:] # Quantities at timestep i 515 510 else: 516 #Assume no time dependency 517 result = interpol.interpolate(quantities[name][:], 518 point_coordinates = \ 519 self.interpolation_points) 511 Q = quantities[name][:] # No time dependency 520 512 513 # Interpolate 514 result = interpol.interpolate(Q, 515 point_coordinates=\ 516 self.interpolation_points) 521 517 self.precomputed_values[name][i, :] = result 518 522 519 523 # Report520 # Report 524 521 if verbose: 525 522 print self.statistics() … … 527 524 528 525 else: 529 # Store quantitites as is530 526 # Store quantitites as is 527 for name in quantity_names: 531 528 self.precomputed_values[name] = quantities[name] 532 529 533 534 530 def __repr__(self): 535 # return 'Interpolation function (spatiotemporal)'531 # return 'Interpolation function (spatiotemporal)' 536 532 return self.statistics() 537 538 539 def __call__(self, t, point_id = None, x = None, y = None): 533 534 def __call__(self, t, point_id=None, x=None, y=None): 540 535 """Evaluate f(t), f(t, point_id) or f(t, x, y) 541 536 … … 665 660 return self.time 666 661 662 667 663 def statistics(self): 668 664 """Output statistics about interpolation_function … … 711 707 return str 712 708 709 713 710 def interpolate_sww(sww_file, time, interpolation_points, 714 711 quantity_names = None, verbose = False): … … 729 726 730 727 #Will return the quantity values at the specified times and locations 731 interp = Interpolation_interface( 732 time, 733 quantities, 734 quantity_names = quantity_names, 735 vertex_coordinates = vertex_coordinates, 736 triangles = volumes, 737 interpolation_points = interpolation_points, 738 verbose = verbose) 728 interp = Interpolation_interface(time, 729 quantities, 730 quantity_names=quantity_names, 731 vertex_coordinates=vertex_coordinates, 732 triangles=volumes, 733 interpolation_points=interpolation_points, 734 verbose=verbose) 739 735 740 736 … … 801 797 return x, y, volumes, time, quantities 802 798 799 803 800 # 804 801 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.