- Timestamp:
- Nov 6, 2008, 3:41:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/fit_interpolate/interpolate.py
r5869 r5905 24 24 from csv import writer, DictWriter 25 25 26 from Numeric import zeros, array, Float, Int, dot, transpose, concatenate, \ 27 ArrayType, allclose, take, NewAxis, arange 26 import numpy 28 27 29 28 from anuga.caching.caching import cache … … 116 115 117 116 # Create interpolation object with matrix 118 args = (ensure_numeric(vertex_coordinates, Float),117 args = (ensure_numeric(vertex_coordinates, numpy.float), 119 118 ensure_numeric(triangles)) 120 119 kwargs = {'mesh_origin': mesh_origin, … … 224 223 225 224 from utilities.polygon import point_on_line 226 from Numeric import ones 227 z=ones(len(point_coordinates),Float) 225 z=numpy.ones(len(point_coordinates),numpy.float) 228 226 229 227 msg='point coordinates are not given (interpolate.py)' … … 343 341 # creating a dummy array to concatenate to. 344 342 345 f = ensure_numeric(f, Float)343 f = ensure_numeric(f, numpy.float) 346 344 #print "f.shape",f.shape 347 345 if len(f.shape) > 1: 348 z = zeros((0,f.shape[1]))346 z = numpy.zeros((0,f.shape[1]), numpy.float) 349 347 else: 350 z = zeros((0,))348 z = numpy.zeros((0,), numpy.float) 351 349 352 350 for end in range(start_blocking_len, … … 358 356 #print "t", t 359 357 #print "z", z 360 z = concatenate((z,t))358 z = numpy.concatenate((z,t)) 361 359 start = end 362 360 … … 364 362 t = self.interpolate_block(f, point_coordinates[start:end], 365 363 verbose=verbose) 366 z = concatenate((z,t))364 z = numpy.concatenate((z,t)) 367 365 return z 368 366 … … 389 387 390 388 # Convert lists to Numeric arrays if necessary 391 point_coordinates = ensure_numeric(point_coordinates, Float)392 f = ensure_numeric(f, Float)389 point_coordinates = ensure_numeric(point_coordinates, numpy.float) 390 f = ensure_numeric(f, numpy.float) 393 391 394 392 from anuga.caching import myhash 395 from Numeric import alltrue396 393 import sys 397 394 if use_cache is True: … … 412 409 if self.interpolation_matrices.has_key(key): 413 410 X, stored_points = self.interpolation_matrices[key] 414 if alltrue(stored_points == point_coordinates):411 if numpy.alltrue(stored_points == point_coordinates): 415 412 reuse_A = True # Reuse interpolation matrix 416 413 … … 487 484 488 485 # Convert point_coordinates to Numeric arrays, in case it was a list. 489 point_coordinates = ensure_numeric(point_coordinates, Float)486 point_coordinates = ensure_numeric(point_coordinates, numpy.float) 490 487 491 488 … … 752 749 """ 753 750 754 from Numeric import array, zeros, Float, alltrue, concatenate,\755 reshape, ArrayType756 757 758 751 from anuga.config import time_format 759 752 import types 760 761 753 762 754 # Check temporal info … … 764 756 msg = 'Time must be a monotonuosly ' 765 757 msg += 'increasing sequence %s' %time 766 assert alltrue(time[1:] - time[:-1] >= 0 ), msg758 assert numpy.alltrue(time[1:] - time[:-1] >= 0 ), msg 767 759 768 760 … … 795 787 # Thin timesteps if needed 796 788 # Note array() is used to make the thinned arrays contiguous in memory 797 self.time = array(time[::time_thinning])789 self.time = numpy.array(time[::time_thinning]) 798 790 for name in quantity_names: 799 791 if len(quantities[name].shape) == 2: 800 quantities[name] = array(quantities[name][::time_thinning,:])792 quantities[name] = numpy.array(quantities[name][::time_thinning,:]) 801 793 802 794 # Save for use with statistics 803 795 self.quantities_range = {} 804 796 for name in quantity_names: 805 q = quantities[name][:].flat 797 ## q = quantities[name][:].ravel() 798 q = numpy.ravel(quantities[name][:]) 806 799 self.quantities_range[name] = [min(q), max(q)] 807 800 … … 863 856 if sys.platform == 'win32': # FIXME (Ole): Why only Windoze? 864 857 from anuga.utilities.polygon import plot_polygons 865 #out_interp_pts = take(interpolation_points,[indices])858 #out_interp_pts = numpy.take(interpolation_points,[indices], axis=0) 866 859 title = 'Interpolation points fall outside specified mesh' 867 860 plot_polygons([mesh_boundary_polygon, … … 905 898 906 899 for name in quantity_names: 907 self.precomputed_values[name] = zeros((p, m), Float)900 self.precomputed_values[name] = numpy.zeros((p, m), numpy.float) 908 901 909 902 # Build interpolator … … 995 988 996 989 from math import pi, cos, sin, sqrt 997 from Numeric import zeros, Float998 990 from anuga.abstract_2d_finite_volumes.util import mean 999 991 … … 1031 1023 1032 1024 # Compute interpolated values 1033 q = zeros(len(self.quantity_names), Float)1025 q = numpy.zeros(len(self.quantity_names), numpy.float) 1034 1026 # print "self.precomputed_values", self.precomputed_values 1035 1027 for i, name in enumerate(self.quantity_names): … … 1086 1078 return q 1087 1079 else: 1088 from Numeric import ones, Float1089 1080 # x is a vector - Create one constant column for each value 1090 1081 N = len(x) … … 1092 1083 res = [] 1093 1084 for col in q: 1094 res.append(col* ones(N, Float))1085 res.append(col*numpy.ones(N, numpy.float)) 1095 1086 1096 1087 return res … … 1129 1120 minq, maxq = self.quantities_range[name] 1130 1121 str += ' %s in [%f, %f]\n' %(name, minq, maxq) 1131 #q = quantities[name][:]. flat1122 #q = quantities[name][:].ravel() 1132 1123 #str += ' %s in [%f, %f]\n' %(name, min(q), max(q)) 1133 1124 … … 1142 1133 1143 1134 for name in quantity_names: 1144 q = precomputed_values[name][:].flat 1135 ##NumPy q = precomputed_values[name][:].ravel() 1136 q = numpy.ravel(precomputed_values[name][:]) 1145 1137 str += ' %s at interpolation points in [%f, %f]\n'\ 1146 1138 %(name, min(q), max(q)) … … 1165 1157 1166 1158 #Add the x and y together 1167 vertex_coordinates = concatenate((x[:,NewAxis], y[:,NewAxis]),axis=1)1159 vertex_coordinates = numpy.concatenate((x[:,numpy.newaxis], y[:,numpy.newaxis]),axis=1) 1168 1160 1169 1161 #Will return the quantity values at the specified times and locations
Note: See TracChangeset
for help on using the changeset viewer.