diff --git a/anuga/abstract_2d_finite_volumes/file_function.py b/anuga/abstract_2d_finite_volumes/file_function.py index 02a215ee0..2c852f9f9 100644 --- a/anuga/abstract_2d_finite_volumes/file_function.py +++ b/anuga/abstract_2d_finite_volumes/file_function.py @@ -262,7 +262,7 @@ def get_netcdf_file_function(filename, if interpolation_points is not None: - #interpolation_points = num.array(interpolation_points, num.float) + #interpolation_points = num.array(interpolation_points, float) interpolation_points = ensure_absolute(interpolation_points) msg = 'Points must by N x 2. I got %d' % interpolation_points.shape[1] assert interpolation_points.shape[1] == 2, msg diff --git a/anuga/abstract_2d_finite_volumes/gauge.py b/anuga/abstract_2d_finite_volumes/gauge.py index b73754f6a..8ea52de60 100644 --- a/anuga/abstract_2d_finite_volumes/gauge.py +++ b/anuga/abstract_2d_finite_volumes/gauge.py @@ -179,7 +179,7 @@ def sww2csv_gauges(sww_file, gid.close() #convert to array for file_function - points_array = num.array(points,num.float) + points_array = num.array(points,float) points_array = ensure_absolute(points_array) @@ -669,18 +669,18 @@ def _generate_figures(plot_quantity, file_loc, report, reportname, surface, if n[i] > n0: n0 = n[i] n0 = int(n0) m = len(locations) - model_time = num.zeros((n0, m, p), num.float) - stages = num.zeros((n0, m, p), num.float) - elevations = num.zeros((n0, m, p), num.float) - momenta = num.zeros((n0, m, p), num.float) - xmom = num.zeros((n0, m, p), num.float) - ymom = num.zeros((n0, m, p), num.float) - speed = num.zeros((n0, m, p), num.float) - bearings = num.zeros((n0, m, p), num.float) - due_east = 90.0*num.ones((n0, 1), num.float) - due_west = 270.0*num.ones((n0, 1), num.float) - depths = num.zeros((n0, m, p), num.float) - eastings = num.zeros((n0, m, p), num.float) + model_time = num.zeros((n0, m, p), float) + stages = num.zeros((n0, m, p), float) + elevations = num.zeros((n0, m, p), float) + momenta = num.zeros((n0, m, p), float) + xmom = num.zeros((n0, m, p), float) + ymom = num.zeros((n0, m, p), float) + speed = num.zeros((n0, m, p), float) + bearings = num.zeros((n0, m, p), float) + due_east = 90.0*num.ones((n0, 1), float) + due_west = 270.0*num.ones((n0, 1), float) + depths = num.zeros((n0, m, p), float) + eastings = num.zeros((n0, m, p), float) min_stages = [] max_stages = [] min_momentums = [] @@ -692,9 +692,9 @@ def _generate_figures(plot_quantity, file_loc, report, reportname, surface, max_speeds = [] min_speeds = [] max_depths = [] - model_time_plot3d = num.zeros((n0, m), num.float) - stages_plot3d = num.zeros((n0, m), num.float) - eastings_plot3d = num.zeros((n0, m),num.float) + model_time_plot3d = num.zeros((n0, m), float) + stages_plot3d = num.zeros((n0, m), float) + eastings_plot3d = num.zeros((n0, m),float) if time_unit == 'mins': scale = 60.0 if time_unit == 'hours': scale = 3600.0 diff --git a/anuga/abstract_2d_finite_volumes/general_mesh.py b/anuga/abstract_2d_finite_volumes/general_mesh.py index 6aad39ac6..814a254ae 100644 --- a/anuga/abstract_2d_finite_volumes/general_mesh.py +++ b/anuga/abstract_2d_finite_volumes/general_mesh.py @@ -91,12 +91,12 @@ def __init__(self, self.use_inscribed_circle = use_inscribed_circle - self.triangles = num.array(triangles, num.int) + self.triangles = num.array(triangles, int) if verbose: log.timingInfo("numTriangles, " + str(self.triangles.shape[0])) - self.nodes = num.array(nodes, num.float) + self.nodes = num.array(nodes, float) # Register number of elements and nodes self.number_of_triangles = N = int(self.triangles.shape[0]) @@ -128,18 +128,18 @@ def __init__(self, xy_extent = [min(self.nodes[:,0]), min(self.nodes[:,1]), max(self.nodes[:,0]), max(self.nodes[:,1])] - self.xy_extent = num.array(xy_extent, num.float) + self.xy_extent = num.array(xy_extent, float) # Allocate space for geometric quantities - self.normals = num.zeros((N, 6), num.float) - self.areas = num.zeros(N, num.float) - self.edgelengths = num.zeros((N, 3), num.float) + self.normals = num.zeros((N, 6), float) + self.areas = num.zeros(N, float) + self.edgelengths = num.zeros((N, 3), float) # Get x,y coordinates for all triangle vertices and store - self.centroid_coordinates = num.zeros((N, 2), num.float) + self.centroid_coordinates = num.zeros((N, 2), float) #Allocate space for geometric quantities - self.radii = num.zeros(N, num.float) + self.radii = num.zeros(N, float) # Get x,y coordinates for all triangle vertices and store self.vertex_coordinates = V = self.compute_vertex_coordinates() @@ -315,13 +315,13 @@ def __init__(self, # # (First normal is associated with the edge opposite # # the first vertex, etc) # # - Stored as six floats n0x,n0y,n1x,n1y,n2x,n2y per triangle -# n0 = num.array([x2-x1, y2-y1], num.float) +# n0 = num.array([x2-x1, y2-y1], float) # l0 = num.sqrt(num.sum(n0**2)) # -# n1 = num.array([x0-x2, y0-y2], num.float) +# n1 = num.array([x0-x2, y0-y2], float) # l1 = num.sqrt(num.sum(n1**2)) # -# n2 = num.array([x1-x0, y1-y0], num.float) +# n2 = num.array([x1-x0, y1-y0], float) # l2 = num.sqrt(num.sum(n2**2)) # # # Normalise @@ -340,7 +340,7 @@ def __init__(self, # # # #Compute centroid -## centroid = num.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3], num.float) +## centroid = num.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3], float) ### self.centroid_coordinates[i] = centroid ## ## @@ -349,9 +349,9 @@ def __init__(self, ## #inscribed circle ## ## #Midpoints -## m0 = num.array([(x1 + x2)/2, (y1 + y2)/2], num.float) -## m1 = num.array([(x0 + x2)/2, (y0 + y2)/2], num.float) -## m2 = num.array([(x1 + x0)/2, (y1 + y0)/2], num.float) +## m0 = num.array([(x1 + x2)/2, (y1 + y2)/2], float) +## m1 = num.array([(x0 + x2)/2, (y0 + y2)/2], float) +## m2 = num.array([(x1 + x0)/2, (y1 + y0)/2], float) ## ## #The radius is the distance from the centroid of ## #a triangle to the midpoint of the side of the triangle @@ -460,7 +460,7 @@ def get_node(self, i, absolute=False): # get a copy so as not to modify the internal self.nodes array V = copy.copy(V) V += num.array([self.geo_reference.get_xllcorner(), - self.geo_reference.get_yllcorner()], num.float) + self.geo_reference.get_yllcorner()], float) return V def get_vertex_coordinates(self, triangle_id=None, absolute=False): @@ -494,7 +494,7 @@ def get_vertex_coordinates(self, triangle_id=None, absolute=False): i3 = 3*i if absolute is True and not self.geo_reference.is_absolute(): offset=num.array([self.geo_reference.get_xllcorner(), - self.geo_reference.get_yllcorner()], num.float) + self.geo_reference.get_yllcorner()], float) return V[i3:i3+3,:] + offset else: @@ -522,13 +522,13 @@ def compute_vertex_coordinates(self): """ M = self.number_of_triangles - vertex_coordinates = num.zeros((3*M, 2), num.float) + vertex_coordinates = num.zeros((3*M, 2), float) k0 = self.triangles[:,0] k1 = self.triangles[:,1] k2 = self.triangles[:,2] -# I = num.arange(M,dtype=num.int) +# I = num.arange(M,dtype=int) # # V0 = V[0:3*M:3, :] # V1 = V[1:3*M:3, :] @@ -577,7 +577,7 @@ def get_edge_midpoint_coordinates(self, triangle_id=None, absolute=False): i3 = 3*i if absolute is True and not self.geo_reference.is_absolute(): offset=num.array([self.geo_reference.get_xllcorner(), - self.geo_reference.get_yllcorner()], num.float) + self.geo_reference.get_yllcorner()], float) return E[i3:i3+3,:] + offset else: @@ -607,7 +607,7 @@ def compute_edge_midpoint_coordinates(self): """ M = self.number_of_triangles - E = num.zeros((3*M, 2), num.float) + E = num.zeros((3*M, 2), float) V = self.vertex_coordinates @@ -670,7 +670,7 @@ def get_disconnected_triangles(self): M = len(self) # Number of triangles K = 3*M # Total number of unique vertices - return num.reshape(num.arange(K, dtype=num.int), (M,3)) + return num.reshape(num.arange(K, dtype=int), (M,3)) def get_unique_vertices(self, indices=None): """Return indices to vertices as a sorted list. @@ -726,7 +726,7 @@ def get_triangles_and_vertices_per_node(self, node=None): triangle_list.append( (volume_id, vertex_id) ) - triangle_list = num.array(triangle_list, num.int) #array default# + triangle_list = num.array(triangle_list, int) #array default# else: # Get info for all nodes recursively. # If need be, we can speed this up by @@ -795,16 +795,16 @@ def build_inverted_triangle_structure(self): # Count number of triangles per node # number_of_triangles_per_node = num.zeros(self.number_of_nodes, -# num.int) #array default# +# int) #array default# # for volume_id, triangle in enumerate(self.get_triangles()): # for vertex_id in triangle: # number_of_triangles_per_node[vertex_id] += 1 # Need to pad number_of_triangles_per_node in case lone nodes at end of list - #number_of_triangles_per_node = num.zeros(self.number_of_nodes, num.int) + #number_of_triangles_per_node = num.zeros(self.number_of_nodes, int) - number_of_triangles_per_node = num.bincount(self.triangles.flat).astype(num.int) + number_of_triangles_per_node = num.bincount(self.triangles.flat).astype(int) number_of_lone_nodes = self.number_of_nodes - len(number_of_triangles_per_node) @@ -817,7 +817,7 @@ def build_inverted_triangle_structure(self): if number_of_lone_nodes > 0: number_of_triangles_per_node = \ - num.append(number_of_triangles_per_node,num.zeros(number_of_lone_nodes,num.int)) + num.append(number_of_triangles_per_node,num.zeros(number_of_lone_nodes,int)) #assert num.allclose(number_of_triangles_per_node_new, number_of_triangles_per_node) @@ -826,21 +826,21 @@ def build_inverted_triangle_structure(self): assert number_of_entries == 3*self.number_of_triangles - #vertex_value_indices = num.zeros(number_of_entries, num.int) #array default# + #vertex_value_indices = num.zeros(number_of_entries, int) #array default# # Array of vertex_indices (3*vol_id+vertex_id) sorted into contiguous # order around each node. Use with number_of_triangles_per_node to # find vertices associated with a node. # ie There are number_of_triangles_per_node[i] vertices - vertex_value_indices = num.argsort(self.triangles.flat).astype(num.int) + vertex_value_indices = num.argsort(self.triangles.flat).astype(int) #vertex_value_indices = num.argsort(self.triangles.flatten()) -# node_index = num.zeros((self.number_of_nodes)+1, dtype = num.int) +# node_index = num.zeros((self.number_of_nodes)+1, dtype = int) # node_index[0] = 0 # for i in xrange(self.number_of_nodes): # node_index[i+1] = node_index[i] + number_of_triangles_per_node[i] - node_index = num.zeros((self.number_of_nodes)+1, dtype = num.int) + node_index = num.zeros((self.number_of_nodes)+1, dtype = int) node_index[1:] = num.cumsum(number_of_triangles_per_node) #assert num.allclose(node_index,node_index_new) diff --git a/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py b/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py index 46949ff96..953503fb0 100644 --- a/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py +++ b/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py @@ -208,7 +208,7 @@ def __init__(self, dirichlet_values=None): msg = 'Must specify one value for each quantity' raise Exception(msg) - self.dirichlet_values=num.array(dirichlet_values, num.float) + self.dirichlet_values=num.array(dirichlet_values, float) @@ -338,7 +338,7 @@ def __init__(self, domain=None, try: - q = num.array(q, num.float) + q = num.array(q, float) except: msg = 'Return value from time boundary function could ' msg += 'not be converted into a numeric array of floats.\n' @@ -457,7 +457,7 @@ def __init__(self, domain=None, try: - q = num.array(q, num.float) + q = num.array(q, float) except: msg = 'Return value from time_space_boundary function could ' msg += 'not be converted into a numeric array of floats.\n' @@ -570,7 +570,7 @@ def __init__(self, filename, domain, # any tagged boundary later on. if verbose: log.critical('Find midpoint coordinates of entire boundary') - self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), num.float) + self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), float) boundary_keys = list(domain.boundary.keys()) xllcorner = domain.geo_reference.get_xllcorner() @@ -758,7 +758,7 @@ def __init__(self, filename, domain, time_thinning=1, # any tagged boundary later on. if verbose: log.critical('Find midpoint coordinates of entire boundary') - self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), num.float) + self.midpoint_coordinates = num.zeros((len(domain.boundary), 2), float) boundary_keys = list(domain.boundary.keys()) xllcorner = domain.geo_reference.get_xllcorner() diff --git a/anuga/abstract_2d_finite_volumes/generic_domain.py b/anuga/abstract_2d_finite_volumes/generic_domain.py index 79ea52e8b..c204e8a62 100644 --- a/anuga/abstract_2d_finite_volumes/generic_domain.py +++ b/anuga/abstract_2d_finite_volumes/generic_domain.py @@ -232,13 +232,13 @@ def __init__(self, buffer_shape = self.full_send_dict[key][0].shape[0] self.full_send_dict[key].append(num.zeros((buffer_shape, self.nsys), - num.float)) + float)) for key in self.ghost_recv_dict: buffer_shape = self.ghost_recv_dict[key][0].shape[0] self.ghost_recv_dict[key].append(num.zeros((buffer_shape, self.nsys), - num.float)) + float)) # Setup triangle full flag if verbose: @@ -249,7 +249,7 @@ def __init__(self, # =1 for full # =0 for ghost - self.tri_full_flag = num.ones(N, num.int) + self.tri_full_flag = num.ones(N, int) for i in list(self.ghost_recv_dict.keys()): id = self.ghost_recv_dict[i][0] @@ -276,7 +276,7 @@ def __init__(self, # print list(b) # print num.repeat(self.tri_full_flag, 3) - self.node_full_flag = num.minimum(num.bincount(self.triangles.flat, weights=W).astype(num.int), 1) + self.node_full_flag = num.minimum(num.bincount(self.triangles.flat, weights=W).astype(int), 1) # FIXME SR: The following line leads to a nasty segmentation fault! # self.number_of_full_nodes = int(num.sum(self.node_full_flag)) @@ -346,14 +346,14 @@ def __init__(self, # To avoid calculating the flux across each edge twice, keep an integer # (boolean) array, to be used during the flux calculation. N = len(self) # Number_of_triangles - self.already_computed_flux = num.zeros((N, 3), num.int) + self.already_computed_flux = num.zeros((N, 3), int) - self.work_centroid_values = num.zeros(N, num.float) + self.work_centroid_values = num.zeros(N, float) # Storage for maximal speeds computed for each triangle by # compute_fluxes. # This is used for diagnostics only (reset at every yieldstep) - self.max_speed = num.zeros(N, num.float) + self.max_speed = num.zeros(N, float) if mesh_filename is not None: # If the mesh file passed any quantity values, @@ -486,7 +486,7 @@ def get_conserved_quantities(self, vol_id, msg += 'Only one (or none) is allowed.' raise Exception(msg) - q = num.zeros(len(self.conserved_quantities), num.float) + q = num.zeros(len(self.conserved_quantities), float) for i, name in enumerate(self.conserved_quantities): Q = self.quantities[name] @@ -517,7 +517,7 @@ def get_evolved_quantities(self, vol_id, msg += 'Only one (or none) is allowed.' raise Exception(msg) - q = num.zeros(len(self.evolved_quantities), num.float) + q = num.zeros(len(self.evolved_quantities), float) for i, name in enumerate(self.evolved_quantities): Q = self.quantities[name] @@ -1750,7 +1750,7 @@ def _evolve_base(self, yieldstep=None, self.recorded_max_timestep = self.evolve_min_timestep self.number_of_steps = 0 self.number_of_first_order_steps = 0 - self.max_speed = num.zeros(N, num.float) + self.max_speed = num.zeros(N, float) def evolve_one_euler_step(self, yieldstep, finaltime): """One Euler Time Step diff --git a/anuga/abstract_2d_finite_volumes/mesh_factory.py b/anuga/abstract_2d_finite_volumes/mesh_factory.py index 33cc4f262..14dcb0d3d 100644 --- a/anuga/abstract_2d_finite_volumes/mesh_factory.py +++ b/anuga/abstract_2d_finite_volumes/mesh_factory.py @@ -99,7 +99,7 @@ def __call__(self, i,j): index = Index(n,m) - points = num.zeros((Np, 2), num.float) + points = num.zeros((Np, 2), float) for i in range(m+1): for j in range(n+1): @@ -111,7 +111,7 @@ def __call__(self, i,j): Nt = 2*m*n - elements = num.zeros((Nt, 3), num.int) + elements = num.zeros((Nt, 3), int) boundary = {} nt = -1 for i in range(m): @@ -164,11 +164,11 @@ def rectangular_cross(m, n, len1=1.0, len2=1.0, origin = (0.0, 0.0)): params.append(len1) params.append(len2) - arrParams = num.array(params, dtype=num.float) - arrOrigin = num.array(origin, dtype=num.float) + arrParams = num.array(params, dtype=float) + arrOrigin = num.array(origin, dtype=float) - points = num.empty([(m+1)*(n+1)+m*n,2], dtype=num.float) - elements = num.empty([4*m*n,3], dtype=num.int) + points = num.empty([(m+1)*(n+1)+m*n,2], dtype=float) + elements = num.empty([4*m*n,3], dtype=int) from .mesh_factory_ext import rectangular_cross_construct boundary = rectangular_cross_construct(arrParams, arrOrigin, points, elements) @@ -374,7 +374,7 @@ def __call__(self, i,j): I = VIndex(n,m) E = EIndex(n,m) - points = num.zeros( (Np,2), num.float) + points = num.zeros( (Np,2), float) for i in range(m+1): for j in range(n+1): @@ -386,7 +386,7 @@ def __call__(self, i,j): Nt = 2*m*n - elements = num.zeros( (Nt,3), num.int) + elements = num.zeros( (Nt,3), int) boundary = {} Idgl = [] Idfl = [] @@ -454,8 +454,8 @@ def __call__(self, i,j): Idfl.extend(Idfr) Idgr.extend(Idgl) - Idfl = num.array(Idfl, num.int) - Idgr = num.array(Idgr, num.int) + Idfl = num.array(Idfl, int) + Idgr = num.array(Idgr, int) full_send_dict[processor] = [Idfl, Idfl] ghost_recv_dict[processor] = [Idgr, Idgr] diff --git a/anuga/abstract_2d_finite_volumes/mesh_factory_ext.pyx b/anuga/abstract_2d_finite_volumes/mesh_factory_ext.pyx index eea415206..cd3668c57 100644 --- a/anuga/abstract_2d_finite_volumes/mesh_factory_ext.pyx +++ b/anuga/abstract_2d_finite_volumes/mesh_factory_ext.pyx @@ -20,7 +20,7 @@ def rectangular_cross_construct(np.ndarray[double, ndim=1, mode="c"] params not len1 = params[2] len2 = params[3] - cdef np.ndarray[long, ndim=2, mode="c"] vertices = np.ascontiguousarray(np.zeros((m+1,n+1),dtype=np.int)) + cdef np.ndarray[long, ndim=2, mode="c"] vertices = np.ascontiguousarray(np.zeros((m+1,n+1),dtype=int)) delta1 = len1/m delta2 = len2/n diff --git a/anuga/abstract_2d_finite_volumes/neighbour_mesh.py b/anuga/abstract_2d_finite_volumes/neighbour_mesh.py index bb334d8e2..5985e250e 100644 --- a/anuga/abstract_2d_finite_volumes/neighbour_mesh.py +++ b/anuga/abstract_2d_finite_volumes/neighbour_mesh.py @@ -100,10 +100,10 @@ def __init__(self, coordinates, triangles, # Allocate arrays for neighbour data - self.neighbours = -1*num.ones((N, 3), num.int) - self.neighbour_edges = -1*num.ones((N, 3), num.int) - self.number_of_boundaries = num.zeros(N, num.int) - self.surrogate_neighbours = num.zeros((N, 3), num.int) + self.neighbours = -1*num.ones((N, 3), int) + self.neighbour_edges = -1*num.ones((N, 3), int) + self.number_of_boundaries = num.zeros(N, int) + self.surrogate_neighbours = num.zeros((N, 3), int) #Get x,y coordinates for all triangles and store V = self.vertex_coordinates # Relative coordinates @@ -122,7 +122,7 @@ def __init__(self, coordinates, triangles, # #x2 = V[i, 4]; y2 = V[i, 5] # # #Compute centroid -# centroid = num.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3], num.float) +# centroid = num.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3], float) # self.centroid_coordinates[i] = centroid # # @@ -131,9 +131,9 @@ def __init__(self, coordinates, triangles, # #inscribed circle # # #Midpoints -# m0 = num.array([(x1 + x2)/2, (y1 + y2)/2], num.float) -# m1 = num.array([(x0 + x2)/2, (y0 + y2)/2], num.float) -# m2 = num.array([(x1 + x0)/2, (y1 + y0)/2], num.float) +# m0 = num.array([(x1 + x2)/2, (y1 + y2)/2], float) +# m1 = num.array([(x0 + x2)/2, (y0 + y2)/2], float) +# m2 = num.array([(x1 + x0)/2, (y1 + y0)/2], float) # # #The radius is the distance from the centroid of # #a triangle to the midpoint of the side of the triangle @@ -451,7 +451,7 @@ def build_tagged_elements_dictionary(self, tagged_elements = None): else: #Check that all keys in given boundary exist for tag in list(tagged_elements.keys()): - tagged_elements[tag] = num.array(tagged_elements[tag], num.int) + tagged_elements[tag] = num.array(tagged_elements[tag], int) msg = 'Not all elements exist. ' assert max(tagged_elements[tag]) < len(self), msg @@ -541,8 +541,8 @@ def build_boundary_neighbours(self): # Now we know number of boundaries M = len(self.boundary_enumeration) - self.boundary_cells = num.zeros((M,),num.int) - self.boundary_edges = num.zeros((M,),num.int) + self.boundary_cells = num.zeros((M,),int) + self.boundary_edges = num.zeros((M,),int) for id, edge in X: j = self.boundary_enumeration[id,edge] @@ -1425,8 +1425,8 @@ def _get_intersecting_segments(V, N, line, # the line and the normals # Distances from line origin to the two intersections - z0 = num.array([x0 - xi0, y0 - eta0], num.float) - z1 = num.array([x1 - xi0, y1 - eta0], num.float) + z0 = num.array([x0 - xi0, y0 - eta0], float) + z1 = num.array([x1 - xi0, y1 - eta0], float) d0 = num.sqrt(num.sum(z0**2)) d1 = num.sqrt(num.sum(z1**2)) @@ -1441,9 +1441,9 @@ def _get_intersecting_segments(V, N, line, # Normal direction: # Right hand side relative to line direction - vector = num.array([x1 - x0, y1 - y0], num.float) # Segment vector + vector = num.array([x1 - x0, y1 - y0], float) # Segment vector length = num.sqrt(num.sum(vector**2)) # Segment length - normal = old_div(num.array([vector[1], -vector[0]], num.float),length) + normal = old_div(num.array([vector[1], -vector[0]], float),length) segment = ((x0,y0), (x1, y1)) @@ -1523,7 +1523,7 @@ def segment_midpoints(segments): for segment in segments: assert isinstance(segment, Triangle_intersection), msg - midpoint = old_div(num.sum(num.array(segment.segment, num.float), axis=0),2) + midpoint = old_div(num.sum(num.array(segment.segment, float), axis=0),2) midpoints.append(midpoint) return midpoints diff --git a/anuga/abstract_2d_finite_volumes/pmesh2domain.py b/anuga/abstract_2d_finite_volumes/pmesh2domain.py index 94c2d6850..e5c84948a 100644 --- a/anuga/abstract_2d_finite_volumes/pmesh2domain.py +++ b/anuga/abstract_2d_finite_volumes/pmesh2domain.py @@ -171,7 +171,7 @@ def pmesh_dict_to_tag_dict_old(mesh_dict): triangles = mesh_dict['triangles'] - triangles = num.array(triangles,num.int) + triangles = num.array(triangles,int) sides = {} for id, triangle in enumerate(triangles): @@ -207,8 +207,8 @@ def pmesh_dict_to_tag_dict(mesh_dict): segments = mesh_dict['segments'] segment_tags = mesh_dict['segment_tags'] - triangles = num.array(triangles,num.int) - segments = num.array(segments,num.int) + triangles = num.array(triangles,int) + segments = num.array(segments,int) tag_dict = {} #print triangles @@ -233,7 +233,7 @@ def calc_sides_old(triangles): ''' sides = {} - triangles = num.array(triangles,num.int) + triangles = num.array(triangles,int) for id, triangle in enumerate(triangles): a = triangle[0] b = triangle[1] @@ -255,7 +255,7 @@ def calc_sides_zip(triangles): sides = {} - triangles = num.array(triangles,num.int) + triangles = num.array(triangles,int) a = triangles[:,0] @@ -278,7 +278,7 @@ def calc_sides_c(triangles): sides = {} - triangles = num.array(triangles,num.int) + triangles = num.array(triangles,int) ntriangles = len(triangles) # print 'calc_sides' diff --git a/anuga/abstract_2d_finite_volumes/quantity.py b/anuga/abstract_2d_finite_volumes/quantity.py index 4532c0b89..9e1d1a850 100644 --- a/anuga/abstract_2d_finite_volumes/quantity.py +++ b/anuga/abstract_2d_finite_volumes/quantity.py @@ -51,9 +51,9 @@ def __init__(self, domain, vertex_values=None, name=None, register=False): if vertex_values is None: N = len(domain) # number_of_elements - self.vertex_values = num.zeros((N, 3), num.float) + self.vertex_values = num.zeros((N, 3), float) else: - self.vertex_values = num.array(vertex_values, num.float) + self.vertex_values = num.array(vertex_values, float) N, V = self.vertex_values.shape assert V == 3, 'Three vertex values per element must be specified' @@ -65,15 +65,15 @@ def __init__(self, domain, vertex_values=None, name=None, register=False): self.domain = domain # Allocate space for other quantities - self.centroid_values = num.zeros(N, num.float) - self.edge_values = num.zeros((N, 3), num.float) + self.centroid_values = num.zeros(N, float) + self.edge_values = num.zeros((N, 3), float) # Allocate space for Gradient - self.x_gradient = num.zeros(N, num.float) - self.y_gradient = num.zeros(N, num.float) + self.x_gradient = num.zeros(N, float) + self.y_gradient = num.zeros(N, float) # Allocate space for Limiter Phi - self.phi = num.zeros(N, num.float) + self.phi = num.zeros(N, float) # Intialise centroid and edge_values self.interpolate() @@ -81,15 +81,15 @@ def __init__(self, domain, vertex_values=None, name=None, register=False): # Allocate space for boundary values #self.boundary_length = domain.boundary_length self.boundary_length = L = self.domain.boundary_length - self.boundary_values = num.zeros(L, num.float) + self.boundary_values = num.zeros(L, float) # Allocate space for updates of conserved quantities by # flux calculations and forcing functions # Allocate space for update fields - self.explicit_update = num.zeros(N, num.float ) - self.semi_implicit_update = num.zeros(N, num.float ) - self.centroid_backup_values = num.zeros(N, num.float) + self.explicit_update = num.zeros(N, float ) + self.semi_implicit_update = num.zeros(N, float ) + self.centroid_backup_values = num.zeros(N, float) self.set_beta(1.0) @@ -513,11 +513,11 @@ def save_to_array(self, y = y + yllcorner - newyllcorner - grid_values = num.zeros( (nrows*ncols, ), num.float) + grid_values = num.zeros( (nrows*ncols, ), float) num_tri = len(v) - norms = num.zeros(6*num_tri, num.float) + norms = num.zeros(6*num_tri, float) #Use fast method to calc grid values @@ -1019,10 +1019,10 @@ def set_values_from_array(self, values, will be assigned and the others will be left undefined. """ - values = num.array(values, num.float) + values = num.array(values, float) if indices is not None: - indices = num.array(indices, num.int) + indices = num.array(indices, int) msg = ('Number of values must match number of indices: You ' 'specified %d values and %d indices' % (values.shape[0], indices.shape[0])) @@ -1182,8 +1182,8 @@ def set_values_from_geospatial_data(self, from anuga.coordinate_transforms.geo_reference import Geo_reference - points = ensure_numeric(points, num.float) - values = ensure_numeric(values, num.float) + points = ensure_numeric(points, float) + values = ensure_numeric(values, float) if location != 'vertices': msg = ("set_values_from_points is only defined for " @@ -1917,7 +1917,7 @@ def get_values(self, sum += self.vertex_values[triangle_id, vertex_id] vert_values.append(sum / len(triangles)) - return num.array(vert_values, num.float) + return num.array(vert_values, float) else: if indices is None: return self.vertex_values.copy() @@ -1939,7 +1939,7 @@ def set_vertex_values(self, """ # Check that A can be converted to array and is of appropriate dim - A = ensure_numeric(A, num.float) + A = ensure_numeric(A, float) assert len(A.shape) == 1 if indices is None: @@ -2034,13 +2034,13 @@ def get_vertex_values(self, xy=True, smooth=None, precision=None): smooth = False if precision is None: - precision = num.float + precision = float if smooth is True: # Ensure continuous vertex values by averaging values at each node V = self.domain.get_triangles() N = self.domain.number_of_full_nodes # Ignore ghost nodes if any - A = num.zeros(N, num.float) + A = num.zeros(N, float) points = self.domain.get_nodes() if True: diff --git a/anuga/abstract_2d_finite_volumes/region.py b/anuga/abstract_2d_finite_volumes/region.py index b92e28e98..0f3804254 100644 --- a/anuga/abstract_2d_finite_volumes/region.py +++ b/anuga/abstract_2d_finite_volumes/region.py @@ -163,7 +163,7 @@ def plot_region(self, filename=None): vertices = self.domain.get_vertex_coordinates() full_mask = num.repeat(self.domain.tri_full_flag == 1, 3) - region_mask = num.zeros(len(self.domain),num.int).astype(bool) + region_mask = num.zeros(len(self.domain),int).astype(bool) region_mask[self.indices] = True region_mask = num.repeat(region_mask,3) diff --git a/anuga/abstract_2d_finite_volumes/tests/test_general_mesh.py b/anuga/abstract_2d_finite_volumes/tests/test_general_mesh.py index 8ccb6f204..fe6ad2f3e 100644 --- a/anuga/abstract_2d_finite_volumes/tests/test_general_mesh.py +++ b/anuga/abstract_2d_finite_volumes/tests/test_general_mesh.py @@ -63,7 +63,7 @@ def test_get_vertex_coordinates_with_geo_ref(self): nodes_absolute = geo.get_absolute(nodes) # bac, bce, ecf, dbe - triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.int) + triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], int) domain = General_mesh(nodes, triangles, geo_reference=geo) @@ -166,7 +166,7 @@ def test_get_edge_midpoint_coordinates_with_geo_ref(self): nodes_absolute = geo.get_absolute(nodes) # bac, bce, ecf, dbe - triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.int) + triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], int) domain = General_mesh(nodes, triangles, geo_reference=geo) @@ -366,7 +366,7 @@ def test_one_degenerate_triangles(self): # bac, bce, ecf, dbe - triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.int) + triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], int) try: domain = General_mesh(nodes, triangles) @@ -388,7 +388,7 @@ def test_two_degenerate_triangles(self): nodes = num.array([a, b, c, d, e, f]) # bac, bce, ecf, dbe - triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], num.int) + triangles = num.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], int) try: diff --git a/anuga/abstract_2d_finite_volumes/tests/test_generic_domain.py b/anuga/abstract_2d_finite_volumes/tests/test_generic_domain.py index 8fb52fd4c..14e2c8453 100644 --- a/anuga/abstract_2d_finite_volumes/tests/test_generic_domain.py +++ b/anuga/abstract_2d_finite_volumes/tests/test_generic_domain.py @@ -384,8 +384,8 @@ def test_add_quantity(self): other_quantities = ['elevation', 'friction', 'depth']) - A = num.array([[1,2,3], [5,5,-5], [0,0,9], [-6,3,3]], num.float) - B = num.array([[2,4,4], [3,2,1], [6,-3,4], [4,5,-1]], num.float) + A = num.array([[1,2,3], [5,5,-5], [0,0,9], [-6,3,3]], float) + B = num.array([[2,4,4], [3,2,1], [6,-3,4], [4,5,-1]], float) # Shorthands stage = domain.quantities['stage'] @@ -760,7 +760,7 @@ def test_update_conserved_quantities(self): domain.update_conserved_quantities() sem = old_div(num.array([1.,1.,1.,1.]),num.array([1, 2, 3, 4])) - denom = num.ones(4, num.float) - domain.timestep*sem + denom = num.ones(4, float) - domain.timestep*sem # x = array([1, 2, 3, 4]) + array( [.4,.3,.2,.1] ) # x /= denom diff --git a/anuga/abstract_2d_finite_volumes/tests/test_neighbour_mesh.py b/anuga/abstract_2d_finite_volumes/tests/test_neighbour_mesh.py index c0a671f59..b55834668 100644 --- a/anuga/abstract_2d_finite_volumes/tests/test_neighbour_mesh.py +++ b/anuga/abstract_2d_finite_volumes/tests/test_neighbour_mesh.py @@ -1017,8 +1017,8 @@ def test_boundary_polygon_VI(self): [16, 6, 5]] - triangles = num.array(triangles,num.int) - points = num.array(points,num.float) + triangles = num.array(triangles,int) + points = num.array(points,float) mesh = Mesh(points, triangles) mesh.check_integrity() @@ -1099,7 +1099,7 @@ def test_boundary_polygon_VI(self): [ 31998.23828125, 88799.84375 ], [ 35406.3359375 , 79332.9140625 ]] - scaled_points = old_div(ensure_numeric(points, num.int),1000) # Simplify for ease of interpretation + scaled_points = old_div(ensure_numeric(points, int),1000) # Simplify for ease of interpretation triangles = [[ 0, 1, 2], [ 3, 4, 5], diff --git a/anuga/abstract_2d_finite_volumes/tests/test_quantity.py b/anuga/abstract_2d_finite_volumes/tests/test_quantity.py index 22695b5be..3170941d6 100644 --- a/anuga/abstract_2d_finite_volumes/tests/test_quantity.py +++ b/anuga/abstract_2d_finite_volumes/tests/test_quantity.py @@ -2066,7 +2066,7 @@ def test_interpolate_from_vertices_to_edges(self): quantity = Quantity(self.mesh4) quantity.vertex_values = num.array( - [[1, 0, 2], [1, 2, 4], [4, 2, 5], [3, 1, 4]], num.float) + [[1, 0, 2], [1, 2, 4], [4, 2, 5], [3, 1, 4]], float) quantity.interpolate_from_vertices_to_edges() @@ -2081,7 +2081,7 @@ def test_interpolate_from_edges_to_vertices(self): quantity.edge_values = num.array([[1., 1.5, 0.5], [3., 2.5, 1.5], [3.5, 4.5, 3.], - [2.5, 3.5, 2]], num.float) + [2.5, 3.5, 2]], float) quantity.interpolate_from_edges_to_vertices() @@ -2131,7 +2131,7 @@ def test_update_semi_implicit(self): quantity.update(timestep) sem = old_div(num.array([1., 1., 1., 1.]),num.array([1, 2, 3, 4])) - denom = num.ones(4, num.float)-timestep*sem + denom = num.ones(4, float)-timestep*sem x = old_div(num.array([1, 2, 3, 4]),denom) assert num.allclose(quantity.centroid_values, x) @@ -2154,7 +2154,7 @@ def test_both_updates(self): quantity.update(0.1) sem = old_div(num.array([1., 1., 1., 1.]),num.array([1, 2, 3, 4])) - denom = num.ones(4, num.float)-timestep*sem + denom = num.ones(4, float)-timestep*sem x = num.array([1., 2., 3., 4.]) x += timestep*num.array([4.0, 3.0, 2.0, 1.0]) diff --git a/anuga/abstract_2d_finite_volumes/tests/test_util.py b/anuga/abstract_2d_finite_volumes/tests/test_util.py index c736c4fc3..f6d97ea8f 100644 --- a/anuga/abstract_2d_finite_volumes/tests/test_util.py +++ b/anuga/abstract_2d_finite_volumes/tests/test_util.py @@ -387,8 +387,8 @@ def test_spatio_temporal_file_function_different_origin(self): y = fid.variables['y'][:] # we 'cast' to 64 bit floats to pass this test # SWW file quantities are stored as 32 bits - x = num.array(x, num.float) - y = num.array(y, num.float) + x = num.array(x, float) + y = num.array(y, float) stage = fid.variables['stage'][:] xmomentum = fid.variables['xmomentum'][:] @@ -1249,9 +1249,9 @@ def test_apply_expression_to_dictionary(self): #FIXME: Division is not expected to work for integers. #This must be caught. - foo = num.array([[1,2,3], [4,5,6]], num.float) + foo = num.array([[1,2,3], [4,5,6]], float) - bar = num.array([[-1,0,5], [6,1,1]], num.float) + bar = num.array([[-1,0,5], [6,1,1]], float) D = {'X': foo, 'Y': bar} diff --git a/anuga/abstract_2d_finite_volumes/util.py b/anuga/abstract_2d_finite_volumes/util.py index 12f71a62a..3a00486ed 100644 --- a/anuga/abstract_2d_finite_volumes/util.py +++ b/anuga/abstract_2d_finite_volumes/util.py @@ -272,7 +272,7 @@ def get_centroid_values(x, triangles): indices into x """ - xc = num.zeros(triangles.shape[0], num.float) # Space for centroid info + xc = num.zeros(triangles.shape[0], float) # Space for centroid info for k in range(triangles.shape[0]): # Indices of vertices @@ -554,7 +554,7 @@ def csv2timeseries_graphs(directories_dic={}, #add tide to stage if provided if quantity == 'stage': quantity_value[quantity] = num.array(quantity_value[quantity], - num.float) + directory_add_tide + float) + directory_add_tide #condition to find max and mins for all the plots # populate the list with something when i=0 and j=0 and diff --git a/anuga/advection/advection.py b/anuga/advection/advection.py index d5a36a135..31c4f830b 100644 --- a/anuga/advection/advection.py +++ b/anuga/advection/advection.py @@ -257,7 +257,7 @@ def compute_fluxes_python(self): stage_bdry = Stage.boundary_values - flux = num.zeros(1, num.float) #Work array for summing up fluxes + flux = num.zeros(1, float) #Work array for summing up fluxes #Loop for k in range(N): diff --git a/anuga/alpha_shape/alpha_shape.py b/anuga/alpha_shape/alpha_shape.py index 75552ec39..2a129af2e 100644 --- a/anuga/alpha_shape/alpha_shape.py +++ b/anuga/alpha_shape/alpha_shape.py @@ -95,7 +95,7 @@ def _set_points(self, points): raise PointError("Three points on a straight line") #Convert input to numeric arrays - self.points = num.array(points, num.float) + self.points = num.array(points, float) def write_boundary(self,file_name): diff --git a/anuga/caching/tests/test_caching.py b/anuga/caching/tests/test_caching.py index e12a50b42..9f889c2a6 100644 --- a/anuga/caching/tests/test_caching.py +++ b/anuga/caching/tests/test_caching.py @@ -439,7 +439,7 @@ def __call__(self, x): msg = 'Byte code should be different' assert bc1 != bc2, msg - x = num.arange(10).astype(num.float) + x = num.arange(10).astype(float) ref1 = f1(x) ref2 = f2(x) diff --git a/anuga/coordinate_transforms/geo_reference.py b/anuga/coordinate_transforms/geo_reference.py index ddbd194ea..cd6dbaaff 100644 --- a/anuga/coordinate_transforms/geo_reference.py +++ b/anuga/coordinate_transforms/geo_reference.py @@ -273,7 +273,7 @@ def change_points_geo_ref(self, points, points_geo_ref=None): # remember if we got a list is_list = isinstance(points, list) - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) # sanity checks if len(points.shape) == 1: @@ -339,7 +339,7 @@ def get_absolute(self, points): # remember if we got a list is_list = isinstance(points, list) - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) if len(points.shape) == 1: # One point has been passed msg = 'Single point must have two elements' @@ -378,7 +378,7 @@ def get_relative(self, points): # remember if we got a list is_list = isinstance(points, list) - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) if len(points.shape) == 1: #One point has been passed msg = 'Single point must have two elements' diff --git a/anuga/coordinate_transforms/tests/test_geo_reference.py b/anuga/coordinate_transforms/tests/test_geo_reference.py index dc8733c6f..fc3f7bf9d 100644 --- a/anuga/coordinate_transforms/tests/test_geo_reference.py +++ b/anuga/coordinate_transforms/tests/test_geo_reference.py @@ -609,7 +609,7 @@ def test_functionality_get_absolute(self): self.assertTrue(num.alltrue(new_points == points)) # points in num.array() - points = num.array(((2,3), (3,1), (5,2)), num.float) + points = num.array(((2,3), (3,1), (5,2)), float) abs_points = geo.get_absolute(points) # check we haven't changed 'points' itself self.assertFalse(num.alltrue(abs_points == points)) diff --git a/anuga/damage_modelling/inundation_damage.py b/anuga/damage_modelling/inundation_damage.py index 54cc826f8..cd30a7b52 100644 --- a/anuga/damage_modelling/inundation_damage.py +++ b/anuga/damage_modelling/inundation_damage.py @@ -359,8 +359,8 @@ def calc_damage_percentages(self): """ # the data being created - struct_damage = num.zeros(self.structure_count, num.float) - contents_damage = num.zeros(self.structure_count, num.float) + struct_damage = num.zeros(self.structure_count, float) + contents_damage = num.zeros(self.structure_count, float) self.struct_inundated = ['']* self.structure_count for i,max_depth,shore_distance,wall in zip( diff --git a/anuga/damage_modelling/tests/test_inundation_damage.py b/anuga/damage_modelling/tests/test_inundation_damage.py index 36927d441..43de6d701 100644 --- a/anuga/damage_modelling/tests/test_inundation_damage.py +++ b/anuga/damage_modelling/tests/test_inundation_damage.py @@ -91,7 +91,7 @@ def setUp(self): ###################### #Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): @@ -161,7 +161,7 @@ def setUp(self): ###################### #Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 30. for i in range(stage.shape[0]): @@ -488,8 +488,8 @@ def test_calc_damage_percentages(self): def test_calc_collapse_structures1(self): edm = EventDamageModel([0.0]*17, [0.0]*17, [0.0]*17, [0.0]*17, [0.0]*17) - edm.struct_damage = num.zeros(17,num.float) - edm.contents_damage = num.zeros(17,num.float) + edm.struct_damage = num.zeros(17,float) + edm.contents_damage = num.zeros(17,float) collapse_probability = {0.4:[0], #0 0.6:[1], #1 0.5:[2], #1 diff --git a/anuga/file/mux.py b/anuga/file/mux.py index bff421e90..3692d4c74 100644 --- a/anuga/file/mux.py +++ b/anuga/file/mux.py @@ -41,7 +41,7 @@ def read_mux2_py(filenames, numSrc = len(filenames) - file_params = -1 * num.ones(3, num.float) # [nsta,dt,nt] + file_params = -1 * num.ones(3, float) # [nsta,dt,nt] # Convert verbose to int C flag if verbose: @@ -53,7 +53,7 @@ def read_mux2_py(filenames, weights = num.ones(numSrc) if permutation is None: - permutation = ensure_numeric([], num.int) + permutation = ensure_numeric([], int) # Call underlying C implementation urs2sts_ext.c cast_filenames = [] @@ -104,11 +104,11 @@ def read_mux2_py(filenames, parameters_index = data.shape[1] - OFFSET times = dt * num.arange(parameters_index) - latitudes = num.zeros(number_of_selected_stations, num.float) - longitudes = num.zeros(number_of_selected_stations, num.float) - elevation = num.zeros(number_of_selected_stations, num.float) + latitudes = num.zeros(number_of_selected_stations, float) + longitudes = num.zeros(number_of_selected_stations, float) + elevation = num.zeros(number_of_selected_stations, float) quantity = num.zeros((number_of_selected_stations, parameters_index), \ - num.float) + float) starttime = 1e16 for i in range(number_of_selected_stations): diff --git a/anuga/file/sts.py b/anuga/file/sts.py index 9d6fb18f3..ba7a56c28 100644 --- a/anuga/file/sts.py +++ b/anuga/file/sts.py @@ -177,7 +177,7 @@ def store_points(self, outfile.variables[q + Write_sts.RANGE][0] = min(elevation) outfile.variables[q + Write_sts.RANGE][1] = max(elevation) - def store_quantities(self, outfile, sts_precision=num.float, + def store_quantities(self, outfile, sts_precision=float, slice_index=None, time=None, verbose=False, **quant): """Write the quantity info. diff --git a/anuga/file/sww.py b/anuga/file/sww.py index ea4340be2..973892ce2 100644 --- a/anuga/file/sww.py +++ b/anuga/file/sww.py @@ -1,7 +1,5 @@ """ Classes to read an SWW file. """ -from __future__ import absolute_import -from __future__ import division import numpy import numpy as num @@ -24,12 +22,6 @@ from builtins import object from future.utils import raise_ -# Python 2.7 Hack -try: - from exceptions import Exception -except: - pass - class DataFileNotOpenError(Exception): pass @@ -450,7 +442,7 @@ def __init__(self, source): fin = NetCDFFile(self.source, 'r') - self.time = num.array(fin.variables['time'][:], num.float) + self.time = num.array(fin.variables['time'][:], float) self.last_frame_number = self.time.shape[0] - 1 self.frames = num.arange(self.last_frame_number+1) @@ -468,10 +460,10 @@ def read_mesh(self): """ fin = NetCDFFile(self.source, 'r') - self.vertices = num.array(fin.variables['volumes'][:], num.int) + self.vertices = num.array(fin.variables['volumes'][:], int) - self.x = x = num.array(fin.variables['x'][:], num.float) - self.y = y = num.array(fin.variables['y'][:], num.float) + self.x = x = num.array(fin.variables['x'][:], float) + self.y = y = num.array(fin.variables['y'][:], float) assert len(self.x) == len(self.y) @@ -500,10 +492,10 @@ def read_quantities(self, frame_number=0): # print q if len(fin.variables[q].shape) == 1: # Not a time-varying quantity self.quantities[q] = num.ravel( - num.array(fin.variables[q][:], num.float)).reshape(M, 3) + num.array(fin.variables[q][:], float)).reshape(M, 3) else: # Time-varying, get the current timestep data self.quantities[q] = num.array( - fin.variables[q][self.frame_number], num.float).reshape(M, 3) + fin.variables[q][self.frame_number], float).reshape(M, 3) fin.close() return self.quantities @@ -888,7 +880,7 @@ def store_static_quantities(self, The argument sww_precision allows for storing as either * single precision (default): num.float32 - * double precision: num.float64 or num.float + * double precision: num.float64 or float Precondition: store_triangulation and @@ -934,7 +926,7 @@ def store_static_quantities_centroid(self, The argument sww_precision allows for storing as either * single precision (default): num.float32 - * double precision: num.float64 or num.float + * double precision: num.float64 or float Precondition: store_triangulation and @@ -986,7 +978,7 @@ def store_quantities(self, The argument sww_precision allows for storing as either * single precision (default): num.float32 - * double precision: num.float64 or num.float + * double precision: num.float64 or float Precondition: store_triangulation and @@ -1059,7 +1051,7 @@ def store_quantities_centroid(self, The argument sww_precision allows for storing as either * single precision (default): num.float32 - * double precision: num.float64 or num.float + * double precision: num.float64 or float Precondition: store_triangulation and @@ -1392,7 +1384,7 @@ def gather(quantity): def my_num_add_at(a, indices, b): """ - Use the numpy add.at opperation if it is available, (numpy version >1.8) + Use the numpy add.at operation if it is available, (numpy version >1.8) otherwise just use a quick and dirty implementation via a python loop """ @@ -1400,7 +1392,7 @@ def my_num_add_at(a, indices, b): num.add.at(a, indices, b) except: n_ids = len(indices) - b_array = num.zeros_like(indices, dtype=num.float) + b_array = num.zeros_like(indices, dtype=float) b_array[:] = b for n in range(n_ids): @@ -1572,3 +1564,49 @@ def weed(coordinates, volumes, boundary=None): boundary = new_boundary return coordinates, volumes, boundary + + +def sww_files_are_equal(filename1, filename2): + """Read and compare numerical values of two sww files: filename1 and filename2 + + If they are identical (up to a tolerance) the return value is True + If anything substantial is different, the return value is False. + """ + + import anuga.utilities.plot_utils as util + + if not (filename1.endswith('.sww') and filename2.endswith('.sww')): + msg = f'Filenames {filename1} and {filename2} must both end with .sww' + raise Exception(msg) + + + domain1_v = util.get_output(filename1) + domain1_c = util.get_centroids(domain1_v) + + domain2_v = util.get_output(filename2) + domain2_c = util.get_centroids(domain2_v) + + if not num.allclose(domain1_c.stage, domain2_c.stage): + return False + + if not num.allclose(domain1_c.xmom, domain2_c.xmom): + return False + + if not num.allclose(domain1_c.ymom, domain2_c.ymom): + return False + + if not num.allclose(domain1_c.xvel, domain2_c.xvel): + return False + + if not num.allclose(domain1_c.yvel, domain2_c.yvel): + return False + + if not num.allclose(domain1_v.x, domain2_v.x): + return False + + if not num.allclose(domain1_v.y, domain2_v.y): + return False + + # Otherwise, they are deemed to be identical + return True + diff --git a/anuga/file/tests/test_mux.py b/anuga/file/tests/test_mux.py index 1d773796f..67a30dda5 100644 --- a/anuga/file/tests/test_mux.py +++ b/anuga/file/tests/test_mux.py @@ -1,6 +1,6 @@ -from builtins import zip -from builtins import map -from builtins import range +#from builtins import zip +#from builtins import map +#from builtins import range import unittest import tempfile import numpy as num @@ -88,7 +88,7 @@ def write_mux(self, lat_long_points, time_step_count, time_step, for i, q in enumerate(quantities): quantities_init[i] = ensure_numeric(quantities_init[i]) #print "HA_init", HA_init - q_time = num.zeros((time_step_count, points_num), num.float) + q_time = num.zeros((time_step_count, points_num), num.float64) for time in range(time_step_count): q_time[time,:] = quantities_init[i] #* time * 4 @@ -180,17 +180,17 @@ def write_mux2(self, lat_long_points, time_step_count, time_step, if ha is None: this_ha = e - quantities_init[0].append(num.ones(time_step_count,num.float)*this_ha) # HA + quantities_init[0].append(num.ones(time_step_count,float)*this_ha) # HA else: quantities_init[0].append(ha[i]) if ua is None: this_ua = n - quantities_init[1].append(num.ones(time_step_count,num.float)*this_ua) # UA + quantities_init[1].append(num.ones(time_step_count,float)*this_ua) # UA else: quantities_init[1].append(ua[i]) if va is None: this_va = e - quantities_init[2].append(num.ones(time_step_count,num.float)*this_va) # + quantities_init[2].append(num.ones(time_step_count,float)*this_va) # else: quantities_init[2].append(-va[i]) # South is negative in MUX @@ -200,7 +200,7 @@ def write_mux2(self, lat_long_points, time_step_count, time_step, files = [] for i, q in enumerate(quantities): - q_time = num.zeros((time_step_count, points_num), num.float) + q_time = num.zeros((time_step_count, points_num), float) quantities_init[i] = ensure_numeric(quantities_init[i]) for time in range(time_step_count): #print i, q, time, quantities_init[i][:,time] @@ -269,12 +269,12 @@ def test_urs2sts_read_mux2_pyI(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=time_step_count*num.ones(n,num.int) - depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + first_tstep=num.ones(n,int) + last_tstep=time_step_count*num.ones(n,int) + depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) #-ve added to take into account mux file format where south is positive. base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -284,7 +284,7 @@ def test_urs2sts_read_mux2_pyI(self): ua=ua, va=va) - weights=num.ones(1, num.float) + weights=num.ones(1, float) #ensure that files are indeed mux2 files times, latitudes, longitudes, elevation, stage, starttime = read_mux2_py([files[0]], weights) ua_times, ua_latitudes, ua_longitudes, ua_elevation, xvelocity,starttime_ua=read_mux2_py([files[1]], weights) @@ -324,17 +324,17 @@ def test_urs2sts_read_mux2_pyII(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) - depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) + depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count)+1 ha[1]=time_step_count-num.arange(1,time_step_count+1) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) #-ve added to take into account mux file format where south is positive. base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -344,7 +344,7 @@ def test_urs2sts_read_mux2_pyII(self): ua=ua, va=va) - weights=num.ones(1, num.float) + weights=num.ones(1, float) #ensure that files are indeed mux2 files times, latitudes, longitudes, elevation, stage,starttime=read_mux2_py([files[0]], weights) ua_times, ua_latitudes, ua_longitudes, ua_elevation, xvelocity,starttime_ua=read_mux2_py([files[1]], weights) @@ -382,20 +382,20 @@ def test_urs2sts_read_mux2_pyIII(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) #-ve added to take into account mux file format where south is positive. base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -405,7 +405,7 @@ def test_urs2sts_read_mux2_pyIII(self): ua=ua, va=va) - weights=num.ones(1, num.float) + weights=num.ones(1, float) #ensure that files are indeed mux2 files times, latitudes, longitudes, elevation, stage, starttime=read_mux2_py([files[0]], weights) ua_times, ua_latitudes, ua_longitudes, ua_elevation, xvelocity, starttime_ua=read_mux2_py([files[1]], weights) @@ -471,29 +471,29 @@ def test_read_mux_platform_problem1(self): n = len(lat_long_points) # Create different timeseries starting and ending at different times - first_tstep=num.ones(n, num.int) + first_tstep=num.ones(n, int) first_tstep[0]+=2 # Point 0 starts at 2 first_tstep[1]+=4 # Point 1 starts at 4 first_tstep[2]+=3 # Point 2 starts at 3 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 # Point 0 ends 1 step early last_tstep[1]-=2 # Point 1 ends 2 steps early last_tstep[4]-=3 # Point 4 ends 3 steps early # Create varying elevation data (positive values for seafloor) - gauge_depth=20*num.ones(n,num.float) + gauge_depth=20*num.ones(n,float) for i in range(n): gauge_depth[i] += i**2 # Create data to be written to first mux file - ha0=2*num.ones((n,time_step_count),num.float) + ha0=2*num.ones((n,time_step_count),float) ha0[0]=num.arange(0,time_step_count) ha0[1]=num.arange(time_step_count,2*time_step_count) ha0[2]=num.arange(2*time_step_count,3*time_step_count) ha0[3]=num.arange(3*time_step_count,4*time_step_count) - ua0=5*num.ones((n,time_step_count),num.float) - va0=-10*num.ones((n,time_step_count),num.float) + ua0=5*num.ones((n,time_step_count),float) + va0=-10*num.ones((n,time_step_count),float) # Ensure data used to write mux file to be zero when gauges are # not recording @@ -532,7 +532,7 @@ def test_read_mux_platform_problem1(self): # For each quantity read the associated list of source mux2 file with # extention associated with that quantity - file_params=-1*num.ones(3,num.float) #[nsta,dt,nt] + file_params=-1*num.ones(3,float) #[nsta,dt,nt] OFFSET = 5 for j, file in enumerate(filesI): @@ -578,36 +578,36 @@ def test_read_mux_platform_problem2(self): n = len(lat_long_points) # Create different timeseries starting and ending at different times - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=2 # Point 0 starts at 2 first_tstep[1]+=4 # Point 1 starts at 4 first_tstep[2]+=3 # Point 2 starts at 3 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 # Point 0 ends 1 step early last_tstep[1]-=2 # Point 1 ends 2 steps early last_tstep[4]-=3 # Point 4 ends 3 steps early # Create varying elevation data (positive values for seafloor) - gauge_depth=20*num.ones(n,num.float) + gauge_depth=20*num.ones(n,float) for i in range(n): gauge_depth[i] += i**2 # Create data to be written to second mux file - ha1=num.ones((n,time_step_count),num.float) + ha1=num.ones((n,time_step_count),float) ha1[0]=num.sin(times_ref) ha1[1]=2*num.sin(times_ref - 3) ha1[2]=5*num.sin(4*times_ref) ha1[3]=num.sin(times_ref) ha1[4]=num.sin(2*times_ref-0.7) - ua1=num.zeros((n,time_step_count),num.float) + ua1=num.zeros((n,time_step_count),float) ua1[0]=3*num.cos(times_ref) ua1[1]=2*num.sin(times_ref-0.7) ua1[2]=num.arange(3*time_step_count,4*time_step_count) ua1[4]=2*num.ones(time_step_count) - va1=num.zeros((n,time_step_count),num.float) + va1=num.zeros((n,time_step_count),float) va1[0]=2*num.cos(times_ref-0.87) va1[1]=3*num.ones(time_step_count) va1[3]=2*num.sin(times_ref-0.71) @@ -680,17 +680,17 @@ def test_read_mux_platform_problem2(self): if ha is None: this_ha = e - quantities_init[0].append(num.ones(time_step_count,num.float)*this_ha) # HA + quantities_init[0].append(num.ones(time_step_count,float)*this_ha) # HA else: quantities_init[0].append(ha[i]) if ua is None: this_ua = n - quantities_init[1].append(num.ones(time_step_count,num.float)*this_ua) # UA + quantities_init[1].append(num.ones(time_step_count,float)*this_ua) # UA else: quantities_init[1].append(ua[i]) if va is None: this_va = e - quantities_init[2].append(num.ones(time_step_count,num.float)*this_va) # + quantities_init[2].append(num.ones(time_step_count,float)*this_va) # else: quantities_init[2].append(va[i]) @@ -698,7 +698,7 @@ def test_read_mux_platform_problem2(self): #print #print i, q - q_time = num.zeros((time_step_count, points_num), num.float) + q_time = num.zeros((time_step_count, points_num), float) quantities_init[i] = ensure_numeric(quantities_init[i]) for time in range(time_step_count): #print i, q, time, quantities_init[i][:,time] @@ -775,7 +775,7 @@ def test_read_mux_platform_problem2(self): # For each quantity read the associated list of source mux2 file with # extention associated with that quantity - file_params=-1*num.ones(3,num.float) # [nsta,dt,nt] + file_params=-1*num.ones(3,float) # [nsta,dt,nt] OFFSET = 5 for j, file in enumerate(filesII): @@ -790,7 +790,7 @@ def test_read_mux_platform_problem2(self): # Index where data ends and parameters begin parameters_index = data.shape[1]-OFFSET - quantity=num.zeros((number_of_selected_stations, parameters_index), num.float) + quantity=num.zeros((number_of_selected_stations, parameters_index), float) for i in range(number_of_selected_stations): @@ -869,36 +869,36 @@ def test_read_mux_platform_problem3(self): stations = len(lat_long_points) # Create different timeseries starting and ending at different times - first_tstep=num.ones(stations, num.int) + first_tstep=num.ones(stations, int) first_tstep[0]+=2 # Point 0 starts at 2 first_tstep[1]+=4 # Point 1 starts at 4 first_tstep[2]+=3 # Point 2 starts at 3 - last_tstep=(time_step_count)*num.ones(stations, num.int) + last_tstep=(time_step_count)*num.ones(stations, int) last_tstep[0]-=1 # Point 0 ends 1 step early last_tstep[1]-=2 # Point 1 ends 2 steps early last_tstep[4]-=3 # Point 4 ends 3 steps early # Create varying elevation data (positive values for seafloor) - gauge_depth=20*num.ones(stations, num.float) + gauge_depth=20*num.ones(stations, float) for i in range(stations): gauge_depth[i] += i**2 # Create data to be written to second mux file - ha1=num.ones((stations,time_step_count), num.float) + ha1=num.ones((stations,time_step_count), float) ha1[0]=num.sin(times_ref) ha1[1]=2*num.sin(times_ref - 3) ha1[2]=5*num.sin(4*times_ref) ha1[3]=num.sin(times_ref) ha1[4]=num.sin(2*times_ref-0.7) - ua1=num.zeros((stations,time_step_count),num.float) + ua1=num.zeros((stations,time_step_count),float) ua1[0]=3*num.cos(times_ref) ua1[1]=2*num.sin(times_ref-0.7) ua1[2]=num.arange(3*time_step_count,4*time_step_count) ua1[4]=2*num.ones(time_step_count) - va1=num.zeros((stations,time_step_count),num.float) + va1=num.zeros((stations,time_step_count),float) va1[0]=2*num.cos(times_ref-0.87) va1[1]=3*num.ones(time_step_count) va1[3]=2*num.sin(times_ref-0.71) @@ -974,19 +974,19 @@ def test_read_mux_platform_problem3(self): if ha is None: this_ha = e quantities_init[0].append(num.ones(time_step_count, - num.float)*this_ha) # HA + float)*this_ha) # HA else: quantities_init[0].append(ha[i]) if ua is None: this_ua = n quantities_init[1].append(num.ones(time_step_count, - num.float)*this_ua) # UA + float)*this_ua) # UA else: quantities_init[1].append(ua[i]) if va is None: this_va = e quantities_init[2].append(num.ones(time_step_count, - num.float)*this_va) # + float)*this_va) # else: quantities_init[2].append(va[i]) @@ -994,7 +994,7 @@ def test_read_mux_platform_problem3(self): #print #print i, q - q_time = num.zeros((time_step_count, points_num), num.float) + q_time = num.zeros((time_step_count, points_num), float) quantities_init[i] = ensure_numeric(quantities_init[i]) for time in range(time_step_count): #print i, q, time, quantities_init[i][:,time] @@ -1073,7 +1073,7 @@ def test_read_mux_platform_problem3(self): # For each quantity read the associated list of source mux2 file with # extention associated with that quantity - file_params=-1*num.ones(3,num.float) # [nsta,dt,nt] + file_params=-1*num.ones(3,float) # [nsta,dt,nt] OFFSET = 5 for j, file in enumerate(filesII): @@ -1117,20 +1117,20 @@ def test_urs2sts_nonstandard_projection_reverse(self): time_step = 2 lat_long_points =[(-21.,113.5),(-21.,114.5),(-21.,114.), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -1183,20 +1183,20 @@ def test_urs2stsII(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) # Create two identical mux files to be combined by urs2sts base_nameI, filesI = self.write_mux2(lat_long_points, @@ -1285,7 +1285,7 @@ def test_urs2stsII(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth=num.zeros((len(lat_long_points),time_step_count),num.float) + depth=num.zeros((len(lat_long_points),time_step_count),float) for i in range(len(lat_long_points)): depth[i]=gauge_depth[i]+tide+2.0*ha[i] #2.0*ha necessary because using two files with weights=1 are used @@ -1322,20 +1322,20 @@ def test_urs2sts0(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -1408,7 +1408,7 @@ def test_urs2sts0(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth=num.zeros((len(lat_long_points),time_step_count),num.float) + depth=num.zeros((len(lat_long_points),time_step_count),float) for i in range(len(lat_long_points)): depth[i]=gauge_depth[i]+tide+ha[i] assert num.allclose(num.transpose(ua*depth),xmomentum) @@ -1437,20 +1437,20 @@ def test_urs2sts_nonstandard_meridian(self): time_step = 2 lat_long_points =[(-21.,114.5),(-21.,113.5),(-21.,114.), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, diff --git a/anuga/file/urs.py b/anuga/file/urs.py index 756fc08c5..3d59ff13b 100644 --- a/anuga/file/urs.py +++ b/anuga/file/urs.py @@ -69,7 +69,7 @@ def __init__(self, urs_file): raise Exception('Unknown python version: %' % system_tools.version) #print('lonlatdep', lonlatdep) - lonlatdep = num.array(lonlatdep, dtype=num.float) + lonlatdep = num.array(lonlatdep, dtype=float) lonlatdep = num.reshape(lonlatdep, (self.points_num, columns)) self.lonlatdep = lonlatdep @@ -117,7 +117,7 @@ def __next__(self): raise Exception('Unknown python version: %' % system_tools.version) - hz_p = num.array(hz_p_array, dtype=num.float) + hz_p = num.array(hz_p_array, dtype=float) self.iter_time_step += 1 return hz_p diff --git a/anuga/file/urs_ext.pyx b/anuga/file/urs_ext.pyx index fe52af93c..a1ee43926 100644 --- a/anuga/file/urs_ext.pyx +++ b/anuga/file/urs_ext.pyx @@ -30,7 +30,7 @@ def read_mux2(int numSrc,\ cdef np.ndarray[double, ndim=2, mode="c"] pydata cdef np.ndarray[long, ndim=1, mode="c"] tmp_perm - tmp_perm = np.array([0],np.int) + tmp_perm = np.array([0],int) assert len(filenames) > 0, "empty lists not allowed" @@ -107,7 +107,7 @@ def read_mux2(int numSrc,\ # Each gauge begins and ends recording at different times. When a gauge is # not recording but at least one other gauge is. # Pad the non recording gauge array with zeros. - pydata = np.zeros((dimensions[0],dimensions[1]),dtype=np.float) + pydata = np.zeros((dimensions[0],dimensions[1]),dtype=float) for i in xrange(number_of_selected_stations): time = 0 for it in xrange(finish_tstep): diff --git a/anuga/file_conversion/dem2dem.py b/anuga/file_conversion/dem2dem.py index cf972abac..859fba1e3 100644 --- a/anuga/file_conversion/dem2dem.py +++ b/anuga/file_conversion/dem2dem.py @@ -116,7 +116,7 @@ def dem2dem(name_in, stencil, cellsize_new, name_out=None, if verbose: log.critical('Processing row %d of %d' % (i, nrows_new)) lower_index = global_index - telev = num.zeros(ncols_new, num.float) + telev = num.zeros(ncols_new, float) local_index = 0 trow = i * cellsize_ratio diff --git a/anuga/file_conversion/dem2pts.py b/anuga/file_conversion/dem2pts.py index 2b1db1de1..f5604ca0f 100644 --- a/anuga/file_conversion/dem2pts.py +++ b/anuga/file_conversion/dem2pts.py @@ -238,8 +238,8 @@ def _dem2pts(name_in, name_out=None, verbose=False, # else: # newcols = lenv # ncols_in_bounding_box # -# telev = num.zeros(newcols, num.float) -# tpoints = num.zeros((newcols, 2), num.float) +# telev = num.zeros(newcols, float) +# tpoints = num.zeros((newcols, 2), float) # # local_index = 0 # @@ -284,10 +284,10 @@ def _dem2pts(name_in, name_out=None, verbose=False, #======================================== # Do the preceeding with numpy #======================================== - y = num.arange(nrows,dtype=num.float) + y = num.arange(nrows,dtype=float) y = yllcorner + (nrows-1)*cellsize - y*cellsize - x = num.arange(ncols,dtype=num.float) + x = num.arange(ncols,dtype=float) x = xllcorner + x*cellsize xx,yy = num.meshgrid(x,y) diff --git a/anuga/file_conversion/esri2sww.py b/anuga/file_conversion/esri2sww.py index 5ab7fa4a4..f1a246c01 100644 --- a/anuga/file_conversion/esri2sww.py +++ b/anuga/file_conversion/esri2sww.py @@ -166,8 +166,8 @@ def esri2sww(bath_dir, #Store from anuga.coordinate_transforms.redfearn import redfearn - x = num.zeros(number_of_points, num.float) #Easting - y = num.zeros(number_of_points, num.float) #Northing + x = num.zeros(number_of_points, float) #Easting + y = num.zeros(number_of_points, float) #Northing if verbose: log.critical('Making triangular grid') @@ -203,7 +203,7 @@ def esri2sww(bath_dir, volumes.append([v1,v3,v2]) #Upper element volumes.append([v4,v2,v3]) #Lower element - volumes = num.array(volumes, num.int) #array default# + volumes = num.array(volumes, int) #array default# geo_ref = Geo_reference(refzone, min(x), min(y)) geo_ref.write_NetCDF(outfile) diff --git a/anuga/file_conversion/ferret2sww.py b/anuga/file_conversion/ferret2sww.py index 37f6dc253..9c2afc58b 100644 --- a/anuga/file_conversion/ferret2sww.py +++ b/anuga/file_conversion/ferret2sww.py @@ -264,8 +264,8 @@ def ferret2sww(basename_in, name_out=None, # Store from anuga.coordinate_transforms.redfearn import redfearn - x = num.zeros(number_of_points, num.float) #Easting - y = num.zeros(number_of_points, num.float) #Northing + x = num.zeros(number_of_points, float) #Easting + y = num.zeros(number_of_points, float) #Northing if verbose: log.critical('Making triangular grid') @@ -300,7 +300,7 @@ def ferret2sww(basename_in, name_out=None, volumes.append([v1, v2, v3]) #Upper element volumes.append([v4, v3, v2]) #Lower element - volumes = num.array(volumes, num.int) #array default# + volumes = num.array(volumes, int) #array default# if origin is None: origin = Geo_reference(refzone, min(x), min(y)) diff --git a/anuga/file_conversion/file_conversion.py b/anuga/file_conversion/file_conversion.py index 572b22b56..70fd7afed 100644 --- a/anuga/file_conversion/file_conversion.py +++ b/anuga/file_conversion/file_conversion.py @@ -58,9 +58,9 @@ def sww2obj(filename, size): stage = fid.variables['stage'] M = size #Number of lines - xx = num.zeros((M,3), num.float) - yy = num.zeros((M,3), num.float) - zz = num.zeros((M,3), num.float) + xx = num.zeros((M,3), float) + yy = num.zeros((M,3), float) + zz = num.zeros((M,3), float) for i in range(M): for j in range(3): @@ -166,8 +166,8 @@ def timefile2netcdf(file_text, file_out = None, quantity_names=None, \ N = len(lines) d = len(q) - T = num.zeros(N, num.float) # Time - Q = num.zeros((N, d), num.float) # Values + T = num.zeros(N, float) # Time + Q = num.zeros((N, d), float) # Values for i, line in enumerate(lines): fields = line.split(',') diff --git a/anuga/file_conversion/llasc2pts.py b/anuga/file_conversion/llasc2pts.py index ded234682..2d0488f3a 100644 --- a/anuga/file_conversion/llasc2pts.py +++ b/anuga/file_conversion/llasc2pts.py @@ -94,10 +94,10 @@ def _convert_dem_from_llasc2pts(name_in, name_out = None, totalnopoints = nrows*ncols - y = num.arange(nrows,dtype=num.float) + y = num.arange(nrows,dtype=float) y = yllcorner + (nrows-1)*cellsize - y*cellsize - x = num.arange(ncols,dtype=num.float) + x = num.arange(ncols,dtype=float) x = xllcorner + x*cellsize #print(xllcorner) diff --git a/anuga/file_conversion/sts2sww_mesh.py b/anuga/file_conversion/sts2sww_mesh.py index 999e56cd3..99a2ac6e5 100644 --- a/anuga/file_conversion/sts2sww_mesh.py +++ b/anuga/file_conversion/sts2sww_mesh.py @@ -54,7 +54,7 @@ def sts2sww_mesh(basename_in, basename_out=None, infile.close() number_of_points = nrows*ncols - points_utm = num.zeros((number_of_points,2),num.float) + points_utm = num.zeros((number_of_points,2),float) points_utm[:,0]=x+x_origin points_utm[:,1]=y+y_origin @@ -138,7 +138,7 @@ def sts2sww_mesh(basename_in, basename_out=None, wind_speed=wind_speed[i,:], wind_angle=wind_angle[i,:], barometric_pressure=barometric_pressure[i,:], - sww_precision=num.float) + sww_precision=float) if verbose: sww.verbose_quantities(outfile) diff --git a/anuga/file_conversion/sww2array.py b/anuga/file_conversion/sww2array.py index fe8e84a1d..bd2d1b524 100644 --- a/anuga/file_conversion/sww2array.py +++ b/anuga/file_conversion/sww2array.py @@ -110,9 +110,9 @@ def sww2array(name_in, fid = NetCDFFile(name_in) #Get extent and reference - x = num.array(fid.variables['x'], num.float) - y = num.array(fid.variables['y'], num.float) - volumes = num.array(fid.variables['volumes'], num.int) + x = num.array(fid.variables['x'], float) + y = num.array(fid.variables['y'], float) + volumes = num.array(fid.variables['volumes'], int) if type(reduction) is not types.BuiltinFunctionType: times = fid.variables['time'][reduction] else: @@ -191,7 +191,7 @@ def sww2array(name_in, raise_(Exception, msg) # Create result array and start filling, block by block. - result = num.zeros(number_of_points, num.float) + result = num.zeros(number_of_points, float) if verbose: msg = 'Slicing sww file, num points: ' + str(number_of_points) @@ -217,7 +217,7 @@ def sww2array(name_in, res = apply_expression_to_dictionary(quantity, q_dict) # if len(res.shape) == 2: -# new_res = num.zeros(res.shape[1], num.float) +# new_res = num.zeros(res.shape[1], float) # for k in xrange(res.shape[1]): # if type(reduction) is not types.BuiltinFunctionType: # new_res[k] = res[k] @@ -237,7 +237,7 @@ def sww2array(name_in, res = apply_expression_to_dictionary(quantity, q_dict) if len(res.shape) == 2: - new_res = num.zeros(res.shape[1], num.float) + new_res = num.zeros(res.shape[1], float) for k in range(res.shape[1]): if type(reduction) is not types.BuiltinFunctionType: new_res[k] = res[reduction,k] @@ -297,11 +297,11 @@ def sww2array(name_in, y = y + yllcorner - newyllcorner - grid_values = num.zeros( (nrows*ncols, ), num.float) + grid_values = num.zeros( (nrows*ncols, ), float) #print '---',grid_values.shape num_tri = len(volumes) - norms = num.zeros(6*num_tri, num.float) + norms = num.zeros(6*num_tri, float) #Use fasr method to calc grid values from .calc_grid_values_ext import calc_grid_values diff --git a/anuga/file_conversion/sww2dem.py b/anuga/file_conversion/sww2dem.py index c9de6d636..9dc914b1c 100644 --- a/anuga/file_conversion/sww2dem.py +++ b/anuga/file_conversion/sww2dem.py @@ -140,9 +140,9 @@ def sww2dem(name_in, name_out, fid = NetCDFFile(name_in) #Get extent and reference - x = num.array(fid.variables['x'][:], num.float) - y = num.array(fid.variables['y'][:], num.float) - volumes = num.array(fid.variables['volumes'][:], num.int) + x = num.array(fid.variables['x'][:], float) + y = num.array(fid.variables['y'][:], float) + volumes = num.array(fid.variables['volumes'][:], int) if type(reduction) is not types.BuiltinFunctionType: times = fid.variables['time'][reduction] else: @@ -229,7 +229,7 @@ def sww2dem(name_in, name_out, # Create result array and start filling, block by block. - result = num.zeros(number_of_points, num.float) + result = num.zeros(number_of_points, float) if verbose: msg = 'Slicing sww file, num points: ' + str(number_of_points) @@ -253,7 +253,7 @@ def sww2dem(name_in, name_out, res = apply_expression_to_dictionary(quantity, q_dict) if len(res.shape) == 2: - new_res = num.zeros(res.shape[1], num.float) + new_res = num.zeros(res.shape[1], float) for k in range(res.shape[1]): if type(reduction) is not types.BuiltinFunctionType: new_res[k] = res[reduction,k] @@ -313,7 +313,7 @@ def sww2dem(name_in, name_out, y = y + yllcorner - newyllcorner - grid_values = num.zeros( (nrows*ncols, ), num.float) + grid_values = num.zeros( (nrows*ncols, ), float) #print '---',grid_values.shape #------------------------------------------------------- @@ -323,7 +323,7 @@ def sww2dem(name_in, name_out, def calc_grid_values(nrows, ncols, cellsize, NODATA_value, x,y, norms, volumes, result, grid_values): - grid_points = num.zeros ((ncols*nrows, 2), num.float) + grid_points = num.zeros ((ncols*nrows, 2), float) vertex_points = num.concatenate ((x[:,num.newaxis], y[:,num.newaxis]), axis=1) assert len(vertex_points.shape) == 2 @@ -362,7 +362,7 @@ def calc_grid_values(nrows, ncols, cellsize, NODATA_value, return num_tri = len(volumes) - norms = num.zeros(6*num_tri, num.float) + norms = num.zeros(6*num_tri, float) #print norms from .calc_grid_values_ext import calc_grid_values diff --git a/anuga/file_conversion/sww2dem_new.py b/anuga/file_conversion/sww2dem_new.py index c460251e9..55fd92970 100644 --- a/anuga/file_conversion/sww2dem_new.py +++ b/anuga/file_conversion/sww2dem_new.py @@ -140,9 +140,9 @@ def sww2dem(name_in, name_out, fid = NetCDFFile(name_in) #Get extent and reference - x = num.array(fid.variables['x'], num.float) - y = num.array(fid.variables['y'], num.float) - volumes = num.array(fid.variables['volumes'], num.int) + x = num.array(fid.variables['x'], float) + y = num.array(fid.variables['y'], float) + volumes = num.array(fid.variables['volumes'], int) if type(reduction) is not types.BuiltinFunctionType: times = fid.variables['time'][reduction] else: @@ -221,7 +221,7 @@ def sww2dem(name_in, name_out, raise_(Exception, msg) # Create result array and start filling, block by block. - result = num.zeros(number_of_points, num.float) + result = num.zeros(number_of_points, float) if verbose: msg = 'Slicing sww file, num points: ' + str(number_of_points) @@ -245,7 +245,7 @@ def sww2dem(name_in, name_out, res = apply_expression_to_dictionary(quantity, q_dict) if len(res.shape) == 2: - new_res = num.zeros(res.shape[1], num.float) + new_res = num.zeros(res.shape[1], float) for k in range(res.shape[1]): if type(reduction) is not types.BuiltinFunctionType: new_res[k] = res[reduction,k] @@ -310,7 +310,7 @@ def sww2dem(name_in, name_out, def calc_grid_values_old(vertex_points, volumes, result): - grid_points = num.zeros ((ncols*nrows, 2), num.float) + grid_points = num.zeros ((ncols*nrows, 2), float) for i in range(nrows): if out_ext == '.asc': @@ -351,7 +351,7 @@ def calc_grid_values_old(vertex_points, volumes, result): def calc_grid_values(vertex_points, volumes, result): - grid_points = num.zeros ((ncols*nrows, 2), num.float) + grid_points = num.zeros ((ncols*nrows, 2), float) for i in range(nrows): if out_ext == '.asc': @@ -367,7 +367,7 @@ def calc_grid_values(vertex_points, volumes, result): grid_points[k, 0] = xg grid_points[k, 1] = yg - grid_values = num.zeros(ncols*nrows, num.float) + grid_values = num.zeros(ncols*nrows, float) eval_grid(nrows, ncols, NODATA_value, grid_points, vertex_points.flatten(), volumes, result, grid_values); return grid_values.flatten() diff --git a/anuga/file_conversion/sww2pts.py b/anuga/file_conversion/sww2pts.py index 513fd92d6..11b801922 100644 --- a/anuga/file_conversion/sww2pts.py +++ b/anuga/file_conversion/sww2pts.py @@ -129,7 +129,7 @@ def sww2pts(name_in, name_out=None, # the temporal dimension if verbose: log.critical('Reducing quantity %s' % quantity) - q_reduced = num.zeros(number_of_points, num.float) + q_reduced = num.zeros(number_of_points, float) for k in range(number_of_points): q_reduced[k] = reduction(q[:,k]) q = q_reduced diff --git a/anuga/file_conversion/tests/test_dem2array.py b/anuga/file_conversion/tests/test_dem2array.py index c7bc3f22e..cab6f209c 100644 --- a/anuga/file_conversion/tests/test_dem2array.py +++ b/anuga/file_conversion/tests/test_dem2array.py @@ -65,7 +65,7 @@ def test_dem2array(self): #print 'sending pts', ref_points #print 'sending elev', ref_elevation - Z_ex = num.array(ref_elevation,num.float).reshape(12,11) + Z_ex = num.array(ref_elevation,float).reshape(12,11) Z_ex = num.fliplr(Z_ex.T) #Write prj file with metadata diff --git a/anuga/file_conversion/tests/test_dem2dem.py b/anuga/file_conversion/tests/test_dem2dem.py index 0aa773dc9..244071993 100644 --- a/anuga/file_conversion/tests/test_dem2dem.py +++ b/anuga/file_conversion/tests/test_dem2dem.py @@ -97,7 +97,7 @@ def test_decimate_dem(self): (228+229+230+246+247+248+264+265+266) / 9.0] # generate a stencil for computing the decimated values - stencil = num.ones((3,3), num.float) / 9.0 + stencil = num.ones((3,3), float) / 9.0 dem2dem(filename, stencil=stencil, cellsize_new=100) @@ -192,7 +192,7 @@ def test_decimate_dem_NODATA(self): (228+229+230+246+247+248+264+265+266) / 9.0] # Generate a stencil for computing the decimated values - stencil = num.ones((3,3), num.float) / 9.0 + stencil = num.ones((3,3), float) / 9.0 dem2dem(filename, stencil=stencil, cellsize_new=100) diff --git a/anuga/file_conversion/tests/test_dem2pts.py b/anuga/file_conversion/tests/test_dem2pts.py index ed72b14f5..2dfa298e9 100755 --- a/anuga/file_conversion/tests/test_dem2pts.py +++ b/anuga/file_conversion/tests/test_dem2pts.py @@ -166,7 +166,7 @@ def test_dem2pts_bounding_box_removeNullvalues_v2(self): yvec = list(range(10)) xvec = list(range(10)) #z = range(100) - z = num.zeros(100, num.int) #array default# + z = num.zeros(100, int) #array default# NODATA_value = -9999 count = -1 for i in range(10): @@ -223,7 +223,7 @@ def test_dem2pts_bounding_box_removeNullvalues_v2(self): assert fid.yllcorner == 3003.0 #create new reference points - newz = num.zeros(19, num.int) #array default# + newz = num.zeros(19, int) #array default# newz[0:2] = ref_elevation[32:34] newz[2:5] = ref_elevation[35:38] newz[5:7] = ref_elevation[42:44] @@ -301,7 +301,7 @@ def test_dem2pts_bounding_box_removeNullvalues_v3(self): yvec = list(range(10)) xvec = list(range(10)) #z = range(100) - z = num.zeros(100, num.int) #array default# + z = num.zeros(100, int) #array default# NODATA_value = -9999 count = -1 for i in range(10): @@ -358,7 +358,7 @@ def test_dem2pts_bounding_box_removeNullvalues_v3(self): assert fid.yllcorner == 3003.0 #create new reference points - newz = num.zeros(14, num.int) #array default# + newz = num.zeros(14, int) #array default# newz[0:2] = ref_elevation[32:34] newz[2:5] = ref_elevation[35:38] newz[5:7] = ref_elevation[42:44] diff --git a/anuga/file_conversion/tests/test_file_conversion.py b/anuga/file_conversion/tests/test_file_conversion.py index 964d51de5..c2712c441 100644 --- a/anuga/file_conversion/tests/test_file_conversion.py +++ b/anuga/file_conversion/tests/test_file_conversion.py @@ -120,7 +120,7 @@ def setUp(self): ###################### #Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): diff --git a/anuga/file_conversion/tests/test_sww2dem.py b/anuga/file_conversion/tests/test_sww2dem.py index 40f23eeb2..0b80d51cf 100644 --- a/anuga/file_conversion/tests/test_sww2dem.py +++ b/anuga/file_conversion/tests/test_sww2dem.py @@ -73,7 +73,7 @@ def setUp(self): ###################### # Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): @@ -1379,7 +1379,7 @@ def test_sww2dem_asc_missing_points(self): # Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): diff --git a/anuga/file_conversion/tests/test_urs2sts.py b/anuga/file_conversion/tests/test_urs2sts.py index b770aba08..5942865eb 100644 --- a/anuga/file_conversion/tests/test_urs2sts.py +++ b/anuga/file_conversion/tests/test_urs2sts.py @@ -62,20 +62,20 @@ def test_urs2sts0(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -148,7 +148,7 @@ def test_urs2sts0(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth=num.zeros((len(lat_long_points),time_step_count),num.float) + depth=num.zeros((len(lat_long_points),time_step_count),float) for i in range(len(lat_long_points)): depth[i]=gauge_depth[i]+tide+ha[i] assert num.allclose(num.transpose(ua*depth),xmomentum) @@ -177,20 +177,20 @@ def test_urs2sts_nonstandard_meridian(self): time_step = 2 lat_long_points =[(-21.,114.5),(-21.,113.5),(-21.,114.), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -578,20 +578,20 @@ def test_urs2sts_ordering(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) # Create two identical mux files to be combined by urs2sts base_nameI, filesI = self.write_mux2(lat_long_points, @@ -722,7 +722,7 @@ def test_urs2sts_ordering(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth=num.zeros((len(lat_long_points),time_step_count),num.float) + depth=num.zeros((len(lat_long_points),time_step_count),float) for i in range(len(lat_long_points)): depth[i]=gauge_depth[i]+tide+2.0*ha[i] #2.0*ha necessary because using two files with weights=1 are used @@ -765,20 +765,20 @@ def Xtest_urs2sts_ordering_exception(self): time_step = 2 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=1 first_tstep[2]+=1 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) ha[0]=num.arange(0,time_step_count) ha[1]=num.arange(time_step_count,2*time_step_count) ha[2]=num.arange(2*time_step_count,3*time_step_count) ha[3]=num.arange(3*time_step_count,4*time_step_count) - ua=5*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + ua=5*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) # Create two identical mux files to be combined by urs2sts base_nameI, filesI = self.write_mux2(lat_long_points, @@ -864,12 +864,12 @@ def test_urs2sts_ordering_different_sources(self): # Create different timeseries starting and ending at different times - first_tstep=num.ones(n,num.int) + first_tstep=num.ones(n,int) first_tstep[0]+=2 # Point 0 starts at 2 first_tstep[1]+=4 # Point 1 starts at 4 first_tstep[2]+=3 # Point 2 starts at 3 - last_tstep=(time_step_count)*num.ones(n,num.int) + last_tstep=(time_step_count)*num.ones(n,int) last_tstep[0]-=1 # Point 0 ends 1 step early last_tstep[1]-=2 # Point 1 ends 2 steps early last_tstep[4]-=3 # Point 4 ends 3 steps early @@ -882,20 +882,20 @@ def test_urs2sts_ordering_different_sources(self): # Create varying elevation data (positive values for seafloor) - gauge_depth=20*num.ones(n,num.float) + gauge_depth=20*num.ones(n,float) for i in range(n): gauge_depth[i] += i**2 #print 'gauge_depth', gauge_depth # Create data to be written to first mux file - ha0=2*num.ones((n,time_step_count),num.float) + ha0=2*num.ones((n,time_step_count),float) ha0[0]=num.arange(0,time_step_count) ha0[1]=num.arange(time_step_count,2*time_step_count) ha0[2]=num.arange(2*time_step_count,3*time_step_count) ha0[3]=num.arange(3*time_step_count,4*time_step_count) - ua0=5*num.ones((n,time_step_count),num.float) - va0=-10*num.ones((n,time_step_count),num.float) + ua0=5*num.ones((n,time_step_count),float) + va0=-10*num.ones((n,time_step_count),float) # Ensure data used to write mux file to be zero when gauges are # not recording @@ -926,22 +926,22 @@ def test_urs2sts_ordering_different_sources(self): # Create data to be written to second mux file - ha1=num.ones((n,time_step_count),num.float) + ha1=num.ones((n,time_step_count),float) ha1[0]=num.sin(times_ref) ha1[1]=2*num.sin(times_ref - 3) ha1[2]=5*num.sin(4*times_ref) ha1[3]=num.sin(times_ref) ha1[4]=num.sin(2*times_ref-0.7) - ua1=num.zeros((n,time_step_count),num.float) + ua1=num.zeros((n,time_step_count),float) ua1[0]=3*num.cos(times_ref) ua1[1]=2*num.sin(times_ref-0.7) ua1[2]=num.arange(3*time_step_count,4*time_step_count) ua1[4]=2*num.ones(time_step_count) - va1=num.zeros((n,time_step_count),num.float) + va1=num.zeros((n,time_step_count),float) va1[0]=2*num.cos(times_ref-0.87) - va1[1]=3*num.ones(time_step_count, num.int) #array default# + va1[1]=3*num.ones(time_step_count, int) #array default# va1[3]=2*num.sin(times_ref-0.71) @@ -1068,7 +1068,7 @@ def test_urs2sts_ordering_different_sources(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth_ref = num.zeros((len(permutation), time_step_count), num.float) + depth_ref = num.zeros((len(permutation), time_step_count), float) for i in range(len(permutation)): depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] @@ -1181,7 +1181,7 @@ def test_urs2sts_ordering_different_sources(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth_ref = num.zeros((len(permutation), time_step_count), num.float) + depth_ref = num.zeros((len(permutation), time_step_count), float) for i in range(len(permutation)): depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] @@ -1288,7 +1288,7 @@ def test_urs2sts_ordering_different_sources(self): # elevation = - depth #momentum = velocity_ua *(stage+depth) - depth_ref = num.zeros((len(permutation), time_step_count), num.float) + depth_ref = num.zeros((len(permutation), time_step_count), float) for i in range(len(permutation)): depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] @@ -1341,17 +1341,17 @@ def test_file_boundary_stsI(self): time_step = 2 lat_long_points =bounding_polygon[0:3] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) h = 20 w = 2 u = 10 v = -10 - gauge_depth=h*num.ones(n,num.float) - ha=w*num.ones((n,time_step_count),num.float) - ua=u*num.ones((n,time_step_count),num.float) - va=v*num.ones((n,time_step_count),num.float) + gauge_depth=h*num.ones(n,float) + ha=w*num.ones((n,time_step_count),float) + ua=u*num.ones((n,time_step_count),float) + va=v*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, first_tstep, last_tstep, @@ -1404,7 +1404,7 @@ def test_file_boundary_stsI(self): # Evolve finaltime=time_step*(time_step_count-1) yieldstep=time_step - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1431,7 +1431,7 @@ def test_file_boundary_stsI(self): Br = Reflective_boundary(domain_drchlt) domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) - temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1477,17 +1477,17 @@ def test_file_boundary_stsI_beyond_model_time(self): time_step = 2 lat_long_points = bounding_polygon[0:3] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) h = 20 w = 2 u = 10 v = -10 - gauge_depth=h*num.ones(n,num.float) - ha=w*num.ones((n,time_step_count),num.float) - ua=u*num.ones((n,time_step_count),num.float) - va=v*num.ones((n,time_step_count),num.float) + gauge_depth=h*num.ones(n,float) + ha=w*num.ones((n,time_step_count),float) + ua=u*num.ones((n,time_step_count),float) + va=v*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, first_tstep, last_tstep, @@ -1549,7 +1549,7 @@ def test_file_boundary_stsI_beyond_model_time(self): data_finaltime = time_step*(time_step_count-1) finaltime = data_finaltime + 10 # Let model time exceed available data yieldstep = time_step - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1, num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1, float) for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1575,7 +1575,7 @@ def test_file_boundary_stsI_beyond_model_time(self): Br = Reflective_boundary(domain_drchlt) domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) - temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1619,17 +1619,17 @@ def test_field_boundary_stsI_beyond_model_time(self): time_step = 2 lat_long_points = bounding_polygon[0:3] n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) h = 20 w = 2 u = 10 v = -10 - gauge_depth=h*num.ones(n,num.float) - ha=w*num.ones((n,time_step_count),num.float) - ua=u*num.ones((n,time_step_count),num.float) - va=v*num.ones((n,time_step_count),num.float) + gauge_depth=h*num.ones(n,float) + ha=w*num.ones((n,time_step_count),float) + ua=u*num.ones((n,time_step_count),float) + va=v*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, first_tstep, last_tstep, @@ -1694,7 +1694,7 @@ def test_field_boundary_stsI_beyond_model_time(self): data_finaltime = time_step*(time_step_count-1) finaltime = data_finaltime + 10 # Let model time exceed available data yieldstep = time_step - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1, num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1, float) for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1732,12 +1732,12 @@ def test_file_boundary_stsII(self): lat_long_points.insert(0,bounding_polygon[len(bounding_polygon)-1]) lat_long_points.insert(0,[6.0,97.01]) n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) - ua=10*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) + ua=10*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -1779,7 +1779,7 @@ def test_file_boundary_stsII(self): domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br}) finaltime=time_step*(time_step_count-1) yieldstep=time_step - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1791,7 +1791,7 @@ def test_file_boundary_stsII(self): Br = Reflective_boundary(domain_drchlt) Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) - temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1833,12 +1833,12 @@ def test_file_boundary_stsIII_ordering(self): time_step_count = 50 time_step = 2 n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) - ua=10*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) + ua=10*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) base_name, files = self.write_mux2(lat_long_points, time_step_count, time_step, @@ -1927,7 +1927,7 @@ def test_file_boundary_stsIII_ordering(self): domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br}) finaltime=time_step*(time_step_count-1) yieldstep=time_step - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1941,7 +1941,7 @@ def test_file_boundary_stsIII_ordering(self): Br = Reflective_boundary(domain_drchlt) Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) - temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -1994,14 +1994,14 @@ def test_file_boundary_sts_time_limit(self): times_ref = num.arange(0, time_step_count*time_step, time_step) n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) - gauge_depth=20*num.ones(n,num.float) + gauge_depth=20*num.ones(n,float) - ha1=num.ones((n,time_step_count),num.float) - ua1=3.*num.ones((n,time_step_count),num.float) - va1=2.*num.ones((n,time_step_count),num.float) + ha1=num.ones((n,time_step_count),float) + ua1=3.*num.ones((n,time_step_count),float) + va1=2.*num.ones((n,time_step_count),float) for i in range(n): ha1[i]=num.sin(times_ref) diff --git a/anuga/file_conversion/urs2nc.py b/anuga/file_conversion/urs2nc.py index 0d5c676e1..b22f2ac1a 100644 --- a/anuga/file_conversion/urs2nc.py +++ b/anuga/file_conversion/urs2nc.py @@ -98,7 +98,7 @@ def _binary_c2nc(file_in, file_out, quantity): lonlatdep = p_array.array('f') lonlatdep.read(mux_file, columns * points_num) - lonlatdep = num.array(lonlatdep, dtype=num.float) + lonlatdep = num.array(lonlatdep, dtype=float) lonlatdep = num.reshape(lonlatdep, (points_num, columns)) lon, lat, depth = lon_lat2grid(lonlatdep) @@ -123,7 +123,7 @@ def _binary_c2nc(file_in, file_out, quantity): #Read in a time slice from mux file hz_p_array = p_array.array('f') hz_p_array.read(mux_file, points_num) - hz_p = num.array(hz_p_array, dtype=num.float) + hz_p = num.array(hz_p_array, dtype=float) hz_p = num.reshape(hz_p, (len(lon), len(lat))) hz_p = num.transpose(hz_p) # mux has lat varying fastest, nc has long v.f. @@ -152,7 +152,7 @@ def lon_lat2grid(long_lat_dep): LAT = 1 QUANTITY = 2 - long_lat_dep = ensure_numeric(long_lat_dep, num.float) + long_lat_dep = ensure_numeric(long_lat_dep, float) num_points = long_lat_dep.shape[0] this_rows_long = long_lat_dep[0,LONG] @@ -190,7 +190,7 @@ def lon_lat2grid(long_lat_dep): # long being the fastest varying dimension # FIXME - make this faster/do this a better way # use numeric transpose, after reshaping the quantity vector - quantity = num.zeros(num_points, num.float) + quantity = num.zeros(num_points, float) for lat_i, _ in enumerate(lat): for long_i, _ in enumerate(long): diff --git a/anuga/file_conversion/urs2sts.py b/anuga/file_conversion/urs2sts.py index d3b3df27a..442c710bf 100644 --- a/anuga/file_conversion/urs2sts.py +++ b/anuga/file_conversion/urs2sts.py @@ -98,7 +98,7 @@ def urs2sts(basename_in, basename_out=None, # A weight must be specified for each source if weights is None: # Default is equal weighting - weights = old_div(num.ones(numSrc, num.float), numSrc) + weights = old_div(num.ones(numSrc, float), numSrc) else: weights = ensure_numeric(weights) msg = 'When combining multiple sources must specify a weight for ' \ @@ -227,7 +227,7 @@ def urs2sts(basename_in, basename_out=None, # are assigned the trivial indices enumerating them from # 0 to number_of_points-1 if permutation is None: - permutation = num.arange(number_of_points, dtype=num.int) + permutation = num.arange(number_of_points, dtype=int) # NetCDF file definition outfile = NetCDFFile(stsname, netcdf_mode_w) @@ -246,8 +246,8 @@ def urs2sts(basename_in, basename_out=None, # Store from anuga.coordinate_transforms.redfearn import redfearn - x = num.zeros(number_of_points, num.float) # Easting - y = num.zeros(number_of_points, num.float) # Northing + x = num.zeros(number_of_points, float) # Easting + y = num.zeros(number_of_points, float) # Northing # Check zone boundaries if zone is None: diff --git a/anuga/file_conversion/urs2sww.py b/anuga/file_conversion/urs2sww.py index d62bd4ac2..cada16cc6 100644 --- a/anuga/file_conversion/urs2sww.py +++ b/anuga/file_conversion/urs2sww.py @@ -208,7 +208,7 @@ def urs_ungridded2sww(basename_in='o', basename_out=None, verbose=False, stage=stage, xmomentum=xmomentum, ymomentum=ymomentum, - sww_precision=num.float) + sww_precision=float) j += 1 if verbose: sww.verbose_quantities(outfile) diff --git a/anuga/fit_interpolate/fit.py b/anuga/fit_interpolate/fit.py index ae080bf84..55e1a374b 100644 --- a/anuga/fit_interpolate/fit.py +++ b/anuga/fit_interpolate/fit.py @@ -240,13 +240,13 @@ def _build_matrix_AtA_Atz(self, point_coordinates, z=None, attribute_name=None, # Convert input to numeric arrays if z is not None: - z = ensure_numeric(z, num.float) + z = ensure_numeric(z, float) else: msg = 'z not specified' assert isinstance(point_coordinates, Geospatial_data), msg z = point_coordinates.get_attributes(attribute_name) - point_coordinates = ensure_numeric(point_coordinates, num.float) + point_coordinates = ensure_numeric(point_coordinates, float) npts = len(z) z = num.array(z) @@ -489,7 +489,7 @@ def _fit_to_mesh(point_coordinates, # are None # Convert input to numeric arrays - triangles = ensure_numeric(triangles, num.int) + triangles = ensure_numeric(triangles, int) vertex_coordinates = ensure_absolute(vertex_coordinates, geo_reference=mesh_origin) diff --git a/anuga/fit_interpolate/general_fit_interpolate.py b/anuga/fit_interpolate/general_fit_interpolate.py index a738b7ed7..6c935ac73 100644 --- a/anuga/fit_interpolate/general_fit_interpolate.py +++ b/anuga/fit_interpolate/general_fit_interpolate.py @@ -94,7 +94,7 @@ def __init__(self, # are None # Convert input to numeric arrays - triangles = ensure_numeric(triangles, num.int) + triangles = ensure_numeric(triangles, int) vertex_coordinates = ensure_absolute(vertex_coordinates, geo_reference=mesh_origin) diff --git a/anuga/fit_interpolate/interpolate.py b/anuga/fit_interpolate/interpolate.py index f159f08eb..26238997f 100644 --- a/anuga/fit_interpolate/interpolate.py +++ b/anuga/fit_interpolate/interpolate.py @@ -124,7 +124,7 @@ def interpolate(vertex_coordinates, from anuga.caching import cache # Create interpolation object with matrix - args = (ensure_numeric(vertex_coordinates, num.float), + args = (ensure_numeric(vertex_coordinates, float), ensure_numeric(triangles)) kwargs = {'mesh_origin': mesh_origin, 'verbose': verbose} @@ -264,11 +264,11 @@ def interpolate(self, start = 0 # creating a dummy array to concatenate to. - f = ensure_numeric(f, num.float) + f = ensure_numeric(f, float) if len(f.shape) > 1: - z = num.zeros((0, f.shape[1]), num.int) #array default# + z = num.zeros((0, f.shape[1]), int) #array default# else: - z = num.zeros((0,), num.int) #array default# + z = num.zeros((0,), int) #array default# for end in range(start_blocking_len, len(point_coordinates), @@ -304,8 +304,8 @@ def interpolate_block(self, f, point_coordinates, NODATA_value=NAN, point_coordinates = point_coordinates.get_data_points(absolute=True) # Convert lists to numeric arrays if necessary - point_coordinates = ensure_numeric(point_coordinates, num.float) - f = ensure_numeric(f, num.float) + point_coordinates = ensure_numeric(point_coordinates, float) + f = ensure_numeric(f, float) from anuga.caching import myhash import sys @@ -412,7 +412,7 @@ def _build_interpolation_matrix_A(self, if verbose: log.critical('Building interpolation matrix') # Convert point_coordinates to numeric arrays, in case it was a list. - point_coordinates = ensure_numeric(point_coordinates, num.float) + point_coordinates = ensure_numeric(point_coordinates, float) if verbose: log.critical('Getting indices inside mesh boundary') @@ -708,7 +708,7 @@ def interpolate_sww2csv(sww_file, class Interpolation_function(object): - """Interpolation_interface - creates callable object f(t, id) or f(t,x,y) + """Interpolation_interface - creates callable object f(t, id) or f(t, x, y) which is interpolated from time series defined at vertices of triangular mesh (such as those stored in sww files) @@ -927,7 +927,7 @@ def __init__(self, p = len(self.time) for name in quantity_names: - self.precomputed_values[name] = num.zeros((p, m), num.float) + self.precomputed_values[name] = num.zeros((p, m), float) if verbose is True: log.critical('Build interpolator') @@ -1062,7 +1062,7 @@ def __call__(self, t, point_id=None, x=None, y=None): ratio = (t - self.time[self.index]) / (self.time[self.index+1] - self.time[self.index]) # Compute interpolated values - q = num.zeros(len(self.quantity_names), num.float) + q = num.zeros(len(self.quantity_names), float) for i, name in enumerate(self.quantity_names): Q = self.precomputed_values[name] @@ -1111,7 +1111,7 @@ def __call__(self, t, point_id=None, x=None, y=None): assert len(y) == N, 'x and y must have same length' res = [] for col in q: - res.append(col*num.ones(N, num.float)) + res.append(col*num.ones(N, float)) return res diff --git a/anuga/fit_interpolate/tests/test_interpolate.py b/anuga/fit_interpolate/tests/test_interpolate.py index b1e23986a..d3b178709 100644 --- a/anuga/fit_interpolate/tests/test_interpolate.py +++ b/anuga/fit_interpolate/tests/test_interpolate.py @@ -80,7 +80,7 @@ def setUp(self): #Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): @@ -1131,7 +1131,7 @@ def test_interpolation_interface_time_only(self): #One quantity - Q = num.zeros( (3,6), num.float ) + Q = num.zeros( (3,6), float ) #Linear in time and space a = [0.0, 0.0] @@ -1278,7 +1278,7 @@ def test_interpolation_interface(self): [ 2.8, 1.2]] #One quantity - Q = num.zeros( (3,6), num.float ) + Q = num.zeros( (3,6), float ) #Linear in time and space for i, t in enumerate(time): @@ -1338,7 +1338,7 @@ def test_interpolation_interface_with_time_thinning(self): [ 2.8, 1.2]] # One quantity - Q = num.zeros((8,6), num.float) + Q = num.zeros((8,6), float) # Linear in time and space for i, t in enumerate(time): @@ -1406,7 +1406,7 @@ def test_interpolation_precompute_points(self): interpolation_points = [[ 1., 0.], [0.,1.]] #One quantity - Q = num.zeros( (2,6), num.float ) + Q = num.zeros( (2,6), float ) #Linear in time and space for i, t in enumerate(time): @@ -1472,7 +1472,7 @@ def test_interpolation_function_outside_point(self): [ 545354534, 4354354353]] # outside the mesh # One quantity - Q = num.zeros( (3,6), num.float ) + Q = num.zeros( (3,6), float ) # Linear in time and space for i, t in enumerate(time): @@ -1661,7 +1661,7 @@ def test_interpolation_function_time(self): [ 545354534, 4354354353]] # outside the mesh #One quantity - Q = num.zeros( (len(time),6), num.float ) + Q = num.zeros( (len(time),6), float ) #Linear in time and space for i, t in enumerate(time): diff --git a/anuga/geometry/polygon.py b/anuga/geometry/polygon.py index 1adbc54a4..bf8884f01 100644 --- a/anuga/geometry/polygon.py +++ b/anuga/geometry/polygon.py @@ -137,8 +137,8 @@ def intersection(line0, line1, rtol=1.0e-5, atol=1.0e-8): # FIXME (Ole): Write this in C - line0 = ensure_numeric(line0, num.float) - line1 = ensure_numeric(line1, num.float) + line0 = ensure_numeric(line0, float) + line1 = ensure_numeric(line1, float) x0 = line0[0, 0] y0 = line0[0, 1] @@ -212,8 +212,8 @@ def NEW_C_intersection(line0, line1): status == 4: Lines are parallel. Value set to None. """ - line0 = ensure_numeric(line0, num.float) - line1 = ensure_numeric(line1, num.float) + line0 = ensure_numeric(line0, float) + line1 = ensure_numeric(line1, float) status, value = _intersection(line0[0, 0], line0[0, 1], line0[1, 0], line0[1, 1], @@ -232,7 +232,7 @@ def polygon_overlap(triangles, polygon, verbose=False): M = old_div(triangles.shape[0], 3) # Number of triangles - indices = num.zeros(M, num.int) + indices = num.zeros(M, int) count = _polygon_overlap(polygon, triangles, indices) @@ -252,7 +252,7 @@ def not_polygon_overlap(triangles, polygon, verbose=False): M = old_div(triangles.shape[0], 3) # Number of triangles - indices = num.zeros(M, num.int) + indices = num.zeros(M, int) count = _polygon_overlap(polygon, triangles, indices) @@ -272,7 +272,7 @@ def line_intersect(triangles, line, verbose=False): M = old_div(triangles.shape[0], 3) # Number of triangles - indices = num.zeros(M, num.int) + indices = num.zeros(M, int) count = _line_intersect(line, triangles, indices) @@ -301,7 +301,7 @@ def not_line_intersect(triangles, line, verbose=False): M = old_div(triangles.shape[0], 3) # Number of triangles - indices = num.zeros(M, num.int) + indices = num.zeros(M, int) count = _line_intersect(line, triangles, indices) @@ -358,7 +358,7 @@ def is_inside_triangle(point, triangle, """ triangle = ensure_numeric(triangle) - point = ensure_numeric(point, num.float) + point = ensure_numeric(point, float) if check_inputs is True: msg = 'is_inside_triangle must be invoked with one point only' @@ -391,7 +391,7 @@ def segments_joined(seg0, seg1): return True return False - polygon = ensure_numeric(polygon, num.float) + polygon = ensure_numeric(polygon, float) # build a list of discrete segments from the polygon unsorted_segs = [] @@ -521,7 +521,7 @@ def outside_polygon(points, polygon, closed=True, verbose=False): """ try: - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) except NameError as e: raise_(NameError, e) except: @@ -529,7 +529,7 @@ def outside_polygon(points, polygon, closed=True, verbose=False): raise_(Exception, msg) try: - polygon = ensure_numeric(polygon, num.float) + polygon = ensure_numeric(polygon, float) except NameError as e: raise_(NameError, e) except: @@ -561,7 +561,7 @@ def in_and_outside_polygon(points, polygon, closed=True, verbose=False): """ try: - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) except NameError as e: raise_(NameError, e) except: @@ -569,7 +569,7 @@ def in_and_outside_polygon(points, polygon, closed=True, verbose=False): raise_(Exception, msg) try: - polygon = ensure_numeric(polygon, num.float) + polygon = ensure_numeric(polygon, float) except NameError as e: raise_(NameError, e) except: @@ -645,7 +645,7 @@ def separate_points_by_polygon(points, polygon, 'Keyword argument "verbose" must be boolean' try: - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) except NameError as e: raise_(NameError, e) except: @@ -653,7 +653,7 @@ def separate_points_by_polygon(points, polygon, raise Exception(msg) try: - polygon = ensure_numeric(polygon, num.float) + polygon = ensure_numeric(polygon, float) except NameError as e: raise NameError(e) except: @@ -688,7 +688,7 @@ def separate_points_by_polygon(points, polygon, N = polygon.shape[0] # Number of vertices in polygon M = points.shape[0] # Number of points - indices = num.zeros(M, num.int) + indices = num.zeros(M, int) count = _separate_points_by_polygon(points, polygon, indices, int(closed), int(verbose)) @@ -833,7 +833,7 @@ def _poly_xy(polygon): """ try: - polygon = ensure_numeric(polygon, num.float) + polygon = ensure_numeric(polygon, float) except NameError as err: raise_(NameError, err) except: @@ -1100,12 +1100,12 @@ def interpolate_polyline(data, interpolation_points = interpolation_points.\ get_data_points(absolute=True) - interpolated_values = num.zeros(len(interpolation_points), num.float) + interpolated_values = num.zeros(len(interpolation_points), float) - data = ensure_numeric(data, num.float) - polyline_nodes = ensure_numeric(polyline_nodes, num.float) - interpolation_points = ensure_numeric(interpolation_points, num.float) - gauge_neighbour_id = ensure_numeric(gauge_neighbour_id, num.int) + data = ensure_numeric(data, float) + polyline_nodes = ensure_numeric(polyline_nodes, float) + interpolation_points = ensure_numeric(interpolation_points, float) + gauge_neighbour_id = ensure_numeric(gauge_neighbour_id, int) num_nodes = polyline_nodes.shape[0] # Number of nodes in polyline diff --git a/anuga/geometry/polygon_function.py b/anuga/geometry/polygon_function.py index 4ee264b43..a8ff8149f 100644 --- a/anuga/geometry/polygon_function.py +++ b/anuga/geometry/polygon_function.py @@ -99,8 +99,8 @@ def __call__(self, pts_x, pts_y): x List of x coordinates of points ot interest. y List of y coordinates of points ot interest. """ - pts_x = num.array(pts_x, num.float) - pts_y = num.array(pts_y, num.float) + pts_x = num.array(pts_x, float) + pts_y = num.array(pts_y, float) # x and y must be one-dimensional and same length assert len(pts_x.shape) == 1 and len(pts_y.shape) == 1 @@ -114,7 +114,7 @@ def __call__(self, pts_x, pts_y): if callable(self.default): result = self.default(pts_x, pts_y) else: - result = num.ones(pts_len, num.float) * self.default + result = num.ones(pts_len, float) * self.default for polygon, value in self.regions: indices = inside_polygon(points, polygon) diff --git a/anuga/geospatial_data/geospatial_data.py b/anuga/geospatial_data/geospatial_data.py index 906f9f9e2..d07354658 100644 --- a/anuga/geospatial_data/geospatial_data.py +++ b/anuga/geospatial_data/geospatial_data.py @@ -629,7 +629,7 @@ def split(self, factor=0.5, seed_num=None, verbose=False): log.critical("make unique random number list " "and get indices") - total = num.array(list(range(self_size)), num.int) # array default# + total = num.array(list(range(self_size)), int) # array default# total_list = total.tolist() if verbose: @@ -1046,9 +1046,9 @@ def _read_csv_file_blocking(file_pointer, if points == []: raise StopIteration - pointlist = num.array(points, num.float) + pointlist = num.array(points, float) for key in list(att_dict.keys()): - att_dict[key] = num.array(att_dict[key], num.float) + att_dict[key] = num.array(att_dict[key], float) # Do stuff here so the info is in lat's and longs geo_ref = None @@ -1223,11 +1223,11 @@ def _write_urs_file(file_name, points, delimiter=' '): def _point_atts2array(point_atts): - point_atts['pointlist'] = num.array(point_atts['pointlist'], num.float) + point_atts['pointlist'] = num.array(point_atts['pointlist'], float) for key in list(point_atts['attributelist'].keys()): point_atts['attributelist'][key] = \ - num.array(point_atts['attributelist'][key], num.float) + num.array(point_atts['attributelist'][key], float) return point_atts @@ -1294,7 +1294,7 @@ def ensure_absolute(points, geo_reference=None): msg = 'Use a Geospatial_data object or a mesh origin, not both.' assert geo_reference is None, msg else: - points = ensure_numeric(copy.copy(points), num.float) + points = ensure_numeric(copy.copy(points), float) # Sort of geo_reference and convert points if geo_reference is None: @@ -1331,7 +1331,7 @@ def ensure_geospatial(points, geo_reference=None): return points else: # List or numeric array of absolute points - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) # Sort out geo reference if geo_reference is None: @@ -1477,7 +1477,7 @@ def find_optimal_smoothing_parameter(data_file, # creates array with columns 1 and 2 are x, y. column 3 is elevation # 4 onwards is the elevation_predicted using the alpha, which will # be compared later against the real removed data - data = num.array([], dtype=num.float) + data = num.array([], dtype=float) data = num.resize(data, (len(points), 3+len(alphas))) @@ -1488,7 +1488,7 @@ def find_optimal_smoothing_parameter(data_file, attribute_name=attribute_smoothed) data[:, 2] = elevation_sample - normal_cov = num.array(num.zeros([len(alphas), 2]), dtype=num.float) + normal_cov = num.array(num.zeros([len(alphas), 2]), dtype=float) if verbose: log.critical('Setup computational domains with ' @@ -1696,7 +1696,7 @@ def old_find_optimal_smoothing_parameter(data_file, # creates array with columns 1 and 2 are x, y. column 3 is elevation # 4 onwards is the elevation_predicted using the alpha, which will # be compared later against the real removed data - data = num.array([], dtype=num.float) + data = num.array([], dtype=float) data = num.resize(data, (len(points), 3+len(alphas))) @@ -1707,7 +1707,7 @@ def old_find_optimal_smoothing_parameter(data_file, attribute_name=attribute_smoothed) data[:, 2] = elevation_sample - normal_cov = num.array(num.zeros([len(alphas), 2]), dtype=num.float) + normal_cov = num.array(num.zeros([len(alphas), 2]), dtype=float) if verbose: log.critical('Determine difference between predicted results ' diff --git a/anuga/geospatial_data/tests/test_geospatial_data.py b/anuga/geospatial_data/tests/test_geospatial_data.py index 34dd1f8b9..8c6a137bd 100644 --- a/anuga/geospatial_data/tests/test_geospatial_data.py +++ b/anuga/geospatial_data/tests/test_geospatial_data.py @@ -1365,7 +1365,7 @@ def test_ensure_absolute(self): [1.0, 3.0], [2.0, 2.0]]) mesh_origin = (56, 290000, 618000) # zone, easting, northing - data_points = num.zeros((ab_points.shape), num.float) + data_points = num.zeros((ab_points.shape), float) #Shift datapoints according to new origins for k in range(len(ab_points)): @@ -1407,7 +1407,7 @@ def test_ensure_geospatial(self): [2.0, 0.0],[2.0, 2.0], [1.0, 3.0],[2.0, 2.0]]) mesh_origin = (56, 290000, 618000) # zone, easting, northing - data_points = num.zeros((ab_points.shape), num.float) + data_points = num.zeros((ab_points.shape), float) #Shift datapoints according to new origins for k in range(len(ab_points)): diff --git a/anuga/load_mesh/loadASCII.py b/anuga/load_mesh/loadASCII.py index 24cf0cfac..1a810be45 100644 --- a/anuga/load_mesh/loadASCII.py +++ b/anuga/load_mesh/loadASCII.py @@ -599,7 +599,7 @@ def _write_msh_file(file_name, mesh): # print 'mesh vertices',mesh['vertices'].shape # the triangulation - mesh['vertices'] = num.array(mesh['vertices'], num.float) + mesh['vertices'] = num.array(mesh['vertices'], float) mesh['vertex_attribute_titles'] = \ num.array(string_to_char( mesh['vertex_attribute_titles']), 'S1') @@ -609,7 +609,7 @@ def _write_msh_file(file_name, mesh): # print 'num_attrib ',num_attributes if mesh['vertex_attributes'] != None: mesh['vertex_attributes'] = \ - num.array(mesh['vertex_attributes'], num.float) + num.array(mesh['vertex_attributes'], float) if num_attributes > 0: mesh['vertex_attributes'] = \ @@ -625,16 +625,16 @@ def _write_msh_file(file_name, mesh): num.array(mesh['triangle_neighbors'], IntType) # the outline - mesh['points'] = num.array(mesh['points'], num.float) - mesh['point_attributes'] = num.array(mesh['point_attributes'], num.float) + mesh['points'] = num.array(mesh['points'], float) + mesh['point_attributes'] = num.array(mesh['point_attributes'], float) mesh['outline_segments'] = num.array(mesh['outline_segments'], IntType) mesh['outline_segment_tags'] = \ num.array(string_to_char(mesh['outline_segment_tags']), 'S1') - mesh['holes'] = num.array(mesh['holes'], num.float) - mesh['regions'] = num.array(mesh['regions'], num.float) + mesh['holes'] = num.array(mesh['holes'], float) + mesh['regions'] = num.array(mesh['regions'], float) mesh['region_tags'] = num.array( string_to_char(mesh['region_tags']), 'S1') - mesh['region_max_areas'] = num.array(mesh['region_max_areas'], num.float) + mesh['region_max_areas'] = num.array(mesh['region_max_areas'], float) # NetCDF file definition try: @@ -798,7 +798,7 @@ def _read_msh_file(file_name): try: mesh['vertices'] = fid.variables['vertices'][:] except KeyError: - mesh['vertices'] = num.array([], num.int) # array default# + mesh['vertices'] = num.array([], int) # array default# try: mesh['vertex_attributes'] = fid.variables['vertex_attributes'][:] @@ -816,7 +816,7 @@ def _read_msh_file(file_name): try: mesh['segments'] = fid.variables['segments'][:] except KeyError: - mesh['segments'] = num.array([], num.int) # array default# + mesh['segments'] = num.array([], int) # array default# mesh['segment_tags'] = [] try: @@ -830,8 +830,8 @@ def _read_msh_file(file_name): mesh['triangles'] = fid.variables['triangles'][:] mesh['triangle_neighbors'] = fid.variables['triangle_neighbors'][:] except KeyError: - mesh['triangles'] = num.array([], num.int) # array default# - mesh['triangle_neighbors'] = num.array([], num.int) # array default# + mesh['triangles'] = num.array([], int) # array default# + mesh['triangle_neighbors'] = num.array([], int) # array default# mesh['triangle_tags'] = [] @@ -859,7 +859,7 @@ def _read_msh_file(file_name): try: mesh['outline_segments'] = fid.variables['outline_segments'][:] except KeyError: - mesh['outline_segments'] = num.array([], num.int) # array default# + mesh['outline_segments'] = num.array([], int) # array default# mesh['outline_segment_tags'] = [] try: @@ -873,12 +873,12 @@ def _read_msh_file(file_name): try: mesh['holes'] = fid.variables['holes'][:] except KeyError: - mesh['holes'] = num.array([], num.int) # array default# + mesh['holes'] = num.array([], int) # array default# try: mesh['regions'] = fid.variables['regions'][:] except KeyError: - mesh['regions'] = num.array([], num.int) # array default# + mesh['regions'] = num.array([], int) # array default# mesh['region_tags'] = [] try: @@ -892,7 +892,7 @@ def _read_msh_file(file_name): try: mesh['region_max_areas'] = fid.variables['region_max_areas'][:] except KeyError: - mesh['region_max_areas'] = num.array([], num.int) # array default# + mesh['region_max_areas'] = num.array([], int) # array default# try: geo_reference = Geo_reference(NetCDFObject=fid) @@ -945,7 +945,7 @@ def extent_point_atts(point_atts): def extent(points): - points = num.array(points, num.float) + points = num.array(points, float) max_x = min_x = points[0][0] max_y = min_y = points[0][1] @@ -1015,11 +1015,11 @@ def produce_half_point_files(infile, max_points, delimiter, verbose=False): def point_atts2array(point_atts): # convert attribute list to array of floats - point_atts['pointlist'] = num.array(point_atts['pointlist'], num.float) + point_atts['pointlist'] = num.array(point_atts['pointlist'], float) for key in list(point_atts['attributelist'].keys()): point_atts['attributelist'][key] = \ - num.array(point_atts['attributelist'][key], num.float) + num.array(point_atts['attributelist'][key], float) return point_atts @@ -1040,7 +1040,7 @@ def concatinate_attributelist(dic): return list of attribute titles, array of attributes """ - point_attributes = num.array([], num.float) + point_attributes = num.array([], float) keys = list(dic.keys()) key = keys.pop(0) point_attributes = num.reshape(dic[key], (dic[key].shape[0], 1)) diff --git a/anuga/mesh_engine/mesh_engine.py b/anuga/mesh_engine/mesh_engine.py index 1fb1b9736..cd1d14408 100644 --- a/anuga/mesh_engine/mesh_engine.py +++ b/anuga/mesh_engine/mesh_engine.py @@ -49,7 +49,7 @@ def generate_mesh(points=None, dummy_test = [] try: - points = ensure_numeric(points, num.float) + points = ensure_numeric(points, float) except ValueError: msg = 'ERROR: Inconsistent points array.' raise ANUGAError(msg) @@ -62,7 +62,7 @@ def generate_mesh(points=None, pointatts = [[] for x in range(points.shape[0])] try: - # If num.int is used, instead of num.int32, it fails in Linux + # If int is used, instead of num.int32, it fails in Linux segments = ensure_numeric(segments, num.int32) except ValueError: @@ -74,7 +74,7 @@ def generate_mesh(points=None, segatts = [0 for x in range(segments.shape[0])] try: - holes = ensure_numeric(holes, num.float) + holes = ensure_numeric(holes, float) except ValueError: msg = 'ERROR: Inconsistent holes array.' raise ANUGAError(msg) @@ -82,7 +82,7 @@ def generate_mesh(points=None, regions = add_area_tag(regions) try: - regions = ensure_numeric(regions, num.float) + regions = ensure_numeric(regions, float) except (ValueError, TypeError): msg = 'ERROR: Inconsistent regions array.' raise ANUGAError(msg) @@ -92,7 +92,7 @@ def generate_mesh(points=None, raise ANUGAError(msg) try: - pointatts = ensure_numeric(pointatts, num.float) + pointatts = ensure_numeric(pointatts, float) except (ValueError, TypeError): msg = 'ERROR: Inconsistent point attributes array.' raise ANUGAError(msg) @@ -179,7 +179,7 @@ def generate_mesh(points=None, if 'vertices' in tri: pointlist = num.ascontiguousarray(tri['vertices']) else: - pointlist = num.empty((0,2),dtype=num.float) + pointlist = num.empty((0,2),dtype=float) if 'vertex_markers' in tri: pointmarkerlist = num.ascontiguousarray(tri['vertex_markers'].reshape(-1)) else: @@ -191,11 +191,11 @@ def generate_mesh(points=None, if 'vertex_attributes' in tri: pointattributelist = num.ascontiguousarray(tri['vertex_attributes']) else: - pointattributelist = num.empty((pointlist.shape[0],0),dtype=num.float) + pointattributelist = num.empty((pointlist.shape[0],0),dtype=float) if 'triangle_attributes' in tri: triangleattributelist = num.ascontiguousarray(tri['triangle_attributes']) else: - triangleattributelist = num.empty((trianglelist.shape[0],0),dtype=num.float) + triangleattributelist = num.empty((trianglelist.shape[0],0),dtype=float) if 'segments' in tri: segmentlist = num.ascontiguousarray(tri['segments']) else: diff --git a/anuga/mesh_engine/tests/test_generate_mesh.py b/anuga/mesh_engine/tests/test_generate_mesh.py index 975868774..34a0bbfdd 100644 --- a/anuga/mesh_engine/tests/test_generate_mesh.py +++ b/anuga/mesh_engine/tests/test_generate_mesh.py @@ -409,7 +409,7 @@ def test_numeric_arrays(self): correct.flat), 'Failed!') - correct = num.array(segattlist, num.int) + correct = num.array(segattlist, int) self.assertTrue(num.allclose(data['generatedsegmentmarkerlist'].flat, correct.flat), 'Failed') diff --git a/anuga/operators/elliptic_operator.py b/anuga/operators/elliptic_operator.py index f470dcd05..4235044dc 100644 --- a/anuga/operators/elliptic_operator.py +++ b/anuga/operators/elliptic_operator.py @@ -76,8 +76,8 @@ def __init__(self, domain, use_triangle_areas=True, verbose=False): #Geometric Information if verbose: log.critical('Kinematic Viscosity: Building geometric structure') - self.geo_structure_indices = num.zeros((self.n, 3), num.int) - self.geo_structure_values = num.zeros((self.n, 3), num.float) + self.geo_structure_indices = num.zeros((self.n, 3), int) + self.geo_structure_values = num.zeros((self.n, 3), float) # Only needs to built once, doesn't change kinematic_viscosity_operator_ext.build_geo_structure(self) @@ -97,16 +97,16 @@ def __init__(self, domain, use_triangle_areas=True, verbose=False): self.qty_considered = 1 #1 or 2 (uh or vh respectively) #Sparse_CSR.data - self.operator_data = num.zeros((4 * self.n, ), num.float) + self.operator_data = num.zeros((4 * self.n, ), float) #Sparse_CSR.colind - self.operator_colind = num.zeros((4 * self.n, ), num.int) + self.operator_colind = num.zeros((4 * self.n, ), int) #Sparse_CSR.rowptr (4 entries in every row, we know this already) = [0,4,8,...,4*n] self.operator_rowptr = 4 * num.arange(self.n + 1) # Build matrix self.elliptic_matrix [A B] self.build_elliptic_matrix(self.diffusivity) - self.boundary_term = num.zeros((self.n, ), num.float) + self.boundary_term = num.zeros((self.n, ), float) self.parabolic = False #Are we doing a parabolic solve at the moment? @@ -223,7 +223,7 @@ def _update_elliptic_boundary_term(self, b): n = self.n tot_len = self.tot_len - X = num.zeros((tot_len,), num.float) + X = num.zeros((tot_len,), float) X[n:] = b self.boundary_term[:] = self.elliptic_matrix * X @@ -281,7 +281,7 @@ def _elliptic_multiply_array(self, array_in, array_out): n = self.n tot_len = self.tot_len - V = num.zeros((tot_len,), num.float) + V = num.zeros((tot_len,), float) assert len(array_in) == n @@ -352,7 +352,7 @@ def _parabolic_multiply_array(self, array_in, array_out): n = self.n tot_len = self.tot_len - V = num.zeros((tot_len,), num.float) + V = num.zeros((tot_len,), float) assert len(array_in) == n diff --git a/anuga/operators/erosion_operators.py b/anuga/operators/erosion_operators.py index ac51f1f5f..298ae7974 100644 --- a/anuga/operators/erosion_operators.py +++ b/anuga/operators/erosion_operators.py @@ -207,7 +207,7 @@ def clean_up_elevation_stage(self): for nid in self.node_ids: non = self.domain.number_of_triangles_per_node[nid] - vid = num.arange(self.node_index[nid], self.node_index[nid+1],dtype=num.int) + vid = num.arange(self.node_index[nid], self.node_index[nid+1],dtype=int) vidd = self.domain.vertex_value_indices[vid] # Replaced this (Ole) @@ -439,9 +439,9 @@ def setup_node_structures(self): vertex_ids.append(vidd) #print ' ',nid, vid, vidd, vidd/3, vidd%3 - self.vol_ids = num.array(vertex_ids, dtype=num.int) // 3 - self.vols = num.array(list(set(self.vol_ids)), dtype=num.int) - self.vert_ids = num.array(vertex_ids,dtype=num.int)%3 + self.vol_ids = num.array(vertex_ids, dtype=int) // 3 + self.vols = num.array(list(set(self.vol_ids)), dtype=int) + self.vert_ids = num.array(vertex_ids,dtype=int)%3 diff --git a/anuga/operators/kinematic_viscosity_operator.py b/anuga/operators/kinematic_viscosity_operator.py index 4570cdf6c..fbc086a83 100644 --- a/anuga/operators/kinematic_viscosity_operator.py +++ b/anuga/operators/kinematic_viscosity_operator.py @@ -79,8 +79,8 @@ def __init__(self, #Geometric Information if verbose: log.critical('Kinematic Viscosity: Building geometric structure') - self.geo_structure_indices = num.zeros((self.n, 3), num.int) - self.geo_structure_values = num.zeros((self.n, 3), num.float) + self.geo_structure_indices = num.zeros((self.n, 3), int) + self.geo_structure_values = num.zeros((self.n, 3), float) # Only needs to built once, doesn't change kinematic_viscosity_operator_ext.build_geo_structure(self) @@ -100,16 +100,16 @@ def __init__(self, self.qty_considered = 1 #1 or 2 (uh or vh respectively) #Sparse_CSR.data - self.operator_data = num.zeros((4 * self.n, ), num.float) + self.operator_data = num.zeros((4 * self.n, ), float) #Sparse_CSR.colind - self.operator_colind = num.zeros((4 * self.n, ), num.int) + self.operator_colind = num.zeros((4 * self.n, ), int) #Sparse_CSR.rowptr (4 entries in every row, we know this already) = [0,4,8,...,4*n] self.operator_rowptr = 4 * num.arange(self.n + 1) # Build matrix self.elliptic_matrix [A B] self.build_elliptic_matrix(self.diffusivity) - self.boundary_term = num.zeros((self.n, ), num.float) + self.boundary_term = num.zeros((self.n, ), float) self.parabolic = False #Are we doing a parabolic solve at the moment? @@ -281,7 +281,7 @@ def _update_elliptic_boundary_term(self, b): n = self.n tot_len = self.tot_len - X = num.zeros((tot_len,), num.float) + X = num.zeros((tot_len,), float) X[n:] = b self.boundary_term[:] = self.elliptic_matrix * X @@ -339,7 +339,7 @@ def _elliptic_multiply_array(self, array_in, array_out): n = self.n tot_len = self.tot_len - V = num.zeros((tot_len,), num.float) + V = num.zeros((tot_len,), float) assert len(array_in) == n @@ -410,7 +410,7 @@ def _parabolic_multiply_array(self, array_in, array_out): n = self.n tot_len = self.tot_len - V = num.zeros((tot_len,), num.float) + V = num.zeros((tot_len,), float) assert len(array_in) == n diff --git a/anuga/operators/set_elevation.py b/anuga/operators/set_elevation.py index 286fb2756..091e3ed9e 100644 --- a/anuga/operators/set_elevation.py +++ b/anuga/operators/set_elevation.py @@ -152,7 +152,7 @@ def __call__(self): for nid in self.node_ids: non = self.domain.number_of_triangles_per_node[nid] - vid = num.arange(self.node_index[nid], self.node_index[nid+1], dtype=num.int) + vid = num.arange(self.node_index[nid], self.node_index[nid+1], dtype=int) vidd = self.domain.vertex_value_indices[vid] # Replaced this (Ole) @@ -270,7 +270,7 @@ def setup_node_structures(self): - node_index = num.zeros((self.domain.number_of_nodes)+1, dtype = num.int) + node_index = num.zeros((self.domain.number_of_nodes)+1, dtype = int) # FIXME: SR Don't we calculate this for the domain already! k = 0 @@ -288,9 +288,9 @@ def setup_node_structures(self): vertex_ids.append(vidd) #print ' ',nid, vid, vidd, vidd/3, vidd%3 - self.vol_ids = num.array(vertex_ids, dtype=num.int) // 3 # FIXME(Ole): Tests past both with / and // - self.vols = num.array(list(set(self.vol_ids)), dtype=num.int) - self.vert_ids = num.array(vertex_ids,dtype=num.int)%3 + self.vol_ids = num.array(vertex_ids, dtype=int) // 3 # FIXME(Ole): Tests past both with / and // + self.vols = num.array(list(set(self.vol_ids)), dtype=int) + self.vert_ids = num.array(vertex_ids,dtype=int)%3 diff --git a/anuga/operators/tests/test_kinematic_viscosity_operator.py b/anuga/operators/tests/test_kinematic_viscosity_operator.py index 1b05dd810..43c38fc9a 100644 --- a/anuga/operators/tests/test_kinematic_viscosity_operator.py +++ b/anuga/operators/tests/test_kinematic_viscosity_operator.py @@ -213,7 +213,7 @@ def test_elliptic_multiply_include_boundary_one_triangle(self): assert num.allclose(q_1.centroid_values,q_2.centroid_values) - assert num.allclose( num.zeros((n,), num.float), q_1.centroid_values ) + assert num.allclose( num.zeros((n,), float), q_1.centroid_values ) #Now have different boundary values diff --git a/anuga/parallel/distribute_mesh.py b/anuga/parallel/distribute_mesh.py index f175ec92b..adc38c595 100644 --- a/anuga/parallel/distribute_mesh.py +++ b/anuga/parallel/distribute_mesh.py @@ -67,7 +67,7 @@ def reorder(quantities, tri_index, proc_sum): # Temporary storage area - index = num.zeros(N, num.int) + index = num.zeros(N, int) q_reord = {} # Find the new ordering of the triangles @@ -80,7 +80,7 @@ def reorder(quantities, tri_index, proc_sum): # Reorder each quantity according to the new ordering for k in quantities: - q_reord[k] = num.zeros((N, 3), num.float) + q_reord[k] = num.zeros((N, 3), float) for i in range(N): q_reord[k][index[i]] = quantities[k].vertex_values[i] del index @@ -101,7 +101,7 @@ def reorder_new(quantities, epart_order, proc_sum): # Reorder each quantity according to the new ordering for k in quantities: - q_reord[k] = num.zeros((N, 3), num.float) + q_reord[k] = num.zeros((N, 3), float) q_reord[k][:] = quantities[k].vertex_values[epart_order] return q_reord @@ -206,7 +206,7 @@ def pmesh_divide_metis_helper(domain, n_procs): # dimensional arrays. Correct this. # TODO: Not sure if this can still happen with metis 5 if type(epart[0]) == num.ndarray: - epart_new = num.zeros(len(epart), num.int) + epart_new = num.zeros(len(epart), int) epart_new[:] = epart[:][0] epart = epart_new del epart_new @@ -217,14 +217,14 @@ def pmesh_divide_metis_helper(domain, n_procs): msg += "Try using a smaller number of mpi processes." assert num.all(triangles_per_proc > 0), msg - proc_sum = num.zeros(n_procs+1, num.int) + proc_sum = num.zeros(n_procs+1, int) proc_sum[1:] = num.cumsum(triangles_per_proc) epart_order = num.argsort(epart, kind='mergesort') new_triangles = domain.triangles[epart_order] - #new_r_tri_index_flat = num.zeros((n_tri,3), num.int) - new_tri_index = num.zeros((n_tri, 2), num.int) + #new_r_tri_index_flat = num.zeros((n_tri,3), int) + new_tri_index = num.zeros((n_tri, 2), int) for i in range(n_procs): ids = num.arange(proc_sum[i], proc_sum[i+1]) eids = epart_order[ids] @@ -264,7 +264,7 @@ def pmesh_divide_metis_helper(domain, n_procs): new_quantities = {} for k in domain.quantities: - new_quantities[k] = num.zeros((n_tri, 3), num.float) + new_quantities[k] = num.zeros((n_tri, 3), float) for i in range(n_tri): new_quantities[k][i] = domain.quantities[k].vertex_values[i] @@ -428,7 +428,7 @@ def ghost_layer_old(submesh, mesh, p, tupper, tlower, parameters=None): else: layer_width = parameters['ghost_layer_width'] - trianglemap = num.zeros(ntriangles, num.int) + trianglemap = num.zeros(ntriangles, int) # Find the first layer of boundary triangles for t in range(tlower, tupper): @@ -471,7 +471,7 @@ def ghost_layer_old(submesh, mesh, p, tupper, tlower, parameters=None): # Build the triangle list and make note of the vertices - nodemap = num.zeros(ncoord, num.int) + nodemap = num.zeros(ncoord, int) fullnodes = submesh["full_nodes"][p] subtriangles = [] @@ -551,7 +551,7 @@ def ghost_layer(submesh, mesh, p, tupper, tlower, parameters=None): (num.reshape(new_trianglemap, (-1, 1)), mesh.triangles[new_trianglemap]), 1) fullnodes = submesh["full_nodes"][p] - full_nodes_ids = num.array(fullnodes[:, 0], num.int) + full_nodes_ids = num.array(fullnodes[:, 0], int) new_nodes = num.unique(mesh.triangles[new_trianglemap].flat) new_nodes = numset.setdiff1d(new_nodes, full_nodes_ids) @@ -726,7 +726,7 @@ def ghost_commun_pattern_old(subtri, p, tri_per_proc): # Loop over the ghost triangles - ghost_commun = num.zeros((len(subtri), 2), num.int) + ghost_commun = num.zeros((len(subtri), 2), int) for i in range(len(subtri)): global_no = subtri[i][0] @@ -753,7 +753,7 @@ def ghost_commun_pattern_old_2(subtri, p, tri_per_proc_range): # Loop over the ghost triangles - ghost_commun = num.zeros((len(subtri), 2), num.int) + ghost_commun = num.zeros((len(subtri), 2), int) # print tri_per_proc_range # print tri_per_proc @@ -972,7 +972,7 @@ def submesh_quantities(submesh, quantities, triangles_per_proc): for k in quantities: submesh["full_quan"][k].append(quantities[k][lower:upper]) - submesh["ghost_quan"][k].append(num.zeros((M, 3), num.float)) + submesh["ghost_quan"][k].append(num.zeros((M, 3), float)) for j in range(M): submesh["ghost_quan"][k][p][j] = \ quantities[k][global_id[j]] @@ -1077,14 +1077,14 @@ def build_local_GA(nodes, triangles, boundaries, tri_map): if nodes[i][0] > NGlobal: NGlobal = nodes[i][0] - node_map = -1*num.ones(int(NGlobal)+1, num.int) + node_map = -1*num.ones(int(NGlobal)+1, int) - num.put(node_map, num.take(nodes, (0,), 1).astype(num.int), - num.arange(Nnodes, dtype=num.int)) + num.put(node_map, num.take(nodes, (0,), 1).astype(int), + num.arange(Nnodes, dtype=int)) # Change the global IDs in the triangles to the local IDs - GAtriangles = num.zeros((Ntriangles, 3), num.int) + GAtriangles = num.zeros((Ntriangles, 3), int) GAtriangles[:, 0] = num.take(node_map, triangles[:, 0]) GAtriangles[:, 1] = num.take(node_map, triangles[:, 1]) GAtriangles[:, 2] = num.take(node_map, triangles[:, 2]) @@ -1213,8 +1213,8 @@ def build_local_mesh(submesh, lower_t, upper_t, nproc): id = submesh["ghost_triangles"][i][0] if id > NGlobal: NGlobal = id - #index = num.zeros(int(NGlobal)+1, num.int) - tri_map = -1*num.ones(int(NGlobal)+1, num.int) + #index = num.zeros(int(NGlobal)+1, int) + tri_map = -1*num.ones(int(NGlobal)+1, int) tri_map[lower_t:upper_t] = num.arange(upper_t-lower_t) for i in range(len(submesh["ghost_triangles"])): tri_map[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t @@ -1231,7 +1231,7 @@ def build_local_mesh(submesh, lower_t, upper_t, nproc): for k in submesh["full_quan"]: Nf = len(submesh["full_quan"][k]) Ng = len(submesh["ghost_quan"][k]) - quantities[k] = num.zeros((Nf+Ng, 3), num.float) + quantities[k] = num.zeros((Nf+Ng, 3), float) quantities[k][0:Nf] = submesh["full_quan"][k] quantities[k][Nf:Nf+Ng] = submesh["ghost_quan"][k] @@ -1323,7 +1323,7 @@ def send_submesh(submesh, triangles_per_proc, p, verbose=True): # send the array sizes so memory can be allocated - setup_array = num.zeros((9,), num.int) + setup_array = num.zeros((9,), int) setup_array[0] = len(submesh["full_nodes"][p]) setup_array[1] = len(submesh["ghost_nodes"][p]) setup_array[2] = len(submesh["full_triangles"][p]) @@ -1334,30 +1334,30 @@ def send_submesh(submesh, triangles_per_proc, p, verbose=True): setup_array[7] = len(flat_full_commun) setup_array[8] = len(submesh["full_quan"]) - x = num.array(setup_array, num.int) + x = num.array(setup_array, int) pypar.send(x, p, bypass=True) # ghost layer width - x = num.array(submesh["ghost_layer_width"][p], num.int) + x = num.array(submesh["ghost_layer_width"][p], int) pypar.send(x, p, bypass=True) # send the number of triangles per processor - x = num.array(triangles_per_proc, num.int) + x = num.array(triangles_per_proc, int) pypar.send(x, p, bypass=True) # send the nodes - x = num.array(submesh["full_nodes"][p], num.float) + x = num.array(submesh["full_nodes"][p], float) pypar.send(x, p, bypass=True) - x = num.array(submesh["ghost_nodes"][p], num.float) + x = num.array(submesh["ghost_nodes"][p], float) pypar.send(x, p, bypass=True) # send the triangles - x = num.array(submesh["full_triangles"][p], num.int) + x = num.array(submesh["full_triangles"][p], int) pypar.send(x, p, bypass=True) # send ghost triangles - x = num.array(submesh["ghost_triangles"][p], num.int) + x = num.array(submesh["ghost_triangles"][p], int) pypar.send(x, p, bypass=True) # send the boundary @@ -1365,30 +1365,30 @@ def send_submesh(submesh, triangles_per_proc, p, verbose=True): for b in submesh["full_boundary"][p]: bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]]) - x = num.array(bc, num.int) + x = num.array(bc, int) pypar.send(x, p, bypass=True) bc = [] for b in submesh["ghost_boundary"][p]: bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]]) - x = num.array(bc, num.int) + x = num.array(bc, int) pypar.send(x, p, bypass=True) # send the communication pattern - x = num.array(submesh["ghost_commun"][p], num.int) + x = num.array(submesh["ghost_commun"][p], int) pypar.send(x, p, bypass=True) - x = num.array(flat_full_commun, num.int) + x = num.array(flat_full_commun, int) pypar.send(x, p, bypass=True) # send the quantities for k in submesh["full_quan"]: - x = num.array(submesh["full_quan"][k][p], num.float) + x = num.array(submesh["full_quan"][k][p], float) pypar.send(x, p, bypass=True) for k in submesh["ghost_quan"]: - x = num.array(submesh["ghost_quan"][k][p], num.float) + x = num.array(submesh["ghost_quan"][k][p], float) pypar.send(x, p, bypass=True) @@ -1433,7 +1433,7 @@ def rec_submesh_flat(p, verbose=True): qkeys = pypar.receive(p) # recieve information about the array sizes - x = num.zeros((9,), num.int) + x = num.zeros((9,), int) pypar.receive(p, buffer=x, bypass=True) setup_array = x @@ -1448,37 +1448,37 @@ def rec_submesh_flat(p, verbose=True): no_quantities = setup_array[8] # ghost layer width - x = num.zeros((1,), num.int) + x = num.zeros((1,), int) pypar.receive(p, buffer=x, bypass=True) submesh_cell["ghost_layer_width"] = x[0] # receive the number of triangles per processor - x = num.zeros((numprocs,), num.int) + x = num.zeros((numprocs,), int) pypar.receive(p, buffer=x, bypass=True) triangles_per_proc = x # receive the full nodes - x = num.zeros((no_full_nodes, 3), num.float) + x = num.zeros((no_full_nodes, 3), float) pypar.receive(p, buffer=x, bypass=True) submesh_cell["full_nodes"] = x # receive the ghost nodes - x = num.zeros((no_ghost_nodes, 3), num.float) + x = num.zeros((no_ghost_nodes, 3), float) pypar.receive(p, buffer=x, bypass=True) submesh_cell["ghost_nodes"] = x # receive the full triangles - x = num.zeros((no_full_triangles, 3), num.int) + x = num.zeros((no_full_triangles, 3), int) pypar.receive(p, buffer=x, bypass=True) submesh_cell["full_triangles"] = x # receive the ghost triangles - x = num.zeros((no_ghost_triangles, 4), num.int) + x = num.zeros((no_ghost_triangles, 4), int) pypar.receive(p, buffer=x, bypass=True) submesh_cell["ghost_triangles"] = x # receive the full boundary - x = num.zeros((no_full_boundary, 3), num.int) + x = num.zeros((no_full_boundary, 3), int) pypar.receive(p, buffer=x, bypass=True) bnd_c = x @@ -1487,7 +1487,7 @@ def rec_submesh_flat(p, verbose=True): submesh_cell["full_boundary"][b[0], b[1]] = itagmap[b[2]] # receive the ghost boundary - x = num.zeros((no_ghost_boundary, 3), num.int) + x = num.zeros((no_ghost_boundary, 3), int) pypar.receive(p, buffer=x, bypass=True) bnd_c = x @@ -1496,13 +1496,13 @@ def rec_submesh_flat(p, verbose=True): submesh_cell["ghost_boundary"][b[0], b[1]] = itagmap[b[2]] # receive the ghost communication pattern - x = num.zeros((no_ghost_commun, 2), num.int) + x = num.zeros((no_ghost_commun, 2), int) pypar.receive(p, buffer=x, bypass=True) submesh_cell["ghost_commun"] = x # receive the full communication pattern - x = num.zeros((no_full_commun, 2), num.int) + x = num.zeros((no_full_commun, 2), int) pypar.receive(p, buffer=x, bypass=True) full_commun = x @@ -1516,13 +1516,13 @@ def rec_submesh_flat(p, verbose=True): submesh_cell["full_quan"] = {} for i in range(no_quantities): - x = num.zeros((no_full_triangles, 3), num.float) + x = num.zeros((no_full_triangles, 3), float) pypar.receive(p, buffer=x, bypass=True) submesh_cell["full_quan"][qkeys[i]] = x submesh_cell["ghost_quan"] = {} for i in range(no_quantities): - x = num.zeros((no_ghost_triangles, 3), num.float) + x = num.zeros((no_ghost_triangles, 3), float) pypar.receive(p, buffer=x, bypass=True) submesh_cell["ghost_quan"][qkeys[i]] = x diff --git a/anuga/parallel/parallel_advection.py b/anuga/parallel/parallel_advection.py index 7d2e95f09..5018410c7 100644 --- a/anuga/parallel/parallel_advection.py +++ b/anuga/parallel/parallel_advection.py @@ -74,9 +74,9 @@ def update_timestep(self, yieldstep, finaltime): # For some reason it looks like pypar only reduces numeric arrays # hence we need to create some dummy arrays for communication - ltimestep = num.ones( 1, num.float ) + ltimestep = num.ones( 1, float ) ltimestep[0] = self.flux_timestep - gtimestep = num.zeros( 1, num.float ) # Buffer for results + gtimestep = num.zeros( 1, float ) # Buffer for results #ltimestep = self.flux_timeste diff --git a/anuga/parallel/parallel_api.py b/anuga/parallel/parallel_api.py index b1bdc0142..4f76feb1e 100644 --- a/anuga/parallel/parallel_api.py +++ b/anuga/parallel/parallel_api.py @@ -271,13 +271,13 @@ def protocol(x): if send_s2p : n = len(s2p_map) - s2p_map_keys_flat = num.reshape(num.array(list(s2p_map.keys()),num.int), (n,1) ) - s2p_map_values_flat = num.array(list(s2p_map.values()),num.int) + s2p_map_keys_flat = num.reshape(num.array(list(s2p_map.keys()),int), (n,1) ) + s2p_map_values_flat = num.array(list(s2p_map.values()),int) s2p_map_flat = num.concatenate( (s2p_map_keys_flat, s2p_map_values_flat), axis=1 ) n = len(p2s_map) - p2s_map_keys_flat = num.reshape(num.array(list(p2s_map.keys()),num.int), (n,2) ) - p2s_map_values_flat = num.reshape(num.array(list(p2s_map.values()),num.int) , (n,1)) + p2s_map_keys_flat = num.reshape(num.array(list(p2s_map.keys()),int), (n,2) ) + p2s_map_values_flat = num.reshape(num.array(list(p2s_map.values()),int) , (n,1)) p2s_map_flat = num.concatenate( (p2s_map_keys_flat, p2s_map_values_flat), axis=1 ) for p in range(1, numprocs): @@ -506,4 +506,4 @@ def mpicmd(script_name, numprocs=3): if platform.system() == 'Windows': extra_options = ' ' - return "mpiexec -np %d %s python %s" % (numprocs, extra_options, script_name) + return "mpiexec -np %d %s python -m mpi4py %s" % (numprocs, extra_options, script_name) diff --git a/anuga/parallel/parallel_generic_communications.py b/anuga/parallel/parallel_generic_communications.py index 9dd21ab6a..23cc2b1e0 100644 --- a/anuga/parallel/parallel_generic_communications.py +++ b/anuga/parallel/parallel_generic_communications.py @@ -19,10 +19,10 @@ def setup_buffers(domain): """Buffers for synchronisation of timesteps """ - domain.local_timestep = num.zeros(1, num.float) - domain.global_timestep = num.zeros(1, num.float) + domain.local_timestep = num.zeros(1, float) + domain.global_timestep = num.zeros(1, float) - domain.local_timesteps = num.zeros(domain.numproc, num.float) + domain.local_timesteps = num.zeros(domain.numproc, float) domain.communication_time = 0.0 domain.communication_reduce_time = 0.0 diff --git a/anuga/parallel/parallel_meshes.py b/anuga/parallel/parallel_meshes.py index c04dcd352..ace53e752 100644 --- a/anuga/parallel/parallel_meshes.py +++ b/anuga/parallel/parallel_meshes.py @@ -86,7 +86,7 @@ def __call__(self, i,j): I = VIndex(n,m) E = EIndex(n,m) - points = num.zeros( (Np,2), num.float) + points = num.zeros( (Np,2), float) for i in range(m+1): for j in range(n+1): @@ -98,7 +98,7 @@ def __call__(self, i,j): Nt = 2*m*n - elements = num.zeros( (Nt,3), num.int) + elements = num.zeros( (Nt,3), int) boundary = {} Idgl = [] Idfl = [] @@ -170,8 +170,8 @@ def __call__(self, i,j): #print Idfl #print Idgr - Idfl = num.array(Idfl,num.int) - Idgr = num.array(Idgr,num.int) + Idfl = num.array(Idfl,int) + Idgr = num.array(Idgr,int) #print Idfl #print Idgr @@ -183,16 +183,16 @@ def __call__(self, i,j): elif numprocs == 2: Idfl.extend(Idfr) Idgr.extend(Idgl) - Idfl = num.array(Idfl,num.int) - Idgr = num.array(Idgr,num.int) + Idfl = num.array(Idfl,int) + Idgr = num.array(Idgr,int) full_send_dict[(myid-1)%numprocs] = [Idfl, Idfl] ghost_recv_dict[(myid-1)%numprocs] = [Idgr, Idgr] else: - Idfl = num.array(Idfl,num.int) - Idgl = num.array(Idgl,num.int) + Idfl = num.array(Idfl,int) + Idgl = num.array(Idgl,int) - Idfr = num.array(Idfr,num.int) - Idgr = num.array(Idgr,num.int) + Idfr = num.array(Idfr,int) + Idgr = num.array(Idgr,int) full_send_dict[(myid-1)%numprocs] = [Idfl, Idfl] ghost_recv_dict[(myid-1)%numprocs] = [Idgl, Idgl] @@ -251,7 +251,7 @@ def __call__(self, i,j): I = VIndex(n,m) E = EIndex(n,m) - points = num.zeros( (Np,2), num.float) + points = num.zeros( (Np,2), float) for i in range(m+1): for j in range(n+1): @@ -263,7 +263,7 @@ def __call__(self, i,j): Nt = 2*m*n - elements = num.zeros( (Nt,3), num.int) + elements = num.zeros( (Nt,3), int) boundary = {} ghosts = {} nt = -1 @@ -388,7 +388,7 @@ def __call__(self, i,j): I = VIndex(n,m) E = EIndex(n,m) - points = num.zeros( (Np,2), num.float) + points = num.zeros( (Np,2), float) for i in range(m+1): for j in range(n+1): @@ -400,7 +400,7 @@ def __call__(self, i,j): Nt = 2*m*n - elements = num.zeros( (Nt,3), num.int) + elements = num.zeros( (Nt,3), int) boundary = {} ghosts = {} nt = -1 diff --git a/anuga/parallel/tests/run_parallel_distribute_domain.py b/anuga/parallel/tests/run_parallel_distribute_domain.py new file mode 100644 index 000000000..3756ec1c3 --- /dev/null +++ b/anuga/parallel/tests/run_parallel_distribute_domain.py @@ -0,0 +1,170 @@ +#------------------------------------------------------------------------------ +# Import necessary modules +#------------------------------------------------------------------------------ + +from builtins import range +from builtins import object +import unittest +import os +import sys + +from anuga.utilities.system_tools import get_pathname_from_package + +import numpy as num + +from anuga.utilities import parallel_abstraction as pypar + +#------------------------------------------ +# anuga imports +#------------------------------------------ +import anuga + +from anuga.utilities.numerical_tools import ensure_numeric +from anuga.utilities.util_ext import double_precision +from anuga.utilities.norms import l1_norm, l2_norm, linf_norm + +from anuga import Domain +from anuga import Reflective_boundary +from anuga import Dirichlet_boundary +from anuga import Time_boundary +from anuga import Transmissive_boundary + +from anuga import rectangular_cross +from anuga import create_domain_from_file + + +from anuga.parallel import distribute, myid, numprocs, finalize + + +#-------------------------------------------------------------------------- +# Setup parameters +#-------------------------------------------------------------------------- + +mod_path = get_pathname_from_package('anuga.parallel') + +mesh_filename = os.path.join(mod_path,'data','merimbula_10785_1.tsh') +#mesh_filename = os.path.join(mod_path,'data','test-100.tsh') +yieldstep = 1 +finaltime = 20 +quantity = 'stage' +nprocs = 4 +verbose = False + +#-------------------------------------------------------------------------- +# Setup procedures +#-------------------------------------------------------------------------- +class Set_Stage(object): + """Set an initial condition with constant water height, for xself.x0)&(x 1: + if myid == 0 and verbose: print('DISTRIBUTING PARALLEL DOMAIN') + domain = distribute(domain) + +#------------------------------------------------------------------------------ +# Setup boundary conditions +# This must currently happen *after* domain has been distributed +#------------------------------------------------------------------------------ +domain.store = False +Br = Reflective_boundary(domain) # Solid reflective wall + +domain.set_boundary({'outflow' :Br, 'inflow' :Br, 'inner' :Br, 'exterior' :Br, 'open' :Br}) + +#------------------------------------------------------------------------------ +# Setup diagnostic arrays +#------------------------------------------------------------------------------ +l1list = [] +l2list = [] +linflist = [] +l1norm = num.zeros(3, float) +l2norm = num.zeros(3, float) +linfnorm = num.zeros(3, float) +recv_norm = num.zeros(3, float) + +#------------------------------------------------------------------------------ +# Evolution +#------------------------------------------------------------------------------ +if numprocs > 1: + if myid == 0 and verbose: print('PARALLEL EVOLVE') +else: + if verbose: print('SEQUENTIAL EVOLVE') + +for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime): + edges = domain.quantities[quantity].edge_values.take(num.flatnonzero(domain.tri_full_flag),axis=0) + l1norm[0] = l1_norm(edges[:,0]) + l1norm[1] = l1_norm(edges[:,1]) + l1norm[2] = l1_norm(edges[:,2]) + l2norm[0] = l2_norm(edges[:,0]) + l2norm[1] = l2_norm(edges[:,1]) + l2norm[2] = l2_norm(edges[:,2]) + linfnorm[0] = linf_norm(edges[:,0]) + linfnorm[1] = linf_norm(edges[:,1]) + linfnorm[2] = linf_norm(edges[:,2]) + if numprocs > 1: + l2norm[0] = pow(l2norm[0], 2) + l2norm[1] = pow(l2norm[1], 2) + l2norm[2] = pow(l2norm[2], 2) + if myid == 0: + #domain.write_time() + + #print edges[:,1] + for p in range(1, numprocs): + recv_norm = pypar.receive(p) + l1norm += recv_norm + recv_norm = pypar.receive(p) + l2norm += recv_norm + recv_norm = pypar.receive(p) + linfnorm[0] = max(linfnorm[0], recv_norm[0]) + linfnorm[1] = max(linfnorm[1], recv_norm[1]) + linfnorm[2] = max(linfnorm[2], recv_norm[2]) + + l2norm[0] = pow(l2norm[0], 0.5) + l2norm[1] = pow(l2norm[1], 0.5) + l2norm[2] = pow(l2norm[2], 0.5) + + l1list.append(l1norm) + l2list.append(l2norm) + linflist.append(linfnorm) + else: + pypar.send(l1norm, 0) + pypar.send(l2norm, 0) + pypar.send(linfnorm, 0) + else: + #domain.write_time() + l1list.append(l1norm) + l2list.append(l2norm) + linflist.append(linfnorm) + +# Store results in the appropriate file +if numprocs > 1: + fid = open('distribute_domain_parallel.txt', 'w') +else: + fid = open('distribute_domain_sequential.txt', 'w') + +#fid.write( +print(l1list, l2list, linflist) +print(len(l1list), len(l2list), len(linflist)) + +for i in range(len(l1list)): + fid.write('%f %f %f %f %f %f %f %f %f\n' % (l1list[i][0], l1list[i][1], l1list[i][2], + l2list[i][0], l2list[i][1], l2list[i][2], + linflist[i][0], linflist[i][1], linflist[i][2])) + +fid.close() diff --git a/anuga/parallel/tests/run_parallel_riverwall.py b/anuga/parallel/tests/run_parallel_riverwall.py new file mode 100644 index 000000000..45a3366d0 --- /dev/null +++ b/anuga/parallel/tests/run_parallel_riverwall.py @@ -0,0 +1,132 @@ +"""Run riverwall simulation (sequentially or in parallel) to support test_parallel_riverwall.py +""" + +# ------------------------ +# Import necessary modules +# ------------------------ +from math import exp +from anuga import create_mesh_from_regions, create_domain_from_file +from anuga import Reflective_boundary, Transmissive_momentum_set_stage_boundary +from anuga import myid, distribute, barrier, numprocs, finalize + +verbose = False + +alg = 'DE0' +scale_me = 1.0 +mesh_filename = 'riverwall.msh' + +# ----------- +# Set up mesh +# ----------- +boundaryPolygon = [[0., 0.], [0., 100.], [100.0, 100.0], [100.0, 0.0]] +midResPolygon = [[30., 30.], [30., 70.], [70., 70.], [70., 30.]] +higherResPolygon = [[40., 40.], [40., 60.], [60., 60.], [60., 40.]] + +# Riverwall = list of lists, each with a set of x,y,z +# (and optional QFactor) values +riverWall = {'centralWall': + [[50., 0.0, -0.0], + [50., 45., -0.0], + [50., 46., -0.2], + [50., 100.0, -0.0]] + } + +riverWall_Par = {'centralWall': {'Qfactor': 1.0}} + +# The boundary polygon + riverwall breaks the mesh into multiple regions +# Must define the resolution in these areas with an xy point + maximum area +# Otherwise triangle.c gets confused +regionPtAreas = [[99., 99., 10.0*10.0*0.5], + [1., 1., 10.0*10.0*0.5], + [45., 45., 1.0*1.0*0.5], + [55., 55., 1.0*1.0*0.5], + [65., 65., 3.0*3.0*0.5], + [35., 35., 3.0*3.0*0.5]] + +# -------------------------------------------------------------------------- +# Setup computational domain and quantities +# -------------------------------------------------------------------------- +if myid == 0: + create_mesh_from_regions(boundaryPolygon, + boundary_tags={'left': [0], + 'top': [1], + 'right': [2], + 'bottom': [3]}, + maximum_triangle_area=1.0e+20, + minimum_triangle_angle=28.0, + filename=mesh_filename, + interior_regions=[[higherResPolygon, 1.*1.*0.5], + [midResPolygon, 3.0*3.0*0.5]], + breaklines=list(riverWall.values()), + use_cache=False, + verbose=verbose, + regionPtArea=regionPtAreas) + + base_domain = create_domain_from_file(mesh_filename) + base_domain.set_flow_algorithm(alg) + base_domain.set_datadir('.') + base_domain.set_store_vertices_uniquely() + + # ---------------------------------------- + # Define topography and initial conditions + # ---------------------------------------- + def topography(x, y): + return -x/150. * scale_me + + def stagefun(x, y): + stg = -0.5 * scale_me + return stg + + base_domain.set_quantity('elevation', topography) + base_domain.set_quantity('friction', 0.03) + base_domain.set_quantity('stage', stagefun) +else: + base_domain = None + + +# ---------------------------------------------- +# Decide if this is a sequential or parallel run +# ---------------------------------------------- +if numprocs == 1: + # This is a sequential run + domain = base_domain + domain.set_name('s_riverwall') +else: + # This is a parallel run + domain = distribute(base_domain, verbose=verbose) + domain.set_name('p_riverwall') +domain.set_store_vertices_uniquely() +domain.riverwallData.create_riverwalls(riverWall, + riverWall_Par, + verbose=verbose) + +# ------------------------- +# Setup boundary conditions +# ------------------------- +Br = Reflective_boundary(domain) # Solid reflective wall + + +def boundaryFun(t): + output = -0.4 * exp(-t/100.) - 0.1 + output = min(output, -0.11) + return output + + +Bin_tmss = Transmissive_momentum_set_stage_boundary(domain=domain, + function=boundaryFun) + +# --------------------------------------------- +# Associate boundary tags with boundary objects +# --------------------------------------------- +domain.set_boundary({'left': Br, 'right': Bin_tmss, 'top': Br, 'bottom': Br}) + +# ------------------------------ +# Evolve the system through time +# ------------------------------ +for t in domain.evolve(yieldstep=10.0, finaltime=150.0): + if myid == 0 and verbose: + print(domain.timestepping_statistics()) + +# Wrap up parallel matters if required. +domain.sww_merge(delete_old=True) +finalize() diff --git a/anuga/parallel/tests/run_parallel_shallow_domain.py b/anuga/parallel/tests/run_parallel_shallow_domain.py new file mode 100644 index 000000000..2a08b2fb7 --- /dev/null +++ b/anuga/parallel/tests/run_parallel_shallow_domain.py @@ -0,0 +1,85 @@ +import os + +#------------------------------------------ +# anuga imports +#------------------------------------------ +import anuga + +from anuga.utilities.system_tools import get_pathname_from_package + +from anuga import Domain +from anuga import Reflective_boundary +from anuga import Dirichlet_boundary +from anuga import Time_boundary +from anuga import Transmissive_boundary + +from anuga import rectangular_cross +from anuga import create_domain_from_file + +from anuga import distribute, myid, numprocs, finalize + +# ---------------- +# Setup parameters +# ---------------- + +mod_path = get_pathname_from_package('anuga.parallel') +mesh_filename = os.path.join(mod_path, 'data', 'merimbula_10785_1.tsh') +verbose = False + +# ---------------- +# Setup procedures +# ---------------- +class Set_Stage(object): + """Set an initial condition with constant water height, for x self.x0) & (x < self.x1)) + + +domain = create_domain_from_file(mesh_filename) +domain.set_quantity('stage', Set_Stage(756000.0, 756500.0, 2.0)) + +if numprocs > 1: + if myid == 0 and verbose: print('PARALLEL EVOLVE') + domain.set_name('shallow_water_parallel') +else: + if verbose: print('SEQUENTIAL EVOLVE') + domain.set_name('shallow_water_sequential') + + +# ----------------------------------- +# Create parallel domain if requested +# ----------------------------------- +if numprocs > 1: + if myid == 0 and verbose: print('DISTRIBUTING PARALLEL DOMAIN') + domain = distribute(domain) + +# -------------------------------------------------------------- +# Setup boundary conditions +# This must currently happen *after* domain has been distributed +# -------------------------------------------------------------- +Br = Reflective_boundary(domain) # Solid reflective wall - no movement + +domain.set_boundary({'outflow': Br, 'inflow': Br, 'inner': Br, 'exterior': Br, 'open': Br}) + +# --------- +# Evolution +# --------- + +for t in domain.evolve(yieldstep=1.0, finaltime=2.0): + if myid == 0 and verbose: domain.write_time() + +# ------------------------------------ +# Wrap up parallel matters if required +# ------------------------------------ +domain.sww_merge(delete_old=True) +finalize() + + + diff --git a/anuga/parallel/tests/run_parallel_sw_flow.py b/anuga/parallel/tests/run_parallel_sw_flow.py new file mode 100644 index 000000000..0b93a859f --- /dev/null +++ b/anuga/parallel/tests/run_parallel_sw_flow.py @@ -0,0 +1,70 @@ +"""Run sw_flow simulation (sequentially or in parallel) to support + test_parallel_sw_flow.py +""" + +# ------------------------ +# Import necessary modules +# ------------------------ +from math import exp +from anuga import rectangular_cross_domain +from anuga import Reflective_boundary, Dirichlet_boundary +from anuga import myid, distribute, barrier, numprocs, finalize +import numpy as num + + +#----------------- +# Setup parameters +#----------------- +verbose = True + +#------------------------------------- +# Setup function for initial condition +#------------------------------------- +def topography(x, y): + return -x / 2 + +#------------------------------------------ +# Setup computational domain and quantities +#------------------------------------------ +domain = rectangular_cross_domain(29, 29) +domain.set_quantity('elevation', topography) # Use function for elevation +domain.set_quantity('friction', 0.0) # Constant friction +domain.set_quantity('stage', expression='elevation') # Dry initial stage + +#------------------------ +# Setup domain parameters +#------------------------ +domain.set_datadir('.') # Set output dir + +# ---------------------------------------------- +# Decide if this is a sequential or parallel run +# ---------------------------------------------- +if numprocs == 1: + # This is a sequential run + domain.set_name('sw_flow_sequential') +else: + # This is a parallel run + domain = distribute(domain, verbose=verbose) + domain.set_name('sw_flow_parallel') + +#--------------------------------------------------------------- +# Setup boundary conditions +# This must currently happen *AFTER* domain has been distributed +#--------------------------------------------------------------- +Br = Reflective_boundary(domain) # Solid reflective wall +Bd = Dirichlet_boundary([-0.2, 0., 0.]) # Constant boundary values + +# Associate boundary tags with boundary objects +domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br}) + +#--------------------------- +# Evolve system through time +#--------------------------- +for t in domain.evolve(yieldstep=0.25, finaltime=1.0): + if myid == 0 and verbose: domain.write_time() + +#------------------------------------- +# Wrap up parallel matters if required +#------------------------------------- +domain.sww_merge(delete_old=True) +finalize() diff --git a/anuga/parallel/tests/test_parallel_distribute_domain.py b/anuga/parallel/tests/test_parallel_distribute_domain.py index 63ddbc2d1..0bcfa8b17 100644 --- a/anuga/parallel/tests/test_parallel_distribute_domain.py +++ b/anuga/parallel/tests/test_parallel_distribute_domain.py @@ -1,245 +1,84 @@ - """Test a run of the sequential shallow water domain against a run of the parallel shallow water domain. WARNING: This assumes that the command to run jobs is mpiexec. Tested with MPICH and LAM (Ole) """ -from __future__ import print_function -from __future__ import division -#------------------------------------------------------------------------------ +# ------------------------ # Import necessary modules -#------------------------------------------------------------------------------ - -from builtins import range -from past.utils import old_div -from builtins import object -from future.utils import raise_ +# ------------------------ +import platform import unittest -import os -import sys - -from anuga.utilities.system_tools import get_pathname_from_package - import numpy as num +import os +import subprocess -from anuga.utilities import parallel_abstraction as pypar - -#------------------------------------------ -# anuga imports -#------------------------------------------ -import anuga - -from anuga.utilities.numerical_tools import ensure_numeric -from anuga.utilities.util_ext import double_precision -from anuga.utilities.norms import l1_norm, l2_norm, linf_norm - -from anuga import Domain -from anuga import Reflective_boundary -from anuga import Dirichlet_boundary -from anuga import Time_boundary -from anuga import Transmissive_boundary - -from anuga import rectangular_cross -from anuga import create_domain_from_file - - -from anuga.parallel import distribute, myid, numprocs, finalize - - -#-------------------------------------------------------------------------- -# Setup parameters -#-------------------------------------------------------------------------- - -mod_path = get_pathname_from_package('anuga.parallel') - -mesh_filename = os.path.join(mod_path,'data','merimbula_10785_1.tsh') -#mesh_filename = os.path.join(mod_path,'data','test-100.tsh') -yieldstep = 1 -finaltime = 20 -quantity = 'stage' -nprocs = 4 verbose = False -#-------------------------------------------------------------------------- -# Setup procedures -#-------------------------------------------------------------------------- -class Set_Stage(object): - """Set an initial condition with constant water height, for xself.x0)&(x 0: - # Verify that the quantity is being conserved across iterations. - assert_(abs(l1norm_seq[x][y] - l1norm_seq[x-1][y]) < tol) - assert_(abs(l2norm_seq[x][y] - l2norm_seq[x-1][y]) < tol) - assert_(abs(linfnorm_seq[x][y] - linfnorm_seq[x-1][y]) < tol) - assert_(abs(l1norm_par[x][y] - l1norm_par[x-1][y]) < tol) - assert_(abs(l2norm_par[x][y] - l2norm_par[x-1][y]) < tol) - assert_(abs(linfnorm_par[x][y] - linfnorm_par[x-1][y]) < tol) - - if verbose: print('Parallel test OK') - - - - finalize() + N = len(seq_values) + assert len(par_values) == N + + for i in range(N): + seq_nums = [float(x) for x in seq_values[i].split()] + par_nums = [float(x) for x in par_values[i].split()] + assert num.allclose(seq_nums, par_nums) + +if __name__ == "__main__": + runner = unittest.TextTestRunner() + suite = unittest.makeSuite(Test_parallel_distribute_domain, 'test') + runner.run(suite) diff --git a/anuga/parallel/tests/test_parallel_distribute_mesh.py b/anuga/parallel/tests/test_parallel_distribute_mesh.py index cb7187d95..6560d5301 100644 --- a/anuga/parallel/tests/test_parallel_distribute_mesh.py +++ b/anuga/parallel/tests/test_parallel_distribute_mesh.py @@ -28,7 +28,6 @@ import numpy as num from numpy import array -from numpy import int verbose = False diff --git a/anuga/parallel/tests/test_parallel_file_boundary.py b/anuga/parallel/tests/test_parallel_file_boundary.py index 19af99cd4..e599c16d7 100644 --- a/anuga/parallel/tests/test_parallel_file_boundary.py +++ b/anuga/parallel/tests/test_parallel_file_boundary.py @@ -86,16 +86,16 @@ def sequential_time_varying_file_boundary_sts(self): time_step_count = 65 time_step = 2. n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) - finaltime=num.float(time_step*(time_step_count-1)) - yieldstep=num.float(time_step) - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) - ua=10*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) - - times=num.arange(0., num.float(time_step_count*time_step), time_step) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) + finaltime=float(time_step*(time_step_count-1)) + yieldstep=float(time_step) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) + ua=10*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) + + times=num.arange(0., float(time_step_count*time_step), time_step) for i in range(n): #ha[i]+=num.sin(times) ha[i]+=old_div(times,finaltime) @@ -188,7 +188,7 @@ def sequential_time_varying_file_boundary_sts(self): domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br}) - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,float) if verbose: print("Evolving domain with file boundary condition") for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -206,7 +206,7 @@ def sequential_time_varying_file_boundary_sts(self): Bd = Time_boundary(domain=domain_drchlt, f=lambda t: [2.0+old_div(t,finaltime)+tide,220.+10.*tide+old_div(10.*t,finaltime),-220.-10.*tide-old_div(10.*t,finaltime)]) #Bd = Time_boundary(domain=domain_drchlt,f=lambda t: [2.0+num.sin(t)+tide,10.*(2+20.+num.sin(t)+tide),-10.*(2+20.+num.sin(t)+tide)]) domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) - temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_drchlt=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -251,14 +251,14 @@ def parallel_time_varying_file_boundary_sts(self): time_step_count = 65 time_step = 2 n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) - finaltime=num.float(time_step*(time_step_count-1)) - yieldstep=num.float(time_step) - gauge_depth=20*num.ones(n,num.float) - ha=2*num.ones((n,time_step_count),num.float) - ua=10*num.ones((n,time_step_count),num.float) - va=-10*num.ones((n,time_step_count),num.float) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) + finaltime=float(time_step*(time_step_count-1)) + yieldstep=float(time_step) + gauge_depth=20*num.ones(n,float) + ha=2*num.ones((n,time_step_count),float) + ua=10*num.ones((n,time_step_count),float) + va=-10*num.ones((n,time_step_count),float) times=num.arange(0, time_step_count*time_step, time_step) for i in range(n): diff --git a/anuga/parallel/tests/test_parallel_riverwall.py b/anuga/parallel/tests/test_parallel_riverwall.py index b0f27f84b..ece35e9f7 100644 --- a/anuga/parallel/tests/test_parallel_riverwall.py +++ b/anuga/parallel/tests/test_parallel_riverwall.py @@ -1,262 +1,72 @@ """ -Test parallel and sequential results of riverwall procedure +Test that parallel and sequential results of riverwall simulation are identical """ -from __future__ import print_function - #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ -from future.utils import raise_ +import platform import unittest -import os -import sys -import anuga import numpy as num +import os +import subprocess -from anuga import myid, finalize, distribute, barrier, numprocs - -import anuga.utilities.plot_utils as util - -from math import exp - - -alg = 'DE0' verbose = False -scale_me=1.0 -nprocs = 3 - -## Set up mesh -boundaryPolygon=[ [0., 0.], [0., 100.], [100.0, 100.0], [100.0, 0.0]] -midResPolygon=[ [30., 30.], [30., 70.], [70., 70.], [70., 30.]] -higherResPolygon=[ [40., 40.], [40., 60.], [60., 60.], [60., 40.]] -# Riverwall = list of lists, each with a set of x,y,z (and optional QFactor) values -riverWall={ 'centralWall': - [ [50., 0.0, -0.0], - [50., 45., -0.0], - [50., 46., -0.2], - [50., 54., -0.2], - [50., 55., -0.0], - [50., 100.0, -0.0]] - } - -riverWall_Par={'centralWall':{'Qfactor':1.0}} -# Try to avoid any shallow-water type solution -- becomes unstable -#riverWall_Par={'centralWall':{'Qfactor':1.0, 's1': 0.999, 's2':0.9999, 'h1':100, 'h2':150}} - -# The boundary polygon + riverwall breaks the mesh into multiple regions -# Must define the resolution in these areas with an xy point + maximum area -# Otherwise triangle.c gets confused -regionPtAreas=[ [99., 99., 10.0*10.0*0.5], - [1., 1., 10.0*10.0*0.5], - [45., 45., 1.0*1.0*0.5], - [55., 55., 1.0*1.0*0.5], - [65., 65., 3.0*3.0*0.5], - [35., 35., 3.0*3.0*0.5] ] - - - - - - -########################################################################### -# Setup Test -########################################################################## -def run_simulation(parallel=False, verbose=False): - - #-------------------------------------------------------------------------- - # Setup computational domain and quantities - #-------------------------------------------------------------------------- - if myid == 0: - anuga.create_mesh_from_regions(boundaryPolygon, - boundary_tags={'left': [0], - 'top': [1], - 'right': [2], - 'bottom': [3]}, - maximum_triangle_area = 1.0e+20, - minimum_triangle_angle = 28.0, - filename = 'runup.msh', - interior_regions = [ [higherResPolygon, 1.*1.*0.5], - [midResPolygon, 3.0*3.0*0.5]], - breaklines=list(riverWall.values()), - use_cache=False, - verbose=verbose, - regionPtArea=regionPtAreas) - - sdomain=anuga.create_domain_from_file('runup.msh') - - - sdomain.set_flow_algorithm(alg) - - - sdomain.set_name('s_riverwall') - sdomain.set_datadir('.') - sdomain.set_store_vertices_uniquely() - - #------------------ - # Define topography - #------------------ - - def topography(x,y): - return -x/150.*scale_me - - def stagefun(x,y): - stg=-0.5*scale_me - return stg - - sdomain.set_quantity('elevation',topography) # Use function for elevation - sdomain.set_quantity('friction',0.03) # Constant friction - sdomain.set_quantity('stage', stagefun) # Constant negative initial stage - else: - sdomain = None - - #-------------------------------------------------------------------------- - # Create the parallel domains - #-------------------------------------------------------------------------- - if parallel: - - if myid == 0 and verbose : print('DISTRIBUTING TO PARALLEL DOMAIN') - pdomain = distribute(sdomain, verbose=verbose) - pdomain.set_name('p_riverwall') - pdomain.set_store_vertices_uniquely() - - - if myid == 0 and verbose: - print(60*'=') - print('EVOLVING pdomain') - print(60*'=') - - setup_and_evolve(pdomain, verbose=verbose) - - barrier() - - if myid == 0: - if verbose: - print(60*'=') - print('EVOLVING sdomain') - print(60*'=') - setup_and_evolve(sdomain, verbose=verbose) - - barrier() - - #--------------------------------- - # Now compare the merged sww files - #--------------------------------- - if myid == 0: - if verbose: print('COMPARING SWW FILES') - - sdomain_v = util.get_output('s_riverwall.sww') - sdomain_c = util.get_centroids(sdomain_v) +# These must be the same as given in the run_file. +sequential_sww_file = 's_riverwall.sww' +parallel_sww_file = 'p_riverwall.sww' +mesh_file = 'riverwall.msh' - pdomain_v = util.get_output('p_riverwall.sww') - pdomain_c = util.get_centroids(pdomain_v) +class Test_parallel_riverwall(unittest.TestCase): + def setUp(self): + # Run the sequential and parallel simulations to produce sww files for comparison. + path = os.path.dirname(__file__) # Get folder where this script lives + run_filename = os.path.join(path, 'run_parallel_riverwall.py') - # Test some values against the original ordering - - if verbose: - - order = 0 - print('PDOMAIN CENTROID VALUES') - print(num.linalg.norm(sdomain_c.x-pdomain_c.x,ord=order)) - print(num.linalg.norm(sdomain_c.y-pdomain_c.y,ord=order)) - print(num.linalg.norm(sdomain_c.stage[-1]-pdomain_c.stage[-1],ord=order)) - print(num.linalg.norm(sdomain_c.xmom[-1]-pdomain_c.xmom[-1],ord=order)) - print(num.linalg.norm(sdomain_c.ymom[-1]-pdomain_c.ymom[-1],ord=order)) - print(num.linalg.norm(sdomain_c.xvel[-1]-pdomain_c.xvel[-1],ord=order)) - print(num.linalg.norm(sdomain_c.yvel[-1]-pdomain_c.yvel[-1],ord=order)) + #----------------------- + # First run sequentially + #----------------------- + cmd = 'python ' + run_filename + if verbose: + print(cmd) - assert num.allclose(sdomain_c.stage,pdomain_c.stage) - assert num.allclose(sdomain_c.xmom,pdomain_c.xmom) - assert num.allclose(sdomain_c.ymom,pdomain_c.ymom) - assert num.allclose(sdomain_c.xvel,pdomain_c.xvel) - assert num.allclose(sdomain_c.yvel,pdomain_c.yvel) - - assert num.allclose(sdomain_v.x,pdomain_v.x) - assert num.allclose(sdomain_v.y,pdomain_v.y) - - - import os - os.remove('s_riverwall.sww') - os.remove('p_riverwall.sww') - os.remove('runup.msh') - - - -def setup_and_evolve(domain, verbose=False): - - - domain.riverwallData.create_riverwalls(riverWall, riverWall_Par, verbose=verbose) - - #-------------------------- - # Setup boundary conditions - #-------------------------- - Br=anuga.Reflective_boundary(domain) # Solid reflective wall - - def boundaryFun(t): - output=-0.4*exp(-t/100.)-0.1 - output=min(output,-0.11) - #output=min(output,-0.3) - return output - - - Bin_tmss = anuga.Transmissive_momentum_set_stage_boundary(domain=domain, function = boundaryFun) - - #---------------------------------------------- - # Associate boundary tags with boundary objects - #---------------------------------------------- - domain.set_boundary({'left': Br, 'right': Bin_tmss, 'top': Br, 'bottom':Br}) - - - - #------------------------------ - #Evolve the system through time - #------------------------------ - if verbose: print('Evolve') - for t in domain.evolve(yieldstep=10.0,finaltime=150.0): - if myid == 0 and verbose: print(domain.timestepping_statistics()) - - domain.sww_merge(delete_old=True) - - - -# Test an nprocs-way run of the shallow water equations -# against the sequential code. - -class Test_parallel_riverwall(unittest.TestCase): - def test_parallel_riverwall(self): - if verbose : print("Expect this test to fail if not run from the parallel directory.") - - cmd = anuga.mpicmd(os.path.abspath(__file__)) - result = os.system(cmd) - assert_(result == 0) - -# Because we are doing assertions outside of the TestCase class -# the PyUnit defined assert_ function can't be used. -def assert_(condition, msg="Assertion Failed"): - if condition == False: - #pypar.finalize() - raise_(AssertionError, msg) - -if __name__=="__main__": - if numprocs == 1: - runner = unittest.TextTestRunner() - suite = unittest.makeSuite(Test_parallel_riverwall, 'test') - runner.run(suite) - else: - - #------------------------------------------ - # Run the code code and compare sequential - # and parallel values - #------------------------------------------ - if myid ==0 and verbose: print('PARALLEL START') - - from anuga.utilities.parallel_abstraction import global_except_hook - import sys - sys.excepthook = global_except_hook - - run_simulation(parallel=True, verbose=verbose) - finalize() - - + result = subprocess.run(cmd.split(), capture_output=True) + if result.returncode != 0: + print(result.stdout) + print(result.stderr) + raise Exception(result.stderr) + + #--------------------- + # Then run in parallel + #--------------------- + if platform.system() == 'Windows': + extra_options = ' ' + else: + # E.g. for Ubuntu Linux + extra_options = '--oversubscribe' + + cmd = 'mpiexec -np 3 ' + extra_options + ' python ' + run_filename + if verbose: + print(cmd) + + result = subprocess.run(cmd.split(), capture_output=True) + if result.returncode != 0: + print(result.stdout) + print(result.stderr) + raise Exception(result.stderr) + + def tearDown(self): + os.remove(sequential_sww_file) + os.remove(parallel_sww_file) + os.remove(mesh_file) + + def test_that_sequential_and_parallel_outputs_are_identical(self): + from anuga.file.sww import sww_files_are_equal + assert sww_files_are_equal(sequential_sww_file, parallel_sww_file) + +if __name__ == "__main__": + runner = unittest.TextTestRunner() + suite = unittest.makeSuite(Test_parallel_riverwall, 'test') + runner.run(suite) diff --git a/anuga/parallel/tests/test_parallel_shallow_domain.py b/anuga/parallel/tests/test_parallel_shallow_domain.py index 560a4d893..6ffc229c5 100644 --- a/anuga/parallel/tests/test_parallel_shallow_domain.py +++ b/anuga/parallel/tests/test_parallel_shallow_domain.py @@ -5,155 +5,70 @@ WARNING: This assumes that the command to run jobs is mpiexec. Tested with MPICH and LAM (Ole) """ -from __future__ import print_function -#------------------------------------------------------------------------------ +# ------------------------ # Import necessary modules -#------------------------------------------------------------------------------ - -from builtins import object -from future.utils import raise_ +# ------------------------ +import platform import unittest -import os -import sys - - - import numpy as num +import os +import subprocess -from anuga.utilities import parallel_abstraction as pypar - -#------------------------------------------ -# anuga imports -#------------------------------------------ -import anuga - -from anuga.utilities.numerical_tools import ensure_numeric -from anuga.utilities.util_ext import double_precision -from anuga.utilities.norms import l1_norm, l2_norm, linf_norm -from anuga.utilities.system_tools import get_pathname_from_package - -from anuga import Domain -from anuga import Reflective_boundary -from anuga import Dirichlet_boundary -from anuga import Time_boundary -from anuga import Transmissive_boundary - -from anuga import rectangular_cross -from anuga import create_domain_from_file - - -from anuga import distribute, myid, numprocs, finalize - - -#-------------------------------------------------------------------------- -# Setup parameters -#-------------------------------------------------------------------------- - -mod_path = get_pathname_from_package('anuga.parallel') - -mesh_filename = os.path.join(mod_path,'data','merimbula_10785_1.tsh') -#mesh_filename = os.path.join('..','data','test-100.tsh') -yieldstep = 1 -finaltime = 1 -quantity = 'stage' -nprocs = 3 verbose = False -#-------------------------------------------------------------------------- -# Setup procedures -#-------------------------------------------------------------------------- -class Set_Stage(object): - """Set an initial condition with constant water height, for xself.x0)&(x -1: - gauge_values[i].append(stage.centroid_values[tri_ids[i]]) - - - #---------------------------------------- - # Setup test arrays during sequential run - #---------------------------------------- - if not parallel: - G = [] - for i in range(4): - G.append(gauge_values[i]) - - success = True - - for i in range(4): - if tri_ids[i] > -1: - #print num.max(num.array(gauge_values[i])- num.array(G[i])) - success = success and num.allclose(gauge_values[i], G[i]) - - assert_(success) - - return G, interpolation_points +path = os.path.dirname(__file__) # Get folder where this script lives +run_filename = os.path.join(path, 'run_parallel_sw_flow.py') -# Test an nprocs-way run of the shallow water equations -# against the sequential code. +# These must be the same as given in the run_file. +sequential_sww_file = 'sw_flow_sequential.sww' +parallel_sww_file = 'sw_flow_parallel.sww' class Test_parallel_sw_flow(unittest.TestCase): - def test_parallel_sw_flow(self): - if verbose : print("Expect this test to fail if not run from the parallel directory.") - - cmd = anuga.mpicmd(os.path.abspath(__file__)) - result = os.system(cmd) - - assert_(result == 0) - -# Because we are doing assertions outside of the TestCase class -# the PyUnit defined assert_ function can't be used. -def assert_(condition, msg="Assertion Failed"): - if condition == False: - #pypar.finalize() - raise_(AssertionError, msg) - -if __name__=="__main__": - if numprocs == 1: - runner = unittest.TextTestRunner() - suite = unittest.makeSuite(Test_parallel_sw_flow, 'test') - runner.run(suite) - else: - - from anuga.utilities.parallel_abstraction import global_except_hook - import sys - sys.excepthook = global_except_hook - - #------------------------------------------ - # Run the sequential code on each processor - # and save results at 4 gauge stations to - # array G - #------------------------------------------ - barrier() - if myid == 0 and verbose: print('SEQUENTIAL START') - - G , interpolation_points = run_simulation(parallel=False,verbose=verbose) - G = num.array(G,num.float) - - barrier() + def setUp(self): + # Run the sequential and parallel simulations to produce sww files for comparison. + + # ---------------------- + # First run sequentially + # ---------------------- + cmd = 'python ' + run_filename + if verbose: + print(cmd) + + result = subprocess.run(cmd.split(), capture_output=True) + if result.returncode != 0: + print(result.stdout) + print(result.stderr) + raise Exception(result.stderr) + + # -------------------- + # Then run in parallel + # -------------------- + if platform.system() == 'Windows': + extra_options = ' ' + else: + # E.g. for Ubuntu Linux + extra_options = '--oversubscribe' + + cmd = 'mpiexec -np 3 ' + extra_options + ' python ' + run_filename + if verbose: + print(cmd) + + result = subprocess.run(cmd.split(), capture_output=True) + if result.returncode != 0: + print(result.stdout) + print(result.stderr) + raise Exception(result.stderr) + + def tearDown(self): + os.remove(sequential_sww_file) + os.remove(parallel_sww_file) + + def test_that_sequential_and_parallel_outputs_are_identical(self): + from anuga.file.sww import sww_files_are_equal + assert sww_files_are_equal(sequential_sww_file, parallel_sww_file) - #------------------------------------------ - # Run the code code and compare sequential - # results at 4 gauge stations - #------------------------------------------ - if myid ==0 and verbose: print('PARALLEL START') - - run_simulation(parallel=True, G=G, seq_interpolation_points = interpolation_points, verbose= verbose) - - finalize() - +if __name__ == "__main__": + runner = unittest.TextTestRunner() + suite = unittest.makeSuite(Test_parallel_sw_flow, 'test') + runner.run(suite) diff --git a/anuga/parallel/tests/test_parallel_sw_flow_de0.py b/anuga/parallel/tests/test_parallel_sw_flow_de0.py index fdb00fef2..34cfa36d3 100644 --- a/anuga/parallel/tests/test_parallel_sw_flow_de0.py +++ b/anuga/parallel/tests/test_parallel_sw_flow_de0.py @@ -207,7 +207,7 @@ def assert_(condition, msg="Assertion Failed"): if myid == 0 and verbose: print('SEQUENTIAL START') G , interpolation_points = run_simulation(parallel=False,verbose=verbose) - G = num.array(G,num.float) + G = num.array(G,float) barrier() diff --git a/anuga/parallel/tests/test_parallel_sw_flow_low_froude_0.py b/anuga/parallel/tests/test_parallel_sw_flow_low_froude_0.py index 792439010..6eeca3355 100644 --- a/anuga/parallel/tests/test_parallel_sw_flow_low_froude_0.py +++ b/anuga/parallel/tests/test_parallel_sw_flow_low_froude_0.py @@ -215,7 +215,7 @@ def assert_(condition, msg="Assertion Failed"): if myid == 0 and verbose: print('SEQUENTIAL START') G , interpolation_points = run_simulation(parallel=False,verbose=verbose) - G = num.array(G,num.float) + G = num.array(G,float) barrier() diff --git a/anuga/parallel/tests/test_parallel_sw_flow_low_froude_1.py b/anuga/parallel/tests/test_parallel_sw_flow_low_froude_1.py index 1b56510c0..7e0558a42 100644 --- a/anuga/parallel/tests/test_parallel_sw_flow_low_froude_1.py +++ b/anuga/parallel/tests/test_parallel_sw_flow_low_froude_1.py @@ -216,7 +216,7 @@ def assert_(condition, msg="Assertion Failed"): if myid == 0 and verbose: print('SEQUENTIAL START') G , interpolation_points = run_simulation(parallel=False,verbose=verbose) - G = num.array(G,num.float) + G = num.array(G,float) barrier() diff --git a/anuga/pmesh/mesh_interface.py b/anuga/pmesh/mesh_interface.py index 871c832ce..53685c6f7 100644 --- a/anuga/pmesh/mesh_interface.py +++ b/anuga/pmesh/mesh_interface.py @@ -194,7 +194,7 @@ def _create_mesh_from_regions(bounding_polygon, # (DSG) If polygons were classes caching would break in places. # Simple check - bounding_polygon = ensure_numeric(bounding_polygon, num.float) + bounding_polygon = ensure_numeric(bounding_polygon, float) msg = 'Bounding polygon must be a list of points or an Nx2 array' assert len(bounding_polygon.shape) == 2, msg assert bounding_polygon.shape[1] == 2, msg diff --git a/anuga/pmesh/mesh_quadtree.py b/anuga/pmesh/mesh_quadtree.py index 45d1d1ef5..f323d13fc 100644 --- a/anuga/pmesh/mesh_quadtree.py +++ b/anuga/pmesh/mesh_quadtree.py @@ -60,7 +60,7 @@ def set_extents(self): extents = AABB(*self.mesh.get_extent(absolute=True)) extents.grow(1.001) # To avoid round off error numextents = [extents.xmin, extents.xmax, extents.ymin, extents.ymax] - self.extents = num.array(numextents, num.float) + self.extents = num.array(numextents, float) #print self.extents def add_quad_tree(self): @@ -114,7 +114,7 @@ def search_fast(self, point): if not hasattr(self, 'root'): self.add_quad_tree() - point = ensure_numeric(point, num.float) + point = ensure_numeric(point, float) [found, sigma, index] = fitsmooth.individual_tree_search(self.root, point) diff --git a/anuga/pymetis_4/metis_ext.pyx b/anuga/pymetis_4/metis_ext.pyx index 31ddc3142..44fa50810 100644 --- a/anuga/pymetis_4/metis_ext.pyx +++ b/anuga/pymetis_4/metis_ext.pyx @@ -29,7 +29,7 @@ def partMeshNodal(int ne, int nn, object elements, int etype, int nparts): assert isinstance(elements,list) or isinstance(elements,np.ndarray), "elements must be a list or an array" - elem_arr = np.ascontiguousarray(np.array(elements, dtype=np.int)) + elem_arr = np.ascontiguousarray(np.array(elements, dtype=int)) if elem_arr.dtype == 'int64': elem_c_arr = malloc(elem_arr.shape[0] * sizeof(idxtype)) diff --git a/anuga/shallow_water/boundaries.py b/anuga/shallow_water/boundaries.py index 01d7139f4..1be8325fc 100644 --- a/anuga/shallow_water/boundaries.py +++ b/anuga/shallow_water/boundaries.py @@ -72,7 +72,7 @@ def __init__(self, domain=None): self.ymom = domain.quantities['ymomentum'].edge_values self.normals = domain.normals - self.conserved_quantities = num.zeros(3, num.float) + self.conserved_quantities = num.zeros(3, float) def __repr__(self): return 'Reflective_boundary' @@ -782,7 +782,7 @@ def evaluate(self, vol_id, edge_id): elevation = z[edge_id] # Assign conserved quantities and return - q = num.array([elevation + depth, xmomentum, ymomentum], num.float) + q = num.array([elevation + depth, xmomentum, ymomentum], float) return q diff --git a/anuga/shallow_water/forcing.py b/anuga/shallow_water/forcing.py index 5b1a31a06..3368daa66 100644 --- a/anuga/shallow_water/forcing.py +++ b/anuga/shallow_water/forcing.py @@ -41,8 +41,8 @@ def check_forcefield(f): if callable(f): N = 3 - x = num.ones(3, num.float) - y = num.ones(3, num.float) + x = num.ones(3, float) + y = num.ones(3, float) try: q = f(1.0, x=x, y=y) except Exception as e: @@ -51,7 +51,7 @@ def check_forcefield(f): raise Exception(msg) try: - q = num.array(q, num.float) + q = num.array(q, float) except: msg = ('Return value from vector function %s could not ' 'be converted into a numeric array of floats.\nSpecified ' @@ -182,7 +182,7 @@ def __call__(self, domain): else: # Assume s is a scalar try: - s_vec = self.speed * num.ones(N, num.float) + s_vec = self.speed * num.ones(N, float) except: msg = 'Speed must be either callable or a scalar: %s' %self.s raise Exception(msg) @@ -199,7 +199,7 @@ def __call__(self, domain): # Assume phi is a scalar try: - phi_vec = self.phi * num.ones(N, num.float) + phi_vec = self.phi * num.ones(N, float) except: msg = 'Angle must be either callable or a scalar: %s' %self.phi raise Exception(msg) @@ -915,13 +915,13 @@ def __call__(self, domain): if ( self.use_coordinates ): p_vec = self.pressure(t, xv[:,0], xv[:,1]) else: - p_vec=num.empty(N,num.float) + p_vec=num.empty(N,float) for i in range(N): p_vec[i]=self.pressure(t,i) else: # Assume s is a scalar try: - p_vec = self.pressure * num.ones(N, num.float) + p_vec = self.pressure * num.ones(N, float) except: msg = 'Pressure must be either callable or a scalar: %s' %self.s raise Exception(msg) @@ -1088,13 +1088,13 @@ def pressure(t,x,y): break N = domain.get_number_of_nodes() - self.prev_pressure_vertex_values=num.empty(N,num.float) - self.next_pressure_vertex_values=num.empty(N,num.float) + self.prev_pressure_vertex_values=num.empty(N,float) + self.next_pressure_vertex_values=num.empty(N,float) for i in range(N): self.prev_pressure_vertex_values[i]=self.pressure(self.file_time[self.index],i) self.next_pressure_vertex_values[i]=self.pressure(self.file_time[self.index+1],i) - self.p_vec=num.empty(N,num.float) + self.p_vec=num.empty(N,float) def __call__(self, domain): @@ -1265,18 +1265,18 @@ def angle(t,x,y): else: break - self.prev_windspeed_centroid_values=num.empty(N,num.float) - self.next_windspeed_centroid_values=num.empty(N,num.float) - self.prev_windangle_centroid_values=num.empty(N,num.float) - self.next_windangle_centroid_values=num.empty(N,num.float) + self.prev_windspeed_centroid_values=num.empty(N,float) + self.next_windspeed_centroid_values=num.empty(N,float) + self.prev_windangle_centroid_values=num.empty(N,float) + self.next_windangle_centroid_values=num.empty(N,float) for i in range(N): self.prev_windspeed_centroid_values[i]=self.speed(self.file_time[self.index],i) self.next_windspeed_centroid_values[i]=self.speed(self.file_time[self.index+1],i) self.prev_windangle_centroid_values[i]=self.phi(self.file_time[self.index],i) self.next_windangle_centroid_values[i]=self.phi(self.file_time[self.index+1],i) - self.s_vec=num.empty(N,num.float) - self.phi_vec=num.empty(N,num.float) + self.s_vec=num.empty(N,float) + self.phi_vec=num.empty(N,float) self.const = old_div(eta_w*rho_a,rho_w) diff --git a/anuga/shallow_water/shallow_water_domain.py b/anuga/shallow_water/shallow_water_domain.py index cab20e893..02f0e35b7 100644 --- a/anuga/shallow_water/shallow_water_domain.py +++ b/anuga/shallow_water/shallow_water_domain.py @@ -3286,7 +3286,7 @@ def depth_dependent_friction(domain, default_friction, # EHR this is outwardly inneficient but not obvious how to avoid # recreating each call?????? - wet_friction = num.zeros(len(domain), num.float) + wet_friction = num.zeros(len(domain), float) wet_friction[:] = default_n0 # Initially assign default_n0 to all array so # sure have no zeros values diff --git a/anuga/shallow_water/sww_interrogate.py b/anuga/shallow_water/sww_interrogate.py index 4e5a3323c..a6e21056e 100644 --- a/anuga/shallow_water/sww_interrogate.py +++ b/anuga/shallow_water/sww_interrogate.py @@ -518,12 +518,12 @@ def get_maximum_inundation_data(filename, polygon=None, time_interval=None, # Get the relevant quantities (Convert from single precison) try: - elevation = num.array(fid.variables['elevation_c'][:], num.float) - stage = num.array(fid.variables['stage_c'][:], num.float) + elevation = num.array(fid.variables['elevation_c'][:], float) + stage = num.array(fid.variables['stage_c'][:], float) found_c_values = True except: - elevation = num.array(fid.variables['elevation'][:], num.float) - stage = num.array(fid.variables['stage'][:], num.float) + elevation = num.array(fid.variables['elevation'][:], float) + stage = num.array(fid.variables['stage'][:], float) found_c_values = False if verbose: diff --git a/anuga/shallow_water/tests/test_data_manager.py b/anuga/shallow_water/tests/test_data_manager.py index 6fb80fb88..695be3c13 100644 --- a/anuga/shallow_water/tests/test_data_manager.py +++ b/anuga/shallow_water/tests/test_data_manager.py @@ -102,7 +102,7 @@ def setUp(self): ###################### #Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): @@ -680,14 +680,14 @@ def test_file_boundary_stsIV_sinewave_ordering(self): times_ref = num.arange(0, time_step_count*time_step, time_step) n=len(lat_long_points) - first_tstep=num.ones(n,num.int) - last_tstep=(time_step_count)*num.ones(n,num.int) + first_tstep=num.ones(n,int) + last_tstep=(time_step_count)*num.ones(n,int) - gauge_depth=20*num.ones(n,num.float) + gauge_depth=20*num.ones(n,float) - ha1=num.ones((n,time_step_count),num.float) - ua1=3.*num.ones((n,time_step_count),num.float) - va1=2.*num.ones((n,time_step_count),num.float) + ha1=num.ones((n,time_step_count),float) + ua1=3.*num.ones((n,time_step_count),float) + va1=2.*num.ones((n,time_step_count),float) for i in range(n): ha1[i]=num.sin(times_ref) @@ -795,7 +795,7 @@ def test_file_boundary_stsIV_sinewave_ordering(self): domain_fbound.set_boundary({'ocean': Bf,'otherocean': Br}) finaltime=time_step*(time_step_count-1) yieldstep=time_step - temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_fbound=num.zeros(int(old_div(finaltime,yieldstep))+1,float) for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, finaltime=finaltime, @@ -810,7 +810,7 @@ def test_file_boundary_stsIV_sinewave_ordering(self): function=lambda t: [num.sin(t)+tide,3.*(20.+num.sin(t)+tide),2.*(20.+num.sin(t)+tide)]) domain_time.set_boundary({'ocean': Bw,'otherocean': Br}) - temp_time=num.zeros(int(old_div(finaltime,yieldstep))+1,num.float) + temp_time=num.zeros(int(old_div(finaltime,yieldstep))+1,float) domain_time.set_starttime(domain_fbound.get_starttime()) diff --git a/anuga/shallow_water/tests/test_forcing.py b/anuga/shallow_water/tests/test_forcing.py index aa5c7a797..401c2e30c 100644 --- a/anuga/shallow_water/tests/test_forcing.py +++ b/anuga/shallow_water/tests/test_forcing.py @@ -92,8 +92,8 @@ def time_varying_speed(t, x, y): from math import exp, cos, pi - x = num.array(x,num.float) - y = num.array(y,num.float) + x = num.array(x,float) + y = num.array(y,float) N = len(x) s = 0*x #New array @@ -110,8 +110,8 @@ def time_varying_angle(t, x, y): """ from math import atan, pi - x = num.array(x,num.float) - y = num.array(y,num.float) + x = num.array(x,float) + y = num.array(y,float) N = len(x) a = 0 * x # New array @@ -128,8 +128,8 @@ def time_varying_pressure(t, x, y): """ from math import atan, pi - x = num.array(x,num.float) - y = num.array(y,num.float) + x = num.array(x,float) + y = num.array(y,float) N = len(x) p = 0 * x # New array @@ -196,7 +196,7 @@ def spatial_linear_varying_pressure(t, x, y): def grid_1d(x0,dx,nx): - x = num.empty(nx,dtype=num.float) + x = num.empty(nx,dtype=float) for i in range(nx): x[i]=x0+float(i)*dx return x @@ -205,8 +205,8 @@ def grid_1d(x0,dx,nx): def ndgrid(x,y): nx = len(x) ny = len(y) - X = num.empty(nx*ny,dtype=num.float) - Y = num.empty(nx*ny,dtype=num.float) + X = num.empty(nx*ny,dtype=float) + Y = num.empty(nx*ny,dtype=float) k=0 for i in range(nx): for j in range(ny): @@ -251,14 +251,14 @@ def write_wind_pressure_field_sts(self, [X,Y] = ndgrid(x,y) number_of_points = nrows*ncols - wind_speed = num.empty((number_of_timesteps,nrows*ncols),dtype=num.float) - wind_angle = num.empty((number_of_timesteps,nrows*ncols),dtype=num.float) + wind_speed = num.empty((number_of_timesteps,nrows*ncols),dtype=float) + wind_angle = num.empty((number_of_timesteps,nrows*ncols),dtype=float) barometric_pressure = num.empty((number_of_timesteps,nrows*ncols), - dtype=num.float) + dtype=float) if ( callable(speed) and callable(angle) and callable(pressure) ): - x = num.ones(3, num.float) - y = num.ones(3, num.float) + x = num.ones(3, float) + y = num.ones(3, float) try: s = speed(1.0, x=x, y=y) a = angle(1.0, x=x, y=y) @@ -812,7 +812,7 @@ def test_time_dependent_rainfall_restricted_by_polygon(self): assert num.allclose(domain.quantities['stage'].explicit_update[2:], 0) def test_time_dependent_rainfall_using_starttime(self): - rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float) + rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], float) a = [0.0, 0.0] b = [0.0, 2.0] @@ -859,7 +859,7 @@ def test_time_dependent_rainfall_using_starttime(self): assert num.allclose(domain.quantities['stage'].explicit_update[2:], 0) def test_absolute_time_dependent_rainfall_using_starttime(self): - rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float) + rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], float) a = [0.0, 0.0] b = [0.0, 2.0] @@ -915,7 +915,7 @@ def test_time_dependent_rainfall_using_georef(self): x0 = 314036.58727982 y0 = 6224951.2960092 - rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float) + rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], float) rainfall_poly += [x0, y0] a = [0.0, 0.0] @@ -973,7 +973,7 @@ def test_absolute_time_dependent_rainfall_using_georef(self): x0 = 314036.58727982 y0 = 6224951.2960092 - rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float) + rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], float) rainfall_poly += [x0, y0] a = [0.0, 0.0] @@ -1316,7 +1316,7 @@ def test_variable_windfield_from_file(self): len2=cellsize*(nrows-1), origin=(xllcorner,yllcorner)) - time=num.arange(0,10,1,num.float) + time=num.arange(0,10,1,float) eval_time=time[7]; domain = Domain(points, vertices, boundary) @@ -1327,7 +1327,7 @@ def test_variable_windfield_from_file(self): x=grid_1d(xllcorner,cellsize,ncols) y=grid_1d(yllcorner,cellsize,nrows) X,Y=num.meshgrid(x,y) - interpolation_points=num.empty((X.shape[0]*X.shape[1],2),num.float) + interpolation_points=num.empty((X.shape[0]*X.shape[1],2),float) k=0 for i in range(X.shape[0]): for j in range(X.shape[1]): @@ -1339,13 +1339,13 @@ def test_variable_windfield_from_file(self): interpolation_points[:,1]) k=0 - Z=num.empty((X.shape[0],X.shape[1]),num.float) + Z=num.empty((X.shape[0],X.shape[1]),float) for i in range(X.shape[0]): for j in range(X.shape[1]): Z[i,j]=z[k] k+=1 - Q=num.empty((time.shape[0],points.shape[0]),num.float) + Q=num.empty((time.shape[0],points.shape[0]),float) for i, t in enumerate(time): Q[i,:]=spatial_linear_varying_speed(t,points[:,0],points[:,1]) @@ -1357,7 +1357,7 @@ def test_variable_windfield_from_file(self): interpolation_points=interpolation_points, verbose=False) - V=num.empty((X.shape[0],X.shape[1]),num.float) + V=num.empty((X.shape[0],X.shape[1]),float) for k in range(len(interpolation_points)): assert num.allclose(I(eval_time,k),z[k]) V[k/X.shape[1],k%X.shape[1]]=I(eval_time,k) @@ -1467,7 +1467,7 @@ def test_variable_pressurefield_from_file(self): len2=cellsize*(nrows-1), origin=(xllcorner,yllcorner)) - time=num.arange(0,10,1,num.float) + time=num.arange(0,10,1,float) eval_time=time[7]; domain = Domain(points, vertices, boundary) @@ -1597,7 +1597,7 @@ def test_constant_wind_stress_from_file_evolve(self): domain.forcing_terms.append(W) valuesUsingFunction=num.empty((3,number_of_timesteps+1,midpoints.shape[0]), - num.float) + float) i=0 for t in domain.evolve(yieldstep=1, finaltime=number_of_timesteps*timestep): valuesUsingFunction[0,i]=domain.quantities['stage'].explicit_update @@ -1691,7 +1691,7 @@ def test_temporally_varying_wind_stress_from_file_evolve(self): domain.forcing_terms.append(W) valuesUsingFunction=num.empty((3,2*number_of_timesteps,midpoints.shape[0]), - num.float) + float) i=0 for t in domain.evolve(yieldstep=timestep/2., finaltime=(number_of_timesteps-1)*timestep): valuesUsingFunction[0,i]=domain.quantities['stage'].explicit_update @@ -1791,7 +1791,7 @@ def test_spatially_varying_wind_stress_from_file_evolve(self): domain.forcing_terms.append(W) valuesUsingFunction=num.empty((3,number_of_timesteps,midpoints.shape[0]), - num.float) + float) i=0 for t in domain.evolve(yieldstep=timestep, finaltime=(number_of_timesteps-1)*timestep): valuesUsingFunction[0,i]=domain.quantities['stage'].explicit_update @@ -1895,7 +1895,7 @@ def test_temporally_varying_pressure_stress_from_file_evolve(self): domain.forcing_terms.append(P) valuesUsingFunction=num.empty((3,2*number_of_timesteps,len(domain)), - num.float) + float) i=0 import time as timer t0=timer.time() @@ -1996,7 +1996,7 @@ def test_spatially_varying_pressure_stress_from_file_evolve(self): domain.forcing_terms.append(P) valuesUsingFunction=num.empty((3,number_of_timesteps,len(domain)), - num.float) + float) i=0 for t in domain.evolve(yieldstep=timestep, finaltime=(number_of_timesteps-1)*timestep): valuesUsingFunction[0,i]=domain.quantities['stage'].explicit_update diff --git a/anuga/shallow_water/tests/test_shallow_water_domain.py b/anuga/shallow_water/tests/test_shallow_water_domain.py index b79f0e3dc..d00ac57f9 100644 --- a/anuga/shallow_water/tests/test_shallow_water_domain.py +++ b/anuga/shallow_water/tests/test_shallow_water_domain.py @@ -139,7 +139,7 @@ def __call__(self, x, y): N = len(x) assert N == len(y) - z = num.zeros(N, num.float) + z = num.zeros(N, float) for i in range(N): z[i] = -x[i] / 2 # General slope @@ -230,7 +230,7 @@ def __call__(self, x, y): N = len(x) assert N == len(y) - z = num.zeros(N, num.float) + z = num.zeros(N, float) for i in range(N): z[i] = -x[i] # General slope @@ -294,10 +294,10 @@ def test_rotate(self): # Individual flux tests def test_flux_zero_case(self): - ql = num.zeros(3, num.float) - qr = num.zeros(3, num.float) - normal = num.zeros(2, num.float) - edgeflux = num.zeros(3, num.float) + ql = num.zeros(3, float) + qr = num.zeros(3, float) + normal = num.zeros(2, float) + edgeflux = num.zeros(3, float) zl = zr = 0. H0 = 1.0e-3 # As suggested in the manual @@ -312,7 +312,7 @@ def test_flux_constants(self): normal = num.array([1.,0]) ql = num.array([w, 0, 0]) qr = num.array([w, 0, 0]) - edgeflux = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) zl = zr = 0. h = w - (zl+zr) / 2 H0 = 0.0 @@ -342,7 +342,7 @@ def test_flux1(self): ql = num.array([-0.2, 2, 3]) qr = num.array([-0.2, 2, 3]) zl = zr = -0.5 - edgeflux = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) H0 = 0.0 @@ -359,7 +359,7 @@ def test_flux2(self): qr = num.array([-0.075, 2, 3]) zl = zr = -0.375 - edgeflux = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) H0 = 0.0 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) @@ -374,7 +374,7 @@ def test_flux3(self): qr = num.array([-0.075, 2, 3]) zl = zr = -0.375 - edgeflux = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) H0 = 0.0 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) @@ -389,7 +389,7 @@ def test_flux4(self): qr = num.array([-0.30683287, 0.1071986, 0.05930515]) zl = zr = -0.375 - edgeflux = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) H0 = 0.0 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) @@ -874,10 +874,10 @@ def test_compute_fluxes_structure_0(self): zl = zr = 0. # Assume flat bed - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 # Flux across right edge of volume 1 @@ -964,10 +964,10 @@ def test_compute_fluxes_structure_1(self): zl = zr = 0. # Assume flat bed - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 # Flux across right edge of volume 1 @@ -1064,13 +1064,13 @@ def test_compute_fluxes_structure_2(self): val3 = 2. + 8.0/3 zl = zr = 0 # Assume flat zero bed - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 - domain.set_quantity('elevation', zl*num.ones((4, 3), num.int)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), int)) #array default# domain.set_quantity('stage', [[val0, val0-1, val0-2], [val1, val1+1, val1], @@ -1146,12 +1146,12 @@ def test_compute_fluxes_structure_3(self): val3 = 2.+8.0/3 zl = zr = -3.75 # Assume constant bed (must be less than stage) - domain.set_quantity('elevation', zl*num.ones((4, 3), num.float)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), float)) #array default# - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 domain.set_quantity('stage', [[val0, val0-1, val0-2], @@ -1241,10 +1241,10 @@ def test_compute_fluxes_old_0(self): zl = zr = 0. # Assume flat bed - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 # Flux across right edge of volume 1 @@ -1331,10 +1331,10 @@ def test_compute_fluxes_old_1(self): zl = zr = 0. # Assume flat bed - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 # Flux across right edge of volume 1 @@ -1429,13 +1429,13 @@ def test_compute_fluxes_old_2(self): val3 = 2. + 8.0/3 zl = zr = 0 # Assume flat zero bed - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 - domain.set_quantity('elevation', zl*num.ones((4, 3), num.int)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), int)) #array default# domain.set_quantity('stage', [[val0, val0-1, val0-2], [val1, val1+1, val1], @@ -1510,12 +1510,12 @@ def test_compute_fluxes_old_3(self): val3 = 2.+8.0/3 zl = zr = -3.75 # Assume constant bed (must be less than stage) - domain.set_quantity('elevation', zl*num.ones((4, 3), num.int)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), int)) #array default# - edgeflux = num.zeros(3, num.float) - edgeflux0 = num.zeros(3, num.float) - edgeflux1 = num.zeros(3, num.float) - edgeflux2 = num.zeros(3, num.float) + edgeflux = num.zeros(3, float) + edgeflux0 = num.zeros(3, float) + edgeflux1 = num.zeros(3, float) + edgeflux2 = num.zeros(3, float) H0 = 0.0 domain.set_quantity('stage', [[val0, val0-1, val0-2], @@ -1590,7 +1590,7 @@ def xtest_catching_negative_heights(self): val3 = 2. + 8.0/3 zl = zr = 4 # Too large - domain.set_quantity('elevation', zl*num.ones((4, 3), num.int)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), int)) #array default# domain.set_quantity('stage', [[val0, val0-1, val0-2], [val1, val1+1, val1], [val2, val2-2, val2], @@ -1622,7 +1622,7 @@ def test_get_wet_elements(self): val3 = 2. + 8.0/3 zl = zr = 5 - domain.set_quantity('elevation', zl*num.ones((4, 3), num.int)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), int)) #array default# domain.set_quantity('stage', [[val0, val0-1, val0-2], [val1, val1+1, val1], [val2, val2-2, val2], @@ -3563,7 +3563,7 @@ def test_first_order_extrapolator_const_z(self): val3 = 2. + 8.0/3 zl = zr = -3.75 # Assume constant bed (must be less than stage) - domain.set_quantity('elevation', zl*num.ones((4, 3), num.int)) #array default# + domain.set_quantity('elevation', zl*num.ones((4, 3), int)) #array default# domain.set_quantity('stage', [[val0, val0-1, val0-2], [val1, val1+1, val1], [val2, val2-2, val2], @@ -5083,7 +5083,7 @@ def test_flatbed_second_order_distribute(self): for V in [False, True]: if V: # Set centroids as if system had been evolved - L = num.zeros(2*N*N, num.float) + L = num.zeros(2*N*N, float) L[:32] = [7.21205592e-003, 5.35214298e-002, 1.00910824e-002, 5.35439433e-002, 1.00910824e-002, 5.35439433e-002, 1.00910824e-002, 5.35439433e-002, 1.00910824e-002, @@ -5096,7 +5096,7 @@ def test_flatbed_second_order_distribute(self): 4.37962142e-005, 0.00000000e+000, 4.37962142e-005, 0.00000000e+000, 5.57305948e-005] - X = num.zeros(2*N*N, num.float) + X = num.zeros(2*N*N, float) X[:32] = [6.48351607e-003, 3.68571894e-002, 8.50733285e-003, 3.68731327e-002, 8.50733285e-003, 3.68731327e-002, 8.50733285e-003, 3.68731327e-002, 8.50733285e-003, @@ -5109,7 +5109,7 @@ def test_flatbed_second_order_distribute(self): 3.58905503e-005, 0.00000000e+000, 3.58905503e-005, 0.00000000e+000, 4.57662812e-005] - Y = num.zeros(2*N*N, num.float) + Y = num.zeros(2*N*N, float) Y[:32] = [-1.39463104e-003, 6.15600298e-004, -6.03637382e-004, 6.18272251e-004, -6.03637382e-004, 6.18272251e-004, -6.03637382e-004, 6.18272251e-004, -6.03637382e-004, @@ -6765,7 +6765,7 @@ def test_tight_slope_limiters(self): # Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.3 for i in range(stage.shape[0]): @@ -8477,7 +8477,7 @@ def test_vertex_values_no_smoothing(self): #Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.03 for i in range(stage.shape[0]): @@ -8550,7 +8550,7 @@ def test_smoothing_1_5(self): # Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.03 for i in range(stage.shape[0]): @@ -8636,7 +8636,7 @@ def test_smoothing_de0(self): # Initial condition - with jumps bed = domain.quantities['elevation'].vertex_values - stage = num.zeros(bed.shape, num.float) + stage = num.zeros(bed.shape, float) h = 0.03 for i in range(stage.shape[0]): diff --git a/anuga/shallow_water/tests/test_sww_interrogate.py b/anuga/shallow_water/tests/test_sww_interrogate.py index cd3960836..31fe5fa0f 100644 --- a/anuga/shallow_water/tests/test_sww_interrogate.py +++ b/anuga/shallow_water/tests/test_sww_interrogate.py @@ -216,7 +216,7 @@ def test_get_maximum_inundation_de0(self): #assert num.allclose(max_time, 45.0) # Check runup restricted to a polygon - p = num.array([[50,1], [99,1], [99,40], [50,40]], num.int) + num.array([E, N], num.int) + p = num.array([[50,1], [99,1], [99,40], [50,40]], int) + num.array([E, N], int) runup, location = get_maximum_inundation_data(swwfile, polygon=p) if verbose: print('Runup, location:',runup, location, max_time) @@ -381,7 +381,7 @@ def test_get_maximum_inundation_1_5(self): assert num.allclose(location[0], 61.66+E) # Check runup restricted to a polygon - p = num.array([[50,1], [99,1], [99,49], [50,49]], num.int) + num.array([E, N], num.int) #array default# + p = num.array([[50,1], [99,1], [99,49], [50,49]], int) + num.array([E, N], int) #array default# runup = get_maximum_inundation_elevation(swwfile, polygon=p) location = get_maximum_inundation_location(swwfile, polygon=p) diff --git a/anuga/tsunami_source/eqf_v2.py b/anuga/tsunami_source/eqf_v2.py index 74d0a9b20..83e761a1a 100644 --- a/anuga/tsunami_source/eqf_v2.py +++ b/anuga/tsunami_source/eqf_v2.py @@ -154,7 +154,7 @@ def __call__(self, x, y): # f2py -c okada.f -m okada #z1 = okada(xr,yr,depth,length,width,dip,rake,slip) - z2 = num.zeros(N, num.float) + z2 = num.zeros(N, float) alp = 0.5 disl3 = 0.0 zero = 0.0 @@ -197,8 +197,8 @@ def SRECTF(self,ALP,X,Y,DEP,AL1,AL2,AW1,AW2,SD,CD,DISL1,DISL2,DISL3): SUBROUTINE USED...SRECTG """ - U = num.zeros(9, num.float) - DU = num.zeros(9, num.float) + U = num.zeros(9, float) + DU = num.zeros(9, float) F0 = 0.0 F1 = 1.0 diff --git a/anuga/tsunami_source/smf.py b/anuga/tsunami_source/smf.py index 964455f85..a75848804 100644 --- a/anuga/tsunami_source/smf.py +++ b/anuga/tsunami_source/smf.py @@ -431,7 +431,7 @@ def __call__(self, x, y): xr = ((x-x0) * cosa - (y-y0) * sina) + x0 yr = ((x-x0) * sina + (y-y0) * cosa) + y0 - z = num.zeros(N, num.float) + z = num.zeros(N, float) maxz = 0.0 minz = 0.0 for i in range(N): diff --git a/anuga/tsunami_source/tsunami_okada.py b/anuga/tsunami_source/tsunami_okada.py index fa246fecd..996037f26 100644 --- a/anuga/tsunami_source/tsunami_okada.py +++ b/anuga/tsunami_source/tsunami_okada.py @@ -52,8 +52,8 @@ def earthquake_tsunami(ns, NSMAX, length, width, strike, depth, zrec0.set_values(z0) zrec = zrec0.get_vertex_values(xy=True) - x0 = num.zeros(ns, num.float) - y0 = num.zeros(ns, num.float) + x0 = num.zeros(ns, float) + y0 = num.zeros(ns, float) if ns == 1: x0[0] = xi y0[0] = yi @@ -160,24 +160,24 @@ def __call__(self, x, y): ns = self.ns zrec = self.zrec # initialization - disp0 = num.zeros(3, num.float) - strain0 = num.zeros(6, num.float) - tilt0 = num.zeros(2, num.float) - dislocations = num.zeros(ns, num.float) - depths = num.zeros(ns, num.float) - strikes = num.zeros(ns, num.float) - lengths = num.zeros(ns, num.float) - slips = num.zeros(ns, num.float) - rakes = num.zeros(ns, num.float) - widths = num.zeros(ns, num.float) - dips = num.zeros(ns, num.float) - strikes = num.zeros(ns, num.float) - strikes = num.zeros(ns, num.float) - strain = num.zeros((N, 6), num.float) - disp = num.zeros((N, 3), num.float) - tilt = num.zeros((N, 2), num.float) - xs = num.zeros(ns, num.float) - ys = num.zeros(ns, num.float) + disp0 = num.zeros(3, float) + strain0 = num.zeros(6, float) + tilt0 = num.zeros(2, float) + dislocations = num.zeros(ns, float) + depths = num.zeros(ns, float) + strikes = num.zeros(ns, float) + lengths = num.zeros(ns, float) + slips = num.zeros(ns, float) + rakes = num.zeros(ns, float) + widths = num.zeros(ns, float) + dips = num.zeros(ns, float) + strikes = num.zeros(ns, float) + strikes = num.zeros(ns, float) + strain = num.zeros((N, 6), float) + disp = num.zeros((N, 3), float) + tilt = num.zeros((N, 2), float) + xs = num.zeros(ns, float) + ys = num.zeros(ns, float) z = [] if ns == 1: dislocations[0] = dislocation @@ -384,10 +384,10 @@ def DC3D0(self, ALPHA, X, Y, Z, DEPTH, DIP, POT1, POT2, POT3, POT4): # DIMENSION U(12),DUA(12),DUB(12),DUC(12) F0 = 0.0 - U = num.zeros((12, 1), num.float) - DUA = num.zeros((12, 1), num.float) - DUB = num.zeros((12, 1), num.float) - DUC = num.zeros((12, 1), num.float) + U = num.zeros((12, 1), float) + DUA = num.zeros((12, 1), float) + DUB = num.zeros((12, 1), float) + DUC = num.zeros((12, 1), float) if Z > 0: print('(''0** POSITIVE Z WAS GIVEN IN SUB-DC3D0'')') @@ -532,9 +532,9 @@ def UA0(self, X, Y, D, POT1, POT2, POT3, POT4): VZ = self.VZ WZ = self.WZ - DUA = num.zeros((12, 1), num.float) - DU = num.zeros((12, 1), num.float) - U = num.zeros((12, 1), num.float) + DUA = num.zeros((12, 1), float) + DU = num.zeros((12, 1), float) + U = num.zeros((12, 1), float) # ----- for I in range(0, 12): U[I] = F0 @@ -649,9 +649,9 @@ def UB0(self, X, Y, D, Z, POT1, POT2, POT3, POT4): # * /0.D0,1.D0,2.D0,3.D0,4.D0,5.D0,8.D0,9.D0/ # DATA PI2/6.283185307179586D0/ - DUB = num.zeros((12, 1), num.float) - DU = num.zeros((12, 1), num.float) - U = num.zeros((12, 1), num.float) + DUB = num.zeros((12, 1), float) + DU = num.zeros((12, 1), float) + U = num.zeros((12, 1), float) F0 = 0.0 F1 = 1.0 @@ -822,9 +822,9 @@ def UC0(self, X, Y, D, Z, POT1, POT2, POT3, POT4): # * /0.D0,1.D0,2.D0,3.D0,5.D0,7.D0,10.D0,15.D0/ # DATA PI2/6.283185307179586D0/ - DUC = num.zeros((12, 1), num.float) - DU = num.zeros((12, 1), num.float) - U = num.zeros((12, 1), num.float) + DUC = num.zeros((12, 1), float) + DU = num.zeros((12, 1), float) + U = num.zeros((12, 1), float) F0 = 0.0 F1 = 1.0 @@ -1028,15 +1028,15 @@ def DC3D(self, ALPHA, X, Y, Z, DEPTH, DIP, AL1, AL2, AW1, AW2, DISL1, DISL2, DIS F0 = 0.0 EPS = 0.000001 - XI = num.zeros(2, num.float) - ET = num.zeros(2, num.float) - KXI = num.zeros(2, num.float) - KET = num.zeros(2, num.float) - U = num.zeros(12, num.float) - DU = num.zeros(12, num.float) - DUA = num.zeros(12, num.float) - DUB = num.zeros(12, num.float) - DUC = num.zeros(12, num.float) + XI = num.zeros(2, float) + ET = num.zeros(2, float) + KXI = num.zeros(2, float) + KET = num.zeros(2, float) + U = num.zeros(12, float) + DU = num.zeros(12, float) + DUA = num.zeros(12, float) + DUB = num.zeros(12, float) + DUC = num.zeros(12, float) # ----- if Z > 0: @@ -1254,9 +1254,9 @@ def UA(self, XI, ET, Q, DISL1, DISL2, DISL3): # * EY,EZ,FY,FZ,GY,GZ,HY,HZ # DATA F0,F2,PI2/0.D0,2.D0,6.283185307179586D0/ - U = num.zeros(12, num.float) - DU = num.zeros(12, num.float) - DUA = num.zeros(12, num.float) + U = num.zeros(12, float) + DU = num.zeros(12, float) + DUA = num.zeros(12, float) F0 = 0.0 F2 = 2.0 PI2 = 6.283185307179586 @@ -1384,9 +1384,9 @@ def UB(self, XI, ET, Q, DISL1, DISL2, DISL3): # * EY,EZ,FY,FZ,GY,GZ,HY,HZ # DATA F0,F1,F2,PI2/0.D0,1.D0,2.D0,6.283185307179586D0/ - DUB = num.zeros(12, num.float) - DU = num.zeros(12, num.float) - U = num.zeros(12, num.float) + DUB = num.zeros(12, float) + DU = num.zeros(12, float) + U = num.zeros(12, float) F0 = 0.0 F1 = 1.0 @@ -1545,9 +1545,9 @@ def UC(self, XI, ET, Q, Z, DISL1, DISL2, DISL3): # * EY,EZ,FY,FZ,GY,GZ,HY,HZ # DATA F0,F1,F2,F3,PI2/0.D0,1.D0,2.D0,3.D0,6.283185307179586D0/ - DUC = num.zeros(12, num.float) - DU = num.zeros(12, num.float) - U = num.zeros(12, num.float) + DUC = num.zeros(12, float) + DU = num.zeros(12, float) + U = num.zeros(12, float) F0 = 0.0 F1 = 1.0 diff --git a/anuga/utilities/cg_solve.py b/anuga/utilities/cg_solve.py index 61873851f..bcb253ffe 100644 --- a/anuga/utilities/cg_solve.py +++ b/anuga/utilities/cg_solve.py @@ -65,11 +65,11 @@ def conjugate_gradient(A, b, x0=None, imax=10000, tol=1.0e-8, atol=1.0e-14, assert isinstance(A, Sparse_CSR), msg if x0 is None: - x0 = num.zeros(b.shape, dtype=num.float) + x0 = num.zeros(b.shape, dtype=float) else: - x0 = num.array(x0, dtype=num.float) + x0 = num.array(x0, dtype=float) - b = num.array(b, dtype=num.float) + b = num.array(b, dtype=float) err = 0 @@ -160,15 +160,15 @@ def _conjugate_gradient(A, b, x0, stats = Stats() - b = num.array(b, dtype=num.float) + b = num.array(b, dtype=float) if len(b.shape) != 1: raise VectorShapeError( 'input vector should consist of only one column') if x0 is None: - x0 = num.zeros(b.shape, dtype=num.float) + x0 = num.zeros(b.shape, dtype=float) else: - x0 = num.array(x0, dtype=num.float) + x0 = num.array(x0, dtype=float) stats.x0 = num.linalg.norm(x0) @@ -266,15 +266,15 @@ def _conjugate_gradient_preconditioned(A, b, x0, M, stats = Stats() - b = num.array(b, dtype=num.float) + b = num.array(b, dtype=float) if len(b.shape) != 1: raise VectorShapeError( 'input vector should consist of only one column') if x0 is None: - x0 = num.zeros(b.shape, dtype=num.float) + x0 = num.zeros(b.shape, dtype=float) else: - x0 = num.array(x0, dtype=num.float) + x0 = num.array(x0, dtype=float) stats.x0 = num.linalg.norm(x0) diff --git a/anuga/utilities/log.py b/anuga/utilities/log.py index 84a663361..ae8e2e7fa 100644 --- a/anuga/utilities/log.py +++ b/anuga/utilities/log.py @@ -410,7 +410,7 @@ def test_it(num=100): import numpy as num - a = num.zeros((1000,1000), num.float) + a = num.zeros((1000,1000), float) info('sys.version_info=%s, _new_python=%s' % (str(sys.version_info), str(_new_python))) diff --git a/anuga/utilities/numerical_tools.py b/anuga/utilities/numerical_tools.py index 52217022c..43db833a0 100644 --- a/anuga/utilities/numerical_tools.py +++ b/anuga/utilities/numerical_tools.py @@ -70,8 +70,8 @@ def angle(v1, v2=None): if v2 is None: v2 = [1.0, 0.0] # Unit vector along the x-axis - v1 = ensure_numeric(v1, num.float) - v2 = ensure_numeric(v2, num.float) + v1 = ensure_numeric(v1, float) + v2 = ensure_numeric(v2, float) # Normalise v1 = v1/num.sqrt(num.sum(v1**2)) @@ -121,7 +121,7 @@ def normal_vector(v): Returns vector 90 degrees counter clockwise to and of same length as v """ - return num.array([-v[1], v[0]], num.float) + return num.array([-v[1], v[0]], float) #def crossproduct_length(v1, v2): @@ -242,7 +242,7 @@ def ensure_numeric(A, typecode=None): typecode: numeric type. If specified, use this in the conversion. If not, let numpy package decide. - typecode will always be one of num.float, num.int, etc. + typecode will always be one of float, int, etc. Note that num.array(A, dtype) will sometimes copy. Use 'copy=False' to copy only when required. diff --git a/anuga/utilities/parallel_abstraction.py b/anuga/utilities/parallel_abstraction.py index 3d11855a7..f1fee2ffc 100644 --- a/anuga/utilities/parallel_abstraction.py +++ b/anuga/utilities/parallel_abstraction.py @@ -100,7 +100,7 @@ def send_recv_via_dicts(*args, **kwargs): MAXLOC = MPI.MAXLOC MINLOC = MPI.MINLOC mpiWrapper = 'mpi4py' - MAX_COMBUF = 10 + #MAX_COMBUF = 15 class Status(object): """ Simulate pypar return_status object @@ -233,7 +233,7 @@ def scatter(x, root, buffer=None, vanilla=False): def send(x, destination, use_buffer=False, vanilla=False, tag=1, bypass=False): - """ This wrap uses Send for sendig if bypass is True, else send + """ This wrap uses Send for sending if bypass is True, else send """ if bypass: comm.Send(np.ascontiguousarray(x), dest=destination, tag=tag) @@ -247,18 +247,19 @@ def send_recv_via_dicts(sendDict, recvDict): """ This wrap uses Irecv and Isend for exchanging numpy arrays stored in dicts. """ - if len(recvDict) > MAX_COMBUF: - raise ValueError( - "send_recv_via_dicts: Number of recv communication buffers > %d" % - MAX_COMBUF) - if len(sendDict) > MAX_COMBUF: - raise ValueError( - "send_recv_via_dicts: Number of send communication buffers > %d" % - MAX_COMBUF) - requests = [] - if len(recvDict) != len(sendDict): - raise NotImplementedError("len(recvDict) != len(sendDict): %d %d" % - len(recvDict), len(sendDict)) + + # if len(recvDict) > MAX_COMBUF: + # raise ValueError( + # "send_recv_via_dicts: Requested number of recv communication buffers %d > %d" % + # (len(recvDict), MAX_COMBUF) ) + # if len(sendDict) > MAX_COMBUF: + # raise ValueError( + # "send_recv_via_dicts: Requested number of send communication buffers %d > %d" % + # (len(sendDict), MAX_COMBUF) ) + # if len(recvDict) != len(sendDict): + # raise NotImplementedError("len(recvDict) != len(sendDict): %d %d" % + # len(recvDict), len(sendDict)) + skeys = list(sendDict.keys()) skeys.sort() diff --git a/anuga/utilities/plot_utils.py b/anuga/utilities/plot_utils.py index 1ed2e4dad..66730f041 100644 --- a/anuga/utilities/plot_utils.py +++ b/anuga/utilities/plot_utils.py @@ -141,6 +141,8 @@ def sort_sww_filenames(sww_wildcard): return list(output_names) ##################################################################### + +# FIXME (Ole): We should move this to e.g. the module sww.py as it has nothing to do with plotting ;-) class get_output(object): """Read in data from an .sww file in a convenient form e.g. @@ -154,7 +156,7 @@ def __init__(self, filename, minimum_allowed_height=1.0e-03, timeSlices='all', v self.height, self.elev, self.friction, self.xmom, self.ymom, \ self.xvel, self.yvel, self.vel, self.minimum_allowed_height,\ self.xllcorner, self.yllcorner, self.timeSlices, self.starttime = \ - _read_output(filename, minimum_allowed_height,copy.copy(timeSlices)) + _read_output(filename, minimum_allowed_height, copy.copy(timeSlices)) self.filename = filename self.verbose = verbose @@ -185,11 +187,11 @@ def getInds(varIn, timeSlices, absMax=False): else: # For variables xmom,ymom,xvel,yvel we want the 'maximum-absolute-value' varInds = abs(varIn[:]).argmax(axis=0) - varNew = varInds*0. + varNew = varInds * 0. for i in range(len(varInds)): - varNew[i] = varIn[varInds[i],i] + varNew[i] = varIn[varInds[i], i] var = varNew - var=var.reshape((1,len(var))) + var=var.reshape((1, len(var))) else: var = numpy.zeros((len(timeSlices), varIn.shape[1]), dtype='float32') for i in range(len(timeSlices)): @@ -231,47 +233,47 @@ def _read_output(filename, minimum_allowed_height, timeSlices): time=fid.variables['time'][:] # Treat specification of timeSlices - if(timeSlices=='all'): - inds=list(range(len(time))) - elif(timeSlices=='last'): - inds=[len(time)-1] - elif(timeSlices=='max'): - inds='max' # + if(timeSlices == 'all'): + inds = list(range(len(time))) + elif(timeSlices == 'last'): + inds = [len(time)-1] + elif(timeSlices == 'max'): + inds = 'max' # else: try: - inds=list(timeSlices) + inds = list(timeSlices) except: - inds=[timeSlices] + inds = [timeSlices] if(inds != 'max'): - time=time[inds] + time = time[inds] else: # We can't really assign a time to 'max', but I guess max(time) is # technically the right thing -- if not misleading - time=time.max() + time = time.max() # Get lower-left - xllcorner=fid.xllcorner - yllcorner=fid.yllcorner - starttime=fid.starttime + xllcorner = fid.xllcorner + yllcorner = fid.yllcorner + starttime = fid.starttime # Read variables - x=fid.variables['x'][:] - y=fid.variables['y'][:] + x = fid.variables['x'][:] + y = fid.variables['y'][:] - stage=getInds(fid.variables['stage'], timeSlices=inds) - elev=getInds(fid.variables['elevation'], timeSlices=inds) + stage = getInds(fid.variables['stage'], timeSlices=inds) + elev = getInds(fid.variables['elevation'], timeSlices=inds) # Simple approach for volumes - vols=fid.variables['volumes'][:] + vols = fid.variables['volumes'][:] # Friction if it exists if('friction' in fid.variables): - friction=getInds(fid.variables['friction'],timeSlices=inds) + friction=getInds(fid.variables['friction'], timeSlices=inds) else: # Set friction to nan if it is not stored - friction = elev*0.+numpy.nan + friction = elev * 0. + numpy.nan # Trick to treat the case where inds == 'max' inds2 = copy.copy(inds) @@ -449,29 +451,29 @@ def _get_centroid_values(p, velocity_extrapolation, verbose, timeSlices, # Figure out if p is a string (filename) or the output of get_output pIsFile = isinstance(p, str) if(pIsFile): - fid=NetCDFFile(p) + fid = NetCDFFile(p) else: - fid=NetCDFFile(p.filename) + fid = NetCDFFile(p.filename) # UPDATE: 15/06/2014 -- below, we now get all variables directly from the file # This is more flexible, and allows to get 'max' as well # However, potentially it could have performance penalities vs the old approach (?) # Make 3 arrays, each containing one index of a vertex of every triangle. - vols=fid.variables['volumes'][:] - vols0=vols[:,0] - vols1=vols[:,1] - vols2=vols[:,2] + vols = fid.variables['volumes'][:] + vols0 = vols[:,0] + vols1 = vols[:,1] + vols2 = vols[:,2] # Get lower-left offset - xllcorner=fid.xllcorner - yllcorner=fid.yllcorner + xllcorner = fid.xllcorner + yllcorner = fid.yllcorner #@ Get timeSlices # It will be either a list of integers, or 'max' - l=len(vols) - time=fid.variables['time'][:] - nts=len(time) # number of time slices in the file + l = len(vols) + time = fid.variables['time'][:] + nts = len(time) # number of time slices in the file if(timeSlices is None): if(pIsFile): # Assume all timeSlices @@ -493,30 +495,30 @@ def _get_centroid_values(p, velocity_extrapolation, verbose, timeSlices, minimum_allowed_height=copy.copy(p.minimum_allowed_height) # Treat specification of timeSlices - if(timeSlices=='all'): - inds=list(range(len(time))) + if(timeSlices == 'all'): + inds = list(range(len(time))) elif(timeSlices=='last'): - inds=[len(time)-1] + inds = [len(time)-1] elif(timeSlices=='max'): - inds='max' # + inds = 'max' # else: try: - inds=list(timeSlices) + inds = list(timeSlices) except: - inds=[timeSlices] + inds = [timeSlices] if(inds != 'max'): - time=time[inds] + time = time[inds] else: # We can't really assign a time to 'max', but I guess max(time) is # technically the right thing -- if not misleading - time=time.max() + time = time.max() # Get coordinates - x=fid.variables['x'][:] - y=fid.variables['y'][:] - x_cent=(x[vols0]+x[vols1]+x[vols2])/3.0 - y_cent=(y[vols0]+y[vols1]+y[vols2])/3.0 + x = fid.variables['x'][:] + y = fid.variables['y'][:] + x_cent = (x[vols0] + x[vols1] + x[vols2]) / 3.0 + y_cent = (y[vols0] + y[vols1] + y[vols2]) / 3.0 # Stage and height and elevation stage_cent = _getCentVar(fid, 'stage_c', time_indices=inds, vols=vols) @@ -525,15 +527,15 @@ def _get_centroid_values(p, velocity_extrapolation, verbose, timeSlices, # Hack to allow refernece to time varying elevation elev_cent_orig = elev_cent - if(len(elev_cent.shape)==2): + if(len(elev_cent.shape) == 2): # Coerce to 1D array, since lots of our code assumes it is - elev_cent=elev_cent[0,:] + elev_cent = elev_cent[0,:] # Friction might not be stored at all try: friction_cent = _getCentVar(fid, 'friction_c', time_indices=inds, vols=vols) except: - friction_cent=elev_cent*0.+numpy.nan + friction_cent = elev_cent*0.+numpy.nan # Trick to treat the case where inds == 'max' inds2 = copy.copy(inds) @@ -541,7 +543,7 @@ def _get_centroid_values(p, velocity_extrapolation, verbose, timeSlices, inds2 = list(range(len(fid.variables['time']))) # height - height_cent= stage_cent + 0. + height_cent = stage_cent + 0. for i in range(stage_cent.shape[0]): height_cent[i,:] = stage_cent[i,:] - elev_cent @@ -662,8 +664,8 @@ def animate_1D(time, var, x, ylab=' '): pylab.ion() # Initial plot - vmin=var.min() - vmax=var.max() + vmin = var.min() + vmax = var.max() line, = pylab.plot( (x.min(), x.max()), (vmin, vmax), 'o') # Lots of plots diff --git a/anuga/utilities/sparse.py b/anuga/utilities/sparse.py index f2c563447..cd8ad49ec 100644 --- a/anuga/utilities/sparse.py +++ b/anuga/utilities/sparse.py @@ -95,7 +95,7 @@ def copy(self): return new def todense(self): - D = num.zeros((self.M, self.N), num.float) + D = num.zeros((self.M, self.N), float) for i in range(self.M): for j in range(self.N): @@ -126,7 +126,7 @@ def __mul__(self, other): % (self.M, self.N, B.shape[0]) assert B.shape[0] == self.N, msg - R = num.zeros(self.M, num.float) # Result + R = num.zeros(self.M, float) # Result # Multiply nonzero elements for key in list(self.Data.keys()): @@ -135,7 +135,7 @@ def __mul__(self, other): R[i] += self.Data[key]*B[j] elif len(B.shape) == 2: - R = num.zeros((self.M, B.shape[1]), num.float) # Result matrix + R = num.zeros((self.M, B.shape[1]), float) # Result matrix # Multiply nonzero elements for col in range(R.shape[1]): @@ -198,7 +198,7 @@ def trans_mult(self, other): assert B.shape[0] == self.M, 'Mismatching dimensions' - R = num.zeros((self.N,), num.float) # Result + R = num.zeros((self.N,), float) # Result # Multiply nonzero elements for key in list(self.Data.keys()): @@ -245,9 +245,9 @@ def __init__(self, A=None, data=None, Colind=None, rowptr=None, m=None, n=None): keys = list(A.Data.keys()) keys.sort() nnz = len(keys) - data = num.zeros((nnz,), num.float) - colind = num.zeros((nnz,), num.int) - row_ptr = num.zeros((A.M+1,), num.int) + data = num.zeros((nnz,), float) + colind = num.zeros((nnz,), int) + row_ptr = num.zeros((A.M+1,), int) current_row = -1 k = 0 for key in keys: @@ -303,7 +303,7 @@ def nonzeros(self): return len(self) def todense(self): - D = num.zeros((self.M, self.N), num.float) + D = num.zeros((self.M, self.N), float) for i in range(self.M): for ckey in range(self.row_ptr[i], self.row_ptr[i+1]): diff --git a/anuga/utilities/sparse_ext.pyx b/anuga/utilities/sparse_ext.pyx index 3e9ab3559..3ec8523d7 100644 --- a/anuga/utilities/sparse_ext.pyx +++ b/anuga/utilities/sparse_ext.pyx @@ -19,13 +19,13 @@ def csr_mv(object csr_sparse, np.ndarray x not None): data = csr_sparse.data colind = csr_sparse.colind row_ptr = csr_sparse.row_ptr - x = np.ascontiguousarray(x.astype(np.float)) + x = np.ascontiguousarray(x.astype(float)) M = row_ptr.shape[0] - 1 if x.ndim == 1: # Multiplicant is a vector - y = np.ascontiguousarray(np.zeros(M, dtype=np.float)) + y = np.ascontiguousarray(np.zeros(M, dtype=float)) err = _csr_mv(M, &data[0], &colind[0], &row_ptr[0], x.data, y.data) @@ -34,7 +34,7 @@ def csr_mv(object csr_sparse, np.ndarray x not None): rows = x.shape[0] columns = x.shape[1] - y = np.ascontiguousarray(np.zeros((M,columns),dtype=np.float)) + y = np.ascontiguousarray(np.zeros((M,columns),dtype=float)) err = _csr_mm(M, columns, &data[0], &colind[0], &row_ptr[0], x.data, y.data) diff --git a/anuga/utilities/sww_merge.py b/anuga/utilities/sww_merge.py index 73b15195c..da38b595c 100755 --- a/anuga/utilities/sww_merge.py +++ b/anuga/utilities/sww_merge.py @@ -263,7 +263,7 @@ def _sww_merge_parallel_smooth(swwfiles, output, verbose=False, delete_old=Fals datum = fid.datum; projection = fid.projection; - g_volumes = num.zeros((number_of_global_triangles,3),num.int) + g_volumes = num.zeros((number_of_global_triangles,3),int) g_x = num.zeros((number_of_global_nodes,),num.float32) g_y = num.zeros((number_of_global_nodes,),num.float32) @@ -332,7 +332,7 @@ def _sww_merge_parallel_smooth(swwfiles, output, verbose=False, delete_old=Fals tri_l2g = fid.variables['tri_l2g'][:] node_l2g = fid.variables['node_l2g'][:] tri_full_flag = fid.variables['tri_full_flag'][:] - volumes = num.array(fid.variables['volumes'][:],dtype=num.int) + volumes = num.array(fid.variables['volumes'][:],dtype=int) l_volumes = num.zeros_like(volumes) l_old_volumes = num.zeros_like(volumes) diff --git a/anuga/utilities/tests/test_cg_solve.py b/anuga/utilities/tests/test_cg_solve.py index eb9ebd87f..e3596abd9 100644 --- a/anuga/utilities/tests/test_cg_solve.py +++ b/anuga/utilities/tests/test_cg_solve.py @@ -78,7 +78,7 @@ def test_solve_large(self): if i < n-1: A[i, i+1] = -0.5 - xe = num.ones((n,), num.float) + xe = num.ones((n,), float) b = A*xe x = conjugate_gradient(A, b, b, tol=1.0e-5) @@ -106,7 +106,7 @@ def test_solve_large_2d(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) b = A*xe x = conjugate_gradient(A, b, b, iprint=1) @@ -135,7 +135,7 @@ def test_solve_large_2d_csr_matrix(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) # Convert to csr format # print 'start covert' @@ -167,7 +167,7 @@ def test_solve_large_2d_with_default_guess(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) b = A*xe x = conjugate_gradient(A, b) @@ -264,7 +264,7 @@ def test_solve_large_using_c_ext(self): if i < n-1: A[i, i+1] = -0.5 - xe = num.ones((n,), num.float) + xe = num.ones((n,), float) b = A*xe @@ -295,7 +295,7 @@ def test_solve_large_2d_using_c_ext(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) A = Sparse_CSR(A) b = A*xe x = conjugate_gradient(A, b, b, iprint=1, use_c_cg=True) @@ -324,7 +324,7 @@ def test_solve_large_2d_csr_matrix_using_c_ext(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) # Convert to csr format # print 'start covert' @@ -356,7 +356,7 @@ def test_solve_large_2d_with_default_guess_using_c_ext(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) A = Sparse_CSR(A) b = A*xe x = conjugate_gradient(A, b, use_c_cg=True) @@ -433,7 +433,7 @@ def test_solve_large_using_c_ext_with_jacobi(self): if i < n-1: A[i, i+1] = -0.5 - xe = num.ones((n,), num.float) + xe = num.ones((n,), float) b = A*xe @@ -465,7 +465,7 @@ def test_solve_large_2d_using_c_ext_with_jacobi(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) A = Sparse_CSR(A) b = A*xe x = conjugate_gradient( @@ -495,7 +495,7 @@ def test_solve_large_2d_csr_matrix_using_c_ext_with_jacobi(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) # Convert to csr format # print 'start covert' @@ -528,7 +528,7 @@ def test_solve_large_2d_with_default_guess_using_c_ext_with_jacobi(self): if j < m-1: A[I, I+1] = -1.0 - xe = num.ones((n*m,), num.float) + xe = num.ones((n*m,), float) A = Sparse_CSR(A) b = A*xe x = conjugate_gradient(A, b, use_c_cg=True, precon='Jacobi') diff --git a/anuga/utilities/tests/test_numerical_tools.py b/anuga/utilities/tests/test_numerical_tools.py index 00e95a56f..35669f6f8 100644 --- a/anuga/utilities/tests/test_numerical_tools.py +++ b/anuga/utilities/tests/test_numerical_tools.py @@ -82,13 +82,13 @@ def test_ensure_numeric(self): assert B[0] == 1 and B[1] == 2 and B[2] == 3.14 and B[3] == 4 A = [1, 2, 3, 4] - B = ensure_numeric(A, num.float) + B = ensure_numeric(A, float) assert isinstance(B, num.ndarray) assert B.dtype.char == 'd' assert B[0] == 1.0 and B[1] == 2.0 and B[2] == 3.0 and B[3] == 4.0 A = [1, 2, 3, 4] - B = ensure_numeric(A, num.float) + B = ensure_numeric(A, float) assert isinstance(B, num.ndarray) assert B.dtype.char == 'd' assert B[0] == 1.0 and B[1] == 2.0 and B[2] == 3.0 and B[3] == 4.0 @@ -107,7 +107,7 @@ def test_ensure_numeric(self): assert A.dtype.char == 'l', msg A = num.array([1, 2, 3, 4]) - B = ensure_numeric(A, num.float) + B = ensure_numeric(A, float) assert isinstance(B, num.ndarray) assert A.dtype.char == 'l' assert B.dtype.char == 'd' @@ -116,10 +116,10 @@ def test_ensure_numeric(self): # Check scalars A = 1 - B = ensure_numeric(A, num.float) + B = ensure_numeric(A, float) assert num.alltrue(A == B) - B = ensure_numeric(A, num.int) + B = ensure_numeric(A, int) assert num.alltrue(A == B) # # try to simulate getting (x,0) shape @@ -138,7 +138,7 @@ def NO_ensure_numeric_char(self): '''numpy can't handle this''' # Error situation - B = ensure_numeric('hello', num.int) + B = ensure_numeric('hello', int) assert num.allclose(B, [104, 101, 108, 108, 111]) def test_gradient(self): @@ -381,9 +381,9 @@ def test_norm(self): def test_is_float(self): def t(val, expected): if expected == True: - msg = 'should be num.float?' + msg = 'should be float?' else: - msg = 'should not be num.float?' + msg = 'should not be float?' msg = '%s (%s) %s' % (str(val), type(val), msg) assert is_num_float(val) == expected, msg @@ -392,49 +392,49 @@ def t(val, expected): t('abc', False) t(None, False) t(num.array(None), False) - # can't create array(None, num.int) -# t(num.array(None, num.int), False) - t(num.array(None, num.float), True) + # can't create array(None, int) +# t(num.array(None, int), False) + t(num.array(None, float), True) t(num.array(()), True) - t(num.array((), num.int), False) - t(num.array((), num.float), True) - t(num.array((1), num.int), False) - t(num.array((1), num.float), True) + t(num.array((), int), False) + t(num.array((), float), True) + t(num.array((1), int), False) + t(num.array((1), float), True) t(num.array((1, 2)), False) - t(num.array((1, 2), num.int), False) - t(num.array((1, 2), num.float), True) + t(num.array((1, 2), int), False) + t(num.array((1, 2), float), True) t(num.array([1, 2]), False) - t(num.array([1, 2], num.int), False) - t(num.array([1, 2], num.float), True) + t(num.array([1, 2], int), False) + t(num.array([1, 2], float), True) t(num.array((1.0, 2.0)), True) - t(num.array((1.0, 2.0), num.int), False) - t(num.array((1.0, 2.0), num.float), True) + t(num.array((1.0, 2.0), int), False) + t(num.array((1.0, 2.0), float), True) t(num.array([1.0, 2.0]), True) - t(num.array([1.0, 2.0], num.int), False) - t(num.array([1.0, 2.0], num.float), True) + t(num.array([1.0, 2.0], int), False) + t(num.array([1.0, 2.0], float), True) t(num.array(((1.0, 2.0), (3.0, 4.0))), True) - t(num.array(((1.0, 2.0), (3.0, 4.0)), num.int), False) - t(num.array(((1.0, 2.0), (3.0, 4.0)), num.float), True) + t(num.array(((1.0, 2.0), (3.0, 4.0)), int), False) + t(num.array(((1.0, 2.0), (3.0, 4.0)), float), True) t(num.array([[1.0, 2.0], [3.0, 4.0]]), True) - t(num.array([1.0, 2.0], num.int), False) - t(num.array([1.0, 2.0], num.float), True) + t(num.array([1.0, 2.0], int), False) + t(num.array([1.0, 2.0], float), True) t(num.array('abc'), False) t(num.array('abc', 'S1'), False) # can't create array as int from string -# t(num.array('abc', num.int), False) +# t(num.array('abc', int), False) # can't create array as float from string -# t(num.array('abc', num.float), True) +# t(num.array('abc', float), True) def test_is_int(self): def t(val, expected): if expected == True: - msg = 'should be num.int?' + msg = 'should be int?' else: - msg = 'should not be num.int?' + msg = 'should not be int?' msg = '%s (%s) %s' % (str(val), type(val), msg) assert is_num_int(val) == expected, msg @@ -443,42 +443,42 @@ def t(val, expected): t('abc', False) t(None, False) t(num.array(None), False) - # can't create array(None, num.int) -# t(num.array(None, num.int), True) - t(num.array(None, num.float), False) - t(num.array((), num.int), True) + # can't create array(None, int) +# t(num.array(None, int), True) + t(num.array(None, float), False) + t(num.array((), int), True) t(num.array(()), False) - t(num.array((), num.float), False) - t(num.array((1), num.int), True) - t(num.array((1), num.float), False) + t(num.array((), float), False) + t(num.array((1), int), True) + t(num.array((1), float), False) t(num.array((1, 2)), True) - t(num.array((1, 2), num.int), True) - t(num.array((1, 2), num.float), False) + t(num.array((1, 2), int), True) + t(num.array((1, 2), float), False) t(num.array([1, 2]), True) - t(num.array([1, 2], num.int), True) - t(num.array([1, 2], num.float), False) + t(num.array([1, 2], int), True) + t(num.array([1, 2], float), False) t(num.array((1.0, 2.0)), False) - t(num.array((1.0, 2.0), num.int), True) - t(num.array((1.0, 2.0), num.float), False) + t(num.array((1.0, 2.0), int), True) + t(num.array((1.0, 2.0), float), False) t(num.array([1.0, 2.0]), False) - t(num.array([1.0, 2.0], num.int), True) - t(num.array([1.0, 2.0], num.float), False) + t(num.array([1.0, 2.0], int), True) + t(num.array([1.0, 2.0], float), False) t(num.array(((1.0, 2.0), (3.0, 4.0))), False) - t(num.array(((1.0, 2.0), (3.0, 4.0)), num.int), True) - t(num.array(((1.0, 2.0), (3.0, 4.0)), num.float), False) + t(num.array(((1.0, 2.0), (3.0, 4.0)), int), True) + t(num.array(((1.0, 2.0), (3.0, 4.0)), float), False) t(num.array([[1.0, 2.0], [3.0, 4.0]]), False) - t(num.array([1.0, 2.0], num.int), True) - t(num.array([1.0, 2.0], num.float), False) + t(num.array([1.0, 2.0], int), True) + t(num.array([1.0, 2.0], float), False) t(num.array('abc'), False) t(num.array('abc', 'S1'), False) # can't create array as int from string -# t(num.array('abc', num.int), True) +# t(num.array('abc', int), True) # can't create array as float from string -# t(num.array('abc', num.float), False) +# t(num.array('abc', float), False) def test_ensure_numeric_copy(self): """Test to see if ensure_numeric() behaves as we expect. @@ -494,7 +494,7 @@ def test_ensure_numeric_copy(self): points = [[1., 2.], [3., 4.], [5., 6.]] points_id = id(points) - points_new = ensure_numeric(points, num.float) + points_new = ensure_numeric(points, float) points_new_id = id(points_new) msg = 'ensure_numeric() should return a copy of a list' @@ -511,7 +511,7 @@ def test_ensure_numeric_copy(self): points = ((1., 2.), (3., 4.), (5., 6.)) points_id = id(points) - points_new = ensure_numeric(points, num.int) + points_new = ensure_numeric(points, int) points_new_id = id(points_new) msg = 'ensure_numeric() should return a copy of a list' @@ -525,10 +525,10 @@ def test_ensure_numeric_copy(self): # Make 'points' a numeric array of float coordinates. # Should NOT be changed by ensure_numeric(). ##### - points = num.array([[1., 2.], [3., 4.], [5., 6.]], num.float) + points = num.array([[1., 2.], [3., 4.], [5., 6.]], float) points_id = id(points) - points_new = ensure_numeric(points, num.float) + points_new = ensure_numeric(points, float) points_new_id = id(points_new) msg = 'ensure_numeric() should return the original input' @@ -540,12 +540,12 @@ def test_ensure_numeric_copy(self): ##### # Make 'points' a numeric array of int coordinates. - # Should be changed by ensure_numeric(, num.float). + # Should be changed by ensure_numeric(, float). ##### - points = num.array([[1, 2], [3, 4], [5, 6]], num.int) + points = num.array([[1, 2], [3, 4], [5, 6]], int) points_id = id(points) - points_new = ensure_numeric(points, num.float) + points_new = ensure_numeric(points, float) points_new_id = id(points_new) msg = 'ensure_numeric() should return a copy of the input' @@ -557,12 +557,12 @@ def test_ensure_numeric_copy(self): ##### # Make 'points' a numeric array of int coordinates. - # Should NOT be changed by ensure_numeric(, num.int). + # Should NOT be changed by ensure_numeric(, int). ##### - points = num.array([[1, 2], [3, 4], [5, 6]], num.int) + points = num.array([[1, 2], [3, 4], [5, 6]], int) points_id = id(points) - points_new = ensure_numeric(points, num.int) + points_new = ensure_numeric(points, int) points_new_id = id(points_new) msg = 'ensure_numeric() should return the original input' @@ -610,7 +610,7 @@ def test_ensure_numeric_copy(self): # Make 'points' a numeric array of float coordinates. # Should NOT be changed by ensure_numeric(, num.float64). ##### - points = num.array([[1., 2.], [3., 4.], [5., 6.]], num.float) + points = num.array([[1., 2.], [3., 4.], [5., 6.]], float) points_id = id(points) points_new = ensure_numeric(points, num.float64) diff --git a/anuga/visualiser/offline.py b/anuga/visualiser/offline.py index 2e8d292ad..28c2e67b6 100644 --- a/anuga/visualiser/offline.py +++ b/anuga/visualiser/offline.py @@ -85,12 +85,12 @@ def read_height_quantity(self, quantityName, dynamic=True, frameNumber=0): N_vert = fin.variables[quantityName].shape[1] else: N_vert = len(fin.variables[quantityName]) - x = num.ravel(num.array(fin.variables['x'], num.float)) - y = num.ravel(num.array(fin.variables['y'], num.float)) + x = num.ravel(num.array(fin.variables['x'], float)) + y = num.ravel(num.array(fin.variables['y'], float)) if dynamic is True: - q = num.array(fin.variables[quantityName][frameNumber], num.float) + q = num.array(fin.variables[quantityName][frameNumber], float) else: - q = num.ravel(num.array(fin.variables[quantityName], num.float)) + q = num.ravel(num.array(fin.variables[quantityName], float)) q *= self.height_zScales[quantityName] q += self.height_offset[quantityName] @@ -128,9 +128,9 @@ def build_quantity_dict(self): fin = NetCDFFile(self.source, 'r') for q in [n for n in list(fin.variables.keys()) if n != 'x' and n != 'y' and n != 'z' and n != 'time' and n != 'volumes']: if len(fin.variables[q].shape) == 1: # Not a time-varying quantity - quantities[q] = num.ravel(num.array(fin.variables[q], num.float)) + quantities[q] = num.ravel(num.array(fin.variables[q], float)) else: # Time-varying, get the current timestep data - quantities[q] = num.array(fin.variables[q][self.frameNumber], num.float) + quantities[q] = num.array(fin.variables[q][self.frameNumber], float) fin.close() return quantities diff --git a/anuga/visualiser/realtime.py b/anuga/visualiser/realtime.py index 84d97d8bd..d9c8f3b86 100644 --- a/anuga/visualiser/realtime.py +++ b/anuga/visualiser/realtime.py @@ -51,7 +51,7 @@ def setup_grid(self): N_vert = len(verticies) # Also build vert_index - a list of the x & y values of each vertex - self.vert_index = num.zeros((N_vert,2), num.float) + self.vert_index = num.zeros((N_vert,2), float) for n in range(N_tri): self.vtk_cells.InsertNextCell(3) for v in range(3): @@ -60,7 +60,7 @@ def setup_grid(self): def update_height_quantity(self, quantityName, dynamic=True): N_vert = len(self.source.get_vertex_coordinates()) - qty_index = num.zeros(N_vert, num.float) + qty_index = num.zeros(N_vert, float) triangles = self.source.get_triangles() vertex_values, _ = self.source.get_quantity(quantityName).get_vertex_values(xy=False, smooth=False) diff --git a/appveyor.yml b/appveyor.yml index 7ff15124c..863644fec 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ os: Visual Studio 2015 environment: matrix: - - PY_MAJOR_VER: 3 - PYTHON_ARCH: "x86" - PY_MAJOR_VER: 3 PYTHON_ARCH: "x86_64" @@ -17,20 +15,16 @@ build_script: Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` throw "There are newer queued builds for this pull request, failing early." } - ps: Start-FileDownload "https://repo.continuum.io/miniconda/Miniconda$env:PY_MAJOR_VER-latest-Windows-$env:PYTHON_ARCH.exe" C:\Miniconda.exe; echo "Finished downloading miniconda" - - ps: Start-FileDownload "https://download.microsoft.com/download/A/E/0/AE002626-9D9D-448D-8197-1EA510E297CE/msmpisetup.exe" C:\msmpisetup.exe; echo "Finished downloading msmpi" - - ps: Start-FileDownload "https://download.microsoft.com/download/A/E/0/AE002626-9D9D-448D-8197-1EA510E297CE/msmpisdk.msi" C:\msmpisdk.msi; echo "Finished downloading msmpisdk" - - cmd: msiexec.exe /i "C:\msmpisdk.msi" /qn - - cmd: C:\msmpisetup.exe -unattend - cmd: C:\Miniconda.exe /S /D=C:\Py - cmd: C:\Py\Scripts\activate.bat - CMD: SET - - set PATH=%PATH%;"C:\Program Files\Microsoft MPI\bin" - conda config --set always_yes yes - conda update conda - conda install python=3.7 gdal nose numpy cython scipy netcdf4 matplotlib dill future gitpython + - conda install -c conda-forge mpi4py msmpi - pip install Pmw - conda install -c msys2 libpython m2w64-toolchain - - pip install mpi4py triangle + - pip install triangle - python setup.py install test_script: diff --git a/examples/parallel/run_sequential_dump_parallel_load.py b/examples/parallel/run_sequential_dump_parallel_load.py index 8efc8de46..a7f814d79 100644 --- a/examples/parallel/run_sequential_dump_parallel_load.py +++ b/examples/parallel/run_sequential_dump_parallel_load.py @@ -2,22 +2,26 @@ # # Example of running a simple parallel model where the # sequential domain is partitioned and dumped as files -# and read in via sequential_load +# via sequential_dump and read in via parallel sequential_load # -# Need mpi setup for your machine +# Note: You can separate the sequential domain creation and dump +# in one script and the sequential_load and parallel domain creation +# script to run the parallel evolution. THe intial sequential domain creation +# can be run on a computer with a large memory. The partition files are +# stored in the directory Partitions # # Run in parallel as follows (on 4 processors) # -# mpiexec -np 4 python run_sequential_dump_parallel_load_sw_rectangular_cross.py +# mpiexec -np 4 python run_sequential_dump_parallel_load.py # # Note the use of "if myid == 0" to restrict some calculations -# to just one processor, in particular the creation of a -# full domain on processor 0 which is then distributed to the -# processors. +# to just one processor, in particular the creation and partition of a +# full domain on processor 0 which is then the partitions are +# loaded on all the processors. # # Authors: # Linda Stals, Steve Roberts and Matthew Hardy - June 2005 -# Steve Roberts - 2018 +# Steve Roberts - 2022. Adapted to use sequential dump and load # # # diff --git a/validation_tests/case_studies/merewether/plot_asc.py b/validation_tests/case_studies/merewether/plot_asc.py index 02a5e63eb..14ca2719e 100644 --- a/validation_tests/case_studies/merewether/plot_asc.py +++ b/validation_tests/case_studies/merewether/plot_asc.py @@ -84,7 +84,7 @@ print 'xllcorner ',xllcorner print 'yllcorner ',yllcorner - Z = np.zeros((nrows,ncols),dtype=np.float) + Z = np.zeros((nrows,ncols),dtype=float) n = len(lines[6:]) for i, line in enumerate(lines[6:]): @@ -124,7 +124,7 @@ plt.figure() - levels = z_min + np.arange(11,dtype=np.float)/10.0*(z_max-z_min) + levels = z_min + np.arange(11,dtype=float)/10.0*(z_max-z_min) print levels diff --git a/validation_tests/case_studies/patong/extras/build_urs_boundary.py b/validation_tests/case_studies/patong/extras/build_urs_boundary.py index e10c313e5..63d1571ba 100644 --- a/validation_tests/case_studies/patong/extras/build_urs_boundary.py +++ b/validation_tests/case_studies/patong/extras/build_urs_boundary.py @@ -145,7 +145,7 @@ def build_urs_boundary(event_file, output_dir): print 'using single-mux file', mux_file weight_factor = 1.0 - mux_weights = weight_factor*num.ones(len(mux_filenames), num.float) + mux_weights = weight_factor*num.ones(len(mux_filenames), float) order_filename = project.urs_order diff --git a/validation_tests/experimental_data/okushiri/create_okushiri.py b/validation_tests/experimental_data/okushiri/create_okushiri.py index 7e443cc27..2c7c68c65 100644 --- a/validation_tests/experimental_data/okushiri/create_okushiri.py +++ b/validation_tests/experimental_data/okushiri/create_okushiri.py @@ -123,8 +123,8 @@ def prepare_timeboundary(filename, verbose = False): N = len(lines) - T = num.zeros(N, num.float) #Time - Q = num.zeros(N, num.float) #Values + T = num.zeros(N, float) #Time + Q = num.zeros(N, float) #Values for i, line in enumerate(lines): fields = line.split()