- Timestamp:
- Nov 6, 2008, 12:17:15 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r5892 r5897 15 15 16 16 from anuga.utilities.numerical_tools import ensure_numeric 17 import numpy 17 from Numeric import arange, choose, zeros, Float, array, allclose, take, compress 18 18 19 19 from anuga.geospatial_data.geospatial_data import ensure_absolute … … 237 237 from anuga.config import time_format 238 238 from Scientific.IO.NetCDF import NetCDFFile 239 ## from numpy.oldnumeric import array, zeros, Float, alltrue, concatenate, reshape239 from Numeric import array, zeros, Float, alltrue, concatenate, reshape 240 240 241 241 # Open NetCDF file … … 303 303 # Get variables 304 304 # if verbose: print 'Get variables' 305 time = numpy.array(fid.variables['time'][:] )305 time = fid.variables['time'][:] 306 306 307 307 # Get time independent stuff … … 317 317 triangles = fid.variables['volumes'][:] 318 318 319 x = numpy.reshape(x, (len(x),1))320 y = numpy.reshape(y, (len(y),1))321 vertex_coordinates = numpy.concatenate((x,y), axis=1) #m x 2 array319 x = reshape(x, (len(x),1)) 320 y = reshape(y, (len(y),1)) 321 vertex_coordinates = concatenate((x,y), axis=1) #m x 2 array 322 322 323 323 if boundary_polygon is not None: … … 331 331 for i in range(len(boundary_polygon)): 332 332 for j in range(len(x)): 333 if numpy.allclose(vertex_coordinates[j],boundary_polygon[i],1e-4):333 if allclose(vertex_coordinates[j],boundary_polygon[i],1e-4): 334 334 #FIX ME: 335 335 #currently gauges lat and long is stored as float and … … 351 351 gauge_neighbour_id.append(-1) 352 352 gauge_neighbour_id=ensure_numeric(gauge_neighbour_id) 353 if len( numpy.compress(gauge_neighbour_id>=0,gauge_neighbour_id))!=len(temp)-1:353 if len(compress(gauge_neighbour_id>=0,gauge_neighbour_id))!=len(temp)-1: 354 354 msg='incorrect number of segments' 355 355 raise msg … … 373 373 # move time back - relative to domain's time 374 374 if domain_starttime > starttime: 375 ## print 'type(time)=%s' % type(time)376 ## print 'type(domain_starttime)=%s' % type(domain_starttime)377 ## print 'type(starttime)=%s' % type(starttime)378 ## a = time - domain_starttime379 375 time = time - domain_starttime + starttime 380 376 … … 402 398 if boundary_polygon is not None: 403 399 #removes sts points that do not lie on boundary 404 quantities[name] = numpy.take(quantities[name], gauge_id,1)400 quantities[name] = take(quantities[name],gauge_id,1) 405 401 406 402 # Close sww, tms or sts netcdf file … … 524 520 raise 'Illegal input to get_textual_float:', value 525 521 else: 526 return format % 522 return format %float(value) 527 523 528 524 … … 1040 1036 """ 1041 1037 # from math import sqrt, atan, degrees 1042 ## from numpy.oldnumeric import ones, allclose, zeros, Float, ravel1038 from Numeric import ones, allclose, zeros, Float, ravel 1043 1039 from os import sep, altsep, getcwd, mkdir, access, F_OK, environ 1044 1040 … … 1081 1077 n0 = int(n0) 1082 1078 m = len(locations) 1083 model_time = numpy.zeros((n0,m,p), numpy.float)1084 stages = numpy.zeros((n0,m,p), numpy.float)1085 elevations = numpy.zeros((n0,m,p), numpy.float)1086 momenta = numpy.zeros((n0,m,p), numpy.float)1087 xmom = numpy.zeros((n0,m,p), numpy.float)1088 ymom = numpy.zeros((n0,m,p), numpy.float)1089 speed = numpy.zeros((n0,m,p), numpy.float)1090 bearings = numpy.zeros((n0,m,p), numpy.float)1091 due_east = 90.0* numpy.ones((n0,1), numpy.float)1092 due_west = 270.0* numpy.ones((n0,1), numpy.float)1093 depths = numpy.zeros((n0,m,p), numpy.float)1094 eastings = numpy.zeros((n0,m,p), numpy.float)1079 model_time = zeros((n0,m,p), Float) 1080 stages = zeros((n0,m,p), Float) 1081 elevations = zeros((n0,m,p), Float) 1082 momenta = zeros((n0,m,p), Float) 1083 xmom = zeros((n0,m,p), Float) 1084 ymom = zeros((n0,m,p), Float) 1085 speed = zeros((n0,m,p), Float) 1086 bearings = zeros((n0,m,p), Float) 1087 due_east = 90.0*ones((n0,1), Float) 1088 due_west = 270.0*ones((n0,1), Float) 1089 depths = zeros((n0,m,p), Float) 1090 eastings = zeros((n0,m,p), Float) 1095 1091 min_stages = [] 1096 1092 max_stages = [] … … 1104 1100 min_speeds = [] 1105 1101 max_depths = [] 1106 model_time_plot3d = numpy.zeros((n0,m), numpy.float)1107 stages_plot3d = numpy.zeros((n0,m), numpy.float)1108 eastings_plot3d = numpy.zeros((n0,m),numpy.float)1102 model_time_plot3d = zeros((n0,m), Float) 1103 stages_plot3d = zeros((n0,m), Float) 1104 eastings_plot3d = zeros((n0,m),Float) 1109 1105 if time_unit is 'mins': scale = 60.0 1110 1106 if time_unit is 'hours': scale = 3600.0 … … 1206 1202 else: 1207 1203 #ax.plot_wireframe(model_time[:,:,j],eastings[:,:,j],stages[:,:,j]) 1208 ax.plot3D( numpy.ravel(eastings[:,:,j]),numpy.ravel(model_time[:,:,j]),numpy.ravel(stages[:,:,j]))1204 ax.plot3D(ravel(eastings[:,:,j]),ravel(model_time[:,:,j]),ravel(stages[:,:,j])) 1209 1205 ax.set_xlabel('time') 1210 1206 ax.set_ylabel('x') … … 1505 1501 1506 1502 # initialise the array to easily find the index of the first loner 1507 loners= numpy.arange(2*N, N, -1) # if N=3 [6,5,4]1503 loners=arange(2*N, N, -1) # if N=3 [6,5,4] 1508 1504 for t in triangles: 1509 1505 for vert in t: … … 1539 1535 #print "loners", loners 1540 1536 #print "triangles before", triangles 1541 triangles = numpy.choose(triangles,loners)1537 triangles = choose(triangles,loners) 1542 1538 #print "triangles after", triangles 1543 1539 return verts, triangles … … 1554 1550 1555 1551 1556 xc = numpy.zeros(triangles.shape[0], numpy.float) # Space for centroid info1552 xc = zeros(triangles.shape[0], Float) # Space for centroid info 1557 1553 1558 1554 for k in range(triangles.shape[0]): … … 1836 1832 #add tide to stage if provided 1837 1833 if quantity == 'stage': 1838 quantity_value[quantity]= numpy.array(quantity_value[quantity])+directory_add_tide1834 quantity_value[quantity]=array(quantity_value[quantity])+directory_add_tide 1839 1835 1840 1836 #condition to find max and mins for all the plots … … 1947 1943 #get data from dict in to list 1948 1944 #do maths to list by changing to array 1949 t=( numpy.array(directory_quantity_value[directory][filename]['time'])+directory_start_time)/seconds_in_minutes1945 t=(array(directory_quantity_value[directory][filename]['time'])+directory_start_time)/seconds_in_minutes 1950 1946 1951 1947 #finds the maximum elevation, used only as a test … … 2128 2124 from csv import reader,writer 2129 2125 from anuga.utilities.numerical_tools import ensure_numeric, mean, NAN 2130 ## from numpy.oldnumeric import array, resize, shape, Float, zeros, take, argsort, argmin2126 from Numeric import array, resize, shape, Float, zeros, take, argsort, argmin 2131 2127 import string 2132 2128 from anuga.shallow_water.data_manager import get_all_swwfiles … … 2169 2165 2170 2166 #convert to array for file_function 2171 points_array = numpy.array(points, numpy.float)2167 points_array = array(points,Float) 2172 2168 2173 2169 points_array = ensure_absolute(points_array)
Note: See TracChangeset
for help on using the changeset viewer.