Changeset 6304 for branches/numpy/anuga/shallow_water
- Timestamp:
- Feb 10, 2009, 11:11:04 AM (16 years ago)
- Location:
- branches/numpy
- Files:
-
- 1 deleted
- 17 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/shallow_water/benchmark_sww2dem.py
r6162 r6304 25 25 26 26 from Scientific.IO.NetCDF import NetCDFFile 27 import Numericas num27 import numpy as num 28 28 29 29 from anuga.fit_interpolate.interpolate import Interpolate … … 101 101 sww_fileName = tempfile.mktemp(".sww" ) 102 102 # sww_fileName = "aa.sww" 103 elevation = num.array(range(len(mesh_dict["vertices"])), num. Int) #array default#103 elevation = num.array(range(len(mesh_dict["vertices"])), num.int) #array default# 104 104 stage = elevation 105 105 ymomentum = elevation … … 111 111 sww.store_header(fid, 0, 112 112 len(mesh_dict['triangles']), 113 len(mesh_dict["vertices"]),sww_precision=num. Float)113 len(mesh_dict["vertices"]),sww_precision=num.float) 114 114 sww.store_triangulation(fid, 115 115 mesh_dict["vertices"], mesh_dict['triangles'], -
branches/numpy/anuga/shallow_water/data_manager.py
r6224 r6304 61 61 from os import sep, path, remove, mkdir, access, F_OK, W_OK, getcwd 62 62 63 import Numericas num63 import numpy as num 64 64 65 65 from Scientific.IO.NetCDF import NetCDFFile … … 76 76 default_minimum_storable_height 77 77 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 78 from anuga.config import netcdf_float, netcdf_float32, netcdf_int 78 79 from anuga.config import max_float 79 80 from anuga.utilities.numerical_tools import ensure_numeric, mean … … 343 344 from Scientific.IO.NetCDF import NetCDFFile 344 345 345 self.precision = n um.Float32 #Use single precision for quantities346 self.precision = netcdf_float32 #Use single precision for quantities 346 347 self.recursion = recursion 347 348 self.mode = mode … … 438 439 439 440 # store the connectivity data 440 points = num.concatenate( (X[:,num. NewAxis],Y[:,num.NewAxis]), axis=1 )441 points = num.concatenate( (X[:,num.newaxis],Y[:,num.newaxis]), axis=1 ) 441 442 self.writer.store_triangulation(fid, 442 443 points, 443 # V.astype(volumes.typecode()), 444 V.astype(num.Float32), 444 V.astype(num.float32), 445 445 Z, 446 446 points_georeference=\ … … 561 561 # Define a zero vector of same size and type as A 562 562 # for use with momenta 563 null = num.zeros(num.size(A), A. typecode())563 null = num.zeros(num.size(A), A.dtype.char) #??# 564 564 565 565 # Get xmomentum where depth exceeds minimum_storable_height … … 622 622 from Scientific.IO.NetCDF import NetCDFFile 623 623 624 self.precision = n um.Float #Use full precision624 self.precision = netcdf_float #Use full precision 625 625 626 626 Data_format.__init__(self, domain, 'sww', mode) … … 650 650 651 651 652 fid.createVariable('volumes', n um.Int, ('number_of_volumes',653 'number_of_vertices'))652 fid.createVariable('volumes', netcdf_int, ('number_of_volumes', 653 'number_of_vertices')) 654 654 655 655 fid.createVariable('time', self.precision, ('number_of_timesteps',)) … … 1304 1304 1305 1305 M = size #Number of lines 1306 xx = num.zeros((M,3), num. Float)1307 yy = num.zeros((M,3), num. Float)1308 zz = num.zeros((M,3), num. Float)1306 xx = num.zeros((M,3), num.float) 1307 yy = num.zeros((M,3), num.float) 1308 zz = num.zeros((M,3), num.float) 1309 1309 1310 1310 for i in range(M): … … 1349 1349 1350 1350 M = len(lines) #Number of lines 1351 x = num.zeros((M,3), num. Float)1352 y = num.zeros((M,3), num. Float)1353 z = num.zeros((M,3), num. Float)1351 x = num.zeros((M,3), num.float) 1352 y = num.zeros((M,3), num.float) 1353 z = num.zeros((M,3), num.float) 1354 1354 1355 1355 for i, line in enumerate(lines): … … 1409 1409 # @param step Timestep stride. 1410 1410 def filter_netcdf(filename1, filename2, first=0, last=None, step=1): 1411 """Read netcdf filename1, pick timesteps first:step:last and save to 1411 """Filter data file, selecting timesteps first:step:last. 1412 1413 Read netcdf filename1, pick timesteps first:step:last and save to 1412 1414 nettcdf file filename2 1413 1415 """ … … 1426 1428 for name in infile.variables: 1427 1429 var = infile.variables[name] 1428 outfile.createVariable(name, var. typecode(), var.dimensions)1430 outfile.createVariable(name, var.dtype.char, var.dimensions) #??# 1429 1431 1430 1432 # Copy the static variables … … 1499 1501 Convert to NetCDF pts format which is 1500 1502 1501 points: (Nx2) Float array1502 elevation: N Float array1503 points: (Nx2) float array 1504 elevation: N float array 1503 1505 """ 1504 1506 … … 1658 1660 1659 1661 # Variable definitions 1660 outfile.createVariable('points', n um.Float, ('number_of_points',1661 'number_of_dimensions'))1662 outfile.createVariable('elevation', n um.Float, ('number_of_points',))1662 outfile.createVariable('points', netcdf_float, ('number_of_points', 1663 'number_of_dimensions')) 1664 outfile.createVariable('elevation', netcdf_float, ('number_of_points',)) 1663 1665 1664 1666 # Get handles to the variables … … 1684 1686 newcols = lenv # ncols_in_bounding_box 1685 1687 1686 telev = num.zeros(newcols, num. Float)1687 tpoints = num.zeros((newcols, 2), num. Float)1688 telev = num.zeros(newcols, num.float) 1689 tpoints = num.zeros((newcols, 2), num.float) 1688 1690 1689 1691 local_index = 0 … … 1801 1803 Convert to NetCDF pts format which is 1802 1804 1803 points: (Nx2) Float array1804 elevation: N Float array1805 points: (Nx2) float array 1806 elevation: N float array 1805 1807 """ 1806 1808 … … 2245 2247 # Comment out for reduced memory consumption 2246 2248 for name in ['stage', 'xmomentum', 'ymomentum']: 2247 q = fid.variables[name][:].flat 2249 q = fid.variables[name][:].flatten() 2248 2250 if timestep is not None: 2249 2251 q = q[timestep*len(x):(timestep+1)*len(x)] 2250 2252 if verbose: print ' %s in [%f, %f]' %(name, min(q), max(q)) 2251 2253 for name in ['elevation']: 2252 q = fid.variables[name][:].flat 2254 q = fid.variables[name][:].flatten() 2253 2255 if verbose: print ' %s in [%f, %f]' %(name, min(q), max(q)) 2254 2256 … … 2256 2258 if verbose: print 'Processing quantity %s' %quantity 2257 2259 2258 # Turn NetCDF objects into Numeric arrays2260 # Turn NetCDF objects into numeric arrays 2259 2261 try: 2260 2262 q = fid.variables[quantity][:] … … 2269 2271 #q has a time component, must be reduced alongthe temporal dimension 2270 2272 if verbose: print 'Reducing quantity %s' %quantity 2271 q_reduced = num.zeros(number_of_points, num. Float)2273 q_reduced = num.zeros(number_of_points, num.float) 2272 2274 2273 2275 if timestep is not None: … … 2329 2331 y = y + yllcorner - newyllcorner 2330 2332 2331 vertex_points = num.concatenate ((x[:,num. NewAxis], y[:,num.NewAxis]), axis=1)2333 vertex_points = num.concatenate ((x[:,num.newaxis], y[:,num.newaxis]), axis=1) 2332 2334 assert len(vertex_points.shape) == 2 2333 2335 2334 grid_points = num.zeros ((ncols*nrows, 2), num. Float)2336 grid_points = num.zeros ((ncols*nrows, 2), num.float) 2335 2337 2336 2338 for i in xrange(nrows): … … 2359 2361 #Interpolate using quantity values 2360 2362 if verbose: print 'Interpolating' 2361 grid_values = interp.interpolate(q, grid_points).flat 2363 grid_values = interp.interpolate(q, grid_points).flatten() 2362 2364 2363 2365 if verbose: 2364 print 'Interpolated values are in [%f, %f]' %(min(grid_values ),2365 max(grid_values ))2366 print 'Interpolated values are in [%f, %f]' %(min(grid_values.flat), 2367 max(grid_values.flat)) 2366 2368 2367 2369 #Assign NODATA_value to all points outside bounding polygon (from interpolation mesh) … … 2631 2633 if verbose: print 'Processing quantity %s' % quantity 2632 2634 2633 # Turn NetCDF objects into Numeric arrays2635 # Turn NetCDF objects into numeric arrays 2634 2636 quantity_dict = {} 2635 2637 for name in fid.variables.keys(): … … 2644 2646 if verbose: print 'Reducing quantity %s' % quantity 2645 2647 2646 q_reduced = num.zeros(number_of_points, num. Float)2648 q_reduced = num.zeros(number_of_points, num.float) 2647 2649 for k in range(number_of_points): 2648 2650 q_reduced[k] = reduction(q[:,k]) … … 2658 2660 2659 2661 # Create grid and update xll/yll corner and x,y 2660 vertex_points = num.concatenate((x[:, num. NewAxis], y[:, num.NewAxis]), axis=1)2662 vertex_points = num.concatenate((x[:, num.newaxis], y[:, num.newaxis]), axis=1) 2661 2663 assert len(vertex_points.shape) == 2 2662 2664 … … 2667 2669 # Interpolate using quantity values 2668 2670 if verbose: print 'Interpolating' 2669 interpolated_values = interp.interpolate(q, data_points).flat 2671 interpolated_values = interp.interpolate(q, data_points).flatten 2670 2672 2671 2673 if verbose: 2672 print 'Interpolated values are in [%f, %f]' % (min(interpolated_values),2673 max(interpolated_values))2674 print 'Interpolated values are in [%f, %f]' \ 2675 % (min(interpolated_values.flat), max(interpolated_values.flat)) 2674 2676 2675 2677 # Assign NODATA_value to all points outside bounding polygon … … 2878 2880 2879 2881 # variable definitions 2880 fid.createVariable('elevation', n um.Float, ('number_of_rows',2881 'number_of_columns'))2882 fid.createVariable('elevation', netcdf_float, ('number_of_rows', 2883 'number_of_columns')) 2882 2884 2883 2885 # Get handles to the variables … … 2959 2961 from Scientific.IO.NetCDF import NetCDFFile 2960 2962 2961 precision = num. Float2963 precision = num.float 2962 2964 2963 2965 msg = 'Must use latitudes and longitudes for minlat, maxlon etc' … … 3078 3080 # elevations = file_e.variables['ELEVATION'][kmin:kmax, lmin:lmax] 3079 3081 # elif latitudes2[0]==latitudes[-1] and latitudes2[-1]==latitudes[0]: 3080 # from Numericimport asarray3082 # from numpy import asarray 3081 3083 # elevations=elevations.tolist() 3082 3084 # elevations.reverse() 3083 3085 # elevations=asarray(elevations) 3084 3086 # else: 3085 # from Numericimport asarray3087 # from numpy import asarray 3086 3088 # elevations=elevations.tolist() 3087 3089 # elevations.reverse() … … 3195 3197 sww.store_header(outfile, times, number_of_volumes, 3196 3198 number_of_points, description=description, 3197 verbose=verbose, sww_precision=n um.Float)3199 verbose=verbose, sww_precision=netcdf_float) 3198 3200 3199 3201 # Store 3200 3202 from anuga.coordinate_transforms.redfearn import redfearn 3201 x = num.zeros(number_of_points, num. Float) #Easting3202 y = num.zeros(number_of_points, num. Float) #Northing3203 x = num.zeros(number_of_points, num.float) #Easting 3204 y = num.zeros(number_of_points, num.float) #Northing 3203 3205 3204 3206 if verbose: print 'Making triangular grid' … … 3234 3236 volumes.append([v4,v3,v2]) #Lower element 3235 3237 3236 volumes = num.array(volumes , num.Int) #array default#3238 volumes = num.array(volumes) 3237 3239 3238 3240 if origin is None: … … 3255 3257 outfile.variables['z'][:] = z #FIXME HACK for bacwards compat. 3256 3258 outfile.variables['elevation'][:] = z 3257 outfile.variables['volumes'][:] = volumes.astype(num. Int32) #For Opteron 643259 outfile.variables['volumes'][:] = volumes.astype(num.int32) #For Opteron 64 3258 3260 3259 3261 #Time stepping … … 3387 3389 d = len(q) 3388 3390 3389 T = num.zeros(N, num. Float) # Time3390 Q = num.zeros((N, d), num. Float) # Values3391 T = num.zeros(N, num.float) # Time 3392 Q = num.zeros((N, d), num.float) # Values 3391 3393 3392 3394 for i, line in enumerate(lines): … … 3424 3426 fid.createDimension('number_of_timesteps', len(T)) 3425 3427 3426 fid.createVariable('time', n um.Float, ('number_of_timesteps',))3428 fid.createVariable('time', netcdf_float, ('number_of_timesteps',)) 3427 3429 3428 3430 fid.variables['time'][:] = T … … 3434 3436 name = 'Attribute%d' % i 3435 3437 3436 fid.createVariable(name, n um.Float, ('number_of_timesteps',))3438 fid.createVariable(name, netcdf_float, ('number_of_timesteps',)) 3437 3439 fid.variables[name][:] = Q[:,i] 3438 3440 … … 3505 3507 time_interp = get_time_interp(time,t) 3506 3508 3507 # Get the variables as Numeric arrays3509 # Get the variables as numeric arrays 3508 3510 x = fid.variables['x'][:] # x-coordinates of vertices 3509 3511 y = fid.variables['y'][:] # y-coordinates of vertices … … 3518 3520 # FIXME (Ole): Something like this might be better: 3519 3521 # concatenate((x, y), axis=1) 3520 # or concatenate((x[:,num. NewAxis], x[:,num.NewAxis]), axis=1)3522 # or concatenate((x[:,num.newaxis], x[:,num.newaxis]), axis=1) 3521 3523 3522 3524 conserved_quantities = [] … … 3706 3708 # @param boundary 3707 3709 def weed(coordinates, volumes, boundary=None): 3708 if type(coordinates) == num.ArrayType:3710 if isinstance(coordinates, num.ndarray): 3709 3711 coordinates = coordinates.tolist() 3710 if type(volumes) == num.ArrayType:3712 if isinstance(volumes, num.ndarray): 3711 3713 volumes = volumes.tolist() 3712 3714 … … 3854 3856 3855 3857 # variable definition 3856 outfile.createVariable('elevation', n um.Float, ('number_of_points',))3858 outfile.createVariable('elevation', netcdf_float, ('number_of_points',)) 3857 3859 3858 3860 # Get handle to the variable … … 3867 3869 3868 3870 lower_index = global_index 3869 telev = num.zeros(ncols_new, num. Float)3871 telev = num.zeros(ncols_new, num.float) 3870 3872 local_index = 0 3871 3873 trow = i * cellsize_ratio … … 3995 3997 from anuga.coordinate_transforms.redfearn import redfearn 3996 3998 3997 precision = n um.Float # So if we want to change the precision its done here3999 precision = netcdf_float # So if we want to change the precision its done here 3998 4000 3999 4001 # go in to the bath dir and load the only file, … … 4096 4098 ################################# 4097 4099 4098 outfile.createVariable('volumes', n um.Int, ('number_of_volumes',4099 'number_of_vertices'))4100 outfile.createVariable('volumes', netcdf_int, ('number_of_volumes', 4101 'number_of_vertices')) 4100 4102 4101 4103 outfile.createVariable('time', precision, ('number_of_timesteps',)) … … 4113 4115 from anuga.coordinate_transforms.redfearn import redfearn 4114 4116 4115 x = num.zeros(number_of_points, num. Float) #Easting4116 y = num.zeros(number_of_points, num. Float) #Northing4117 x = num.zeros(number_of_points, num.float) #Easting 4118 y = num.zeros(number_of_points, num.float) #Northing 4117 4119 4118 4120 if verbose: print 'Making triangular grid' … … 4150 4152 volumes.append([v4,v2,v3]) #Lower element 4151 4153 4152 volumes = num.array(volumes , num.Int) #array default#4154 volumes = num.array(volumes) 4153 4155 4154 4156 geo_ref = Geo_reference(refzone, min(x), min(y)) … … 4175 4177 outfile.variables['z'][:] = z 4176 4178 outfile.variables['elevation'][:] = z 4177 outfile.variables['volumes'][:] = volumes.astype(num. Int32) # On Opteron 644179 outfile.variables['volumes'][:] = volumes.astype(num.int32) # On Opteron 64 4178 4180 4179 4181 stage = outfile.variables['stage'] … … 4367 4369 lat_name = 'LAT' 4368 4370 time_name = 'TIME' 4369 precision = n um.Float # So if we want to change the precision its done here4371 precision = netcdf_float # So if we want to change the precision its done here 4370 4372 4371 4373 ## … … 4648 4650 lonlatdep = p_array.array('f') 4649 4651 lonlatdep.read(mux_file, columns * points_num) 4650 lonlatdep = num.array(lonlatdep, typecode=num.Float)4652 lonlatdep = num.array(lonlatdep, dtype=num.float) 4651 4653 lonlatdep = num.reshape(lonlatdep, (points_num, columns)) 4652 4654 … … 4655 4657 lon_sorted.sort() 4656 4658 4657 if not lon == lon_sorted:4659 if not num.alltrue(lon == lon_sorted): 4658 4660 msg = "Longitudes in mux file are not in ascending order" 4659 4661 raise IOError, msg … … 4661 4663 lat_sorted = list(lat) 4662 4664 lat_sorted.sort() 4663 4664 # UNUSED?4665 ## if not lat == lat_sorted:4666 ## msg = "Latitudes in mux file are not in ascending order"4667 4665 4668 4666 nc_file = Write_nc(quantity, … … 4677 4675 hz_p_array = p_array.array('f') 4678 4676 hz_p_array.read(mux_file, points_num) 4679 hz_p = num.array(hz_p_array, typecode=num.Float)4677 hz_p = num.array(hz_p_array, dtype=num.float) 4680 4678 hz_p = num.reshape(hz_p, (len(lon), len(lat))) 4681 4679 hz_p = num.transpose(hz_p) # mux has lat varying fastest, nc has long v.f. … … 4775 4773 QUANTITY = 2 4776 4774 4777 long_lat_dep = ensure_numeric(long_lat_dep, num. Float)4775 long_lat_dep = ensure_numeric(long_lat_dep, num.float) 4778 4776 4779 4777 num_points = long_lat_dep.shape[0] … … 4813 4811 # FIXME - make this faster/do this a better way 4814 4812 # use numeric transpose, after reshaping the quantity vector 4815 quantity = num.zeros(num_points, num. Float)4813 quantity = num.zeros(num_points, num.float) 4816 4814 4817 4815 for lat_i, _ in enumerate(lat): … … 5266 5264 5267 5265 points_utm=ensure_numeric(points_utm) 5268 assert ensure_numeric(mesh_dic['generatedpointlist']) \5269 == ensure_numeric(points_utm)5266 assert num.alltrue(ensure_numeric(mesh_dic['generatedpointlist']) 5267 == ensure_numeric(points_utm)) 5270 5268 5271 5269 volumes = mesh_dic['generatedtrianglelist'] … … 5285 5283 sww = Write_sww() 5286 5284 sww.store_header(outfile, times, len(volumes), len(points_utm), 5287 verbose=verbose, sww_precision=n um.Float)5285 verbose=verbose, sww_precision=netcdf_float) 5288 5286 outfile.mean_stage = mean_stage 5289 5287 outfile.zscale = zscale … … 5309 5307 xmomentum=xmomentum, 5310 5308 ymomentum=ymomentum, 5311 sww_precision=num. Float)5309 sww_precision=num.float) 5312 5310 j += 1 5313 5311 … … 5356 5354 numSrc = len(filenames) 5357 5355 5358 file_params = -1 * num.ones(3, num. Float) # [nsta,dt,nt]5356 file_params = -1 * num.ones(3, num.float) # [nsta,dt,nt] 5359 5357 5360 5358 # Convert verbose to int C flag … … 5365 5363 5366 5364 if weights is None: 5367 weights = num.ones(numSrc )5365 weights = num.ones(numSrc, num.int) #array default# 5368 5366 5369 5367 if permutation is None: 5370 permutation = ensure_numeric([], num. Float)5368 permutation = ensure_numeric([], num.float) 5371 5369 5372 5370 # Call underlying C implementation urs2sts_ext.c … … 5416 5414 5417 5415 times = dt * num.arange(parameters_index) 5418 latitudes = num.zeros(number_of_selected_stations, num. Float)5419 longitudes = num.zeros(number_of_selected_stations, num. Float)5420 elevation = num.zeros(number_of_selected_stations, num. Float)5421 quantity = num.zeros((number_of_selected_stations, parameters_index), num. Float)5416 latitudes = num.zeros(number_of_selected_stations, num.float) 5417 longitudes = num.zeros(number_of_selected_stations, num.float) 5418 elevation = num.zeros(number_of_selected_stations, num.float) 5419 quantity = num.zeros((number_of_selected_stations, parameters_index), num.float) 5422 5420 5423 5421 starttime = 1e16 … … 5543 5541 if weights is None: 5544 5542 # Default is equal weighting 5545 weights = num.ones(numSrc, num. Float) / numSrc5543 weights = num.ones(numSrc, num.float) / numSrc 5546 5544 else: 5547 5545 weights = ensure_numeric(weights) … … 5665 5663 # 0 to number_of_points-1 5666 5664 if permutation is None: 5667 permutation = num.arange(number_of_points, typecode=num.Int)5665 permutation = num.arange(number_of_points, dtype=num.int) 5668 5666 5669 5667 # NetCDF file definition … … 5679 5677 description=description, 5680 5678 verbose=verbose, 5681 sts_precision=n um.Float)5679 sts_precision=netcdf_float) 5682 5680 5683 5681 # Store 5684 5682 from anuga.coordinate_transforms.redfearn import redfearn 5685 5683 5686 x = num.zeros(number_of_points, num. Float) # Easting5687 y = num.zeros(number_of_points, num. Float) # Northing5684 x = num.zeros(number_of_points, num.float) # Easting 5685 y = num.zeros(number_of_points, num.float) # Northing 5688 5686 5689 5687 # Check zone boundaries … … 5716 5714 5717 5715 elevation = num.resize(elevation, outfile.variables['elevation'][:].shape) 5718 outfile.variables['permutation'][:] = permutation.astype(num. Int32) # Opteron 645716 outfile.variables['permutation'][:] = permutation.astype(num.int32) # Opteron 64 5719 5717 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 5720 5718 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() … … 5821 5819 # @param smoothing True if smoothing is to be used. 5822 5820 # @param order 5823 # @param sww_precision Data type of the quantitiy to be written (Float32)5821 # @param sww_precision Data type of the quantitiy written (netcdf constant) 5824 5822 # @param verbose True if this function is to be verbose. 5825 5823 # @note If 'times' is a list, the info will be made relative. … … 5832 5830 smoothing=True, 5833 5831 order=1, 5834 sww_precision=n um.Float32,5832 sww_precision=netcdf_float32, 5835 5833 verbose=False): 5836 5834 """Write an SWW file header. … … 5865 5863 # This is being used to seperate one number from a list. 5866 5864 # what it is actually doing is sorting lists from numeric arrays. 5867 if type(times) is list or type(times) is num.ArrayType:5865 if type(times) is list or isinstance(times, num.ndarray): 5868 5866 number_of_times = len(times) 5869 5867 times = ensure_numeric(times) … … 5914 5912 outfile.createVariable('z', sww_precision, ('number_of_points',)) 5915 5913 5916 outfile.createVariable('volumes', n um.Int, ('number_of_volumes',5917 'number_of_vertices'))5914 outfile.createVariable('volumes', netcdf_int, ('number_of_volumes', 5915 'number_of_vertices')) 5918 5916 5919 5917 # Doing sww_precision instead of Float gives cast errors. 5920 outfile.createVariable('time', n um.Float,5918 outfile.createVariable('time', netcdf_float, 5921 5919 ('number_of_timesteps',)) 5922 5920 … … 5932 5930 #outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max 5933 5931 5934 if type(times) is list or type(times) is num.ArrayType:5932 if type(times) is list or isinstance(times, num.ndarray): 5935 5933 outfile.variables['time'][:] = times #Store time relative 5936 5934 … … 6035 6033 outfile.variables['z'][:] = elevation 6036 6034 outfile.variables['elevation'][:] = elevation #FIXME HACK 6037 outfile.variables['volumes'][:] = volumes.astype(num. Int32) #On Opteron 646035 outfile.variables['volumes'][:] = volumes.astype(num.int32) #On Opteron 64 6038 6036 6039 6037 q = 'elevation' … … 6051 6049 # @param verbose True if this function is to be verbose. 6052 6050 # @param **quant 6053 def store_quantities(self, outfile, sww_precision=num. Float32,6051 def store_quantities(self, outfile, sww_precision=num.float32, 6054 6052 slice_index=None, time=None, 6055 6053 verbose=False, **quant): … … 6236 6234 # @param number_of_points The number of URS gauge sites. 6237 6235 # @param description Description string to write into the STS file. 6238 # @param sts_precision Format of data to write ( default Float32).6236 # @param sts_precision Format of data to write (netcdf constant ONLY). 6239 6237 # @param verbose True if this function is to be verbose. 6240 6238 # @note If 'times' is a list, the info will be made relative. … … 6244 6242 number_of_points, 6245 6243 description='Converted from URS mux2 format', 6246 sts_precision=n um.Float32,6244 sts_precision=netcdf_float32, 6247 6245 verbose=False): 6248 6246 """ … … 6267 6265 # This is being used to seperate one number from a list. 6268 6266 # what it is actually doing is sorting lists from numeric arrays. 6269 if type(times) is list or type(times) is num.ArrayType:6267 if type(times) is list or isinstance(times, num.ndarray): 6270 6268 number_of_times = len(times) 6271 6269 times = ensure_numeric(times) … … 6287 6285 6288 6286 # Variable definitions 6289 outfile.createVariable('permutation', n um.Int, ('number_of_points',))6287 outfile.createVariable('permutation', netcdf_int, ('number_of_points',)) 6290 6288 outfile.createVariable('x', sts_precision, ('number_of_points',)) 6291 6289 outfile.createVariable('y', sts_precision, ('number_of_points',)) … … 6302 6300 6303 6301 # Doing sts_precision instead of Float gives cast errors. 6304 outfile.createVariable('time', n um.Float, ('number_of_timesteps',))6302 outfile.createVariable('time', netcdf_float, ('number_of_timesteps',)) 6305 6303 6306 6304 for q in Write_sts.sts_quantities: … … 6314 6312 outfile.variables[q + Write_sts.RANGE][1] = -max_float # Max 6315 6313 6316 if type(times) is list or type(times) is num.ArrayType:6314 if type(times) is list or isinstance(times, num.ndarray): 6317 6315 outfile.variables['time'][:] = times #Store time relative 6318 6316 … … 6423 6421 # @param verboseTrue if this function is to be verbose. 6424 6422 # @param **quant Extra keyword args. 6425 def store_quantities(self, outfile, sts_precision=num. Float32,6423 def store_quantities(self, outfile, sts_precision=num.float32, 6426 6424 slice_index=None, time=None, 6427 6425 verbose=False, **quant): … … 6514 6512 lonlatdep = p_array.array('f') 6515 6513 lonlatdep.read(mux_file, columns * self.points_num) 6516 lonlatdep = num.array(lonlatdep, typecode=num.Float)6514 lonlatdep = num.array(lonlatdep, dtype=num.float) 6517 6515 lonlatdep = num.reshape(lonlatdep, (self.points_num, columns)) 6518 6516 self.lonlatdep = lonlatdep … … 6550 6548 hz_p_array = p_array.array('f') 6551 6549 hz_p_array.read(self.mux_file, self.points_num) 6552 hz_p = num.array(hz_p_array, typecode=num.Float)6550 hz_p = num.array(hz_p_array, dtype=num.float) 6553 6551 self.iter_time_step += 1 6554 6552 … … 6695 6693 # array to store data, number in there is to allow float... 6696 6694 # i'm sure there is a better way! 6697 data = num.array([], typecode=num.Float)6695 data = num.array([], dtype=num.float) 6698 6696 data = num.resize(data, ((len(lines)-1), len(header_fields))) 6699 6697 … … 6861 6859 time += fid.starttime[0] 6862 6860 6863 # Get the variables as Numeric arrays6861 # Get the variables as numeric arrays 6864 6862 x = fid.variables['x'][:] # x-coordinates of nodes 6865 6863 y = fid.variables['y'][:] # y-coordinates of nodes … … 6870 6868 6871 6869 # Mesh (nodes (Mx2), triangles (Nx3)) 6872 nodes = num.concatenate((x[:,num. NewAxis], y[:,num.NewAxis]), axis=1)6870 nodes = num.concatenate((x[:,num.newaxis], y[:,num.newaxis]), axis=1) 6873 6871 triangles = fid.variables['volumes'][:] 6874 6872 … … 7293 7291 7294 7292 # Get the relevant quantities (Convert from single precison) 7295 elevation = num.array(fid.variables['elevation'][:], num. Float)7296 stage = num.array(fid.variables['stage'][:], num. Float)7293 elevation = num.array(fid.variables['elevation'][:], num.float) 7294 stage = num.array(fid.variables['stage'][:], num.float) 7297 7295 7298 7296 # Here's where one could convert nodal information to centroid … … 7311 7309 # and call it here 7312 7310 7313 points = num.concatenate((x[:,num. NewAxis], y[:,num.NewAxis]), axis=1)7311 points = num.concatenate((x[:,num.newaxis], y[:,num.newaxis]), axis=1) 7314 7312 7315 7313 point_indices = inside_polygon(points, polygon) -
branches/numpy/anuga/shallow_water/eq_test.py
r6162 r6304 66 66 67 67 from anuga.abstract_2d_finite_volumes.util import file_function 68 import Numericas num68 import numpy as num 69 69 from pylab import plot, ion, hold,savefig 70 70 … … 75 75 76 76 y = 10000 77 points=num.array([[0]*2]*max , num.Int) #array default#77 points=num.array([[0]*2]*max) 78 78 print points 79 79 half_max_skip=(max*skip)/2 … … 87 87 number_points = profile_lenght/interval 88 88 y = 10000 89 points=num.array([[0]*2]*number_points , num.Int) #array default#89 points=num.array([[0]*2]*number_points) 90 90 print points 91 91 half_profile=profile_lenght/2 -
branches/numpy/anuga/shallow_water/eqf_v2.py
r4436 r6304 26 26 """ 27 27 28 import numpy as num 29 30 28 31 def earthquake_tsunami(length, width, strike, depth, \ 29 32 dip, x0=0.0, y0=0.0, slip=1.0, rake=90.,\ … … 110 113 111 114 from math import sin, cos, radians, exp, cosh 112 from Numeric import zeros, Float113 115 #from okada import okadatest 114 116 … … 142 144 #z1 = okada(xr,yr,depth,length,width,dip,rake,slip) 143 145 144 z2 = zeros(N, Float)146 z2 = num.zeros(N, num.float) 145 147 alp = 0.5 146 148 disl3 = 0.0 … … 182 184 """ 183 185 184 from Numeric import zeros, Float 185 U = zeros(9, Float) 186 DU = zeros(9, Float) 186 U = num.zeros(9, num.float) 187 DU = num.zeros(9, num.float) 187 188 188 189 F0 = 0.0 -
branches/numpy/anuga/shallow_water/shallow_water_domain.py
r6190 r6304 80 80 # $LastChangedBy$ 81 81 82 import Numericas num82 import numpy as num 83 83 84 84 from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints … … 1081 1081 self.normals = domain.normals 1082 1082 1083 self.conserved_quantities = num.zeros(3, num. Float)1083 self.conserved_quantities = num.zeros(3, num.float) 1084 1084 1085 1085 def __repr__(self): … … 1501 1501 if callable(f): 1502 1502 N = 3 1503 x = num.ones(3, num. Float)1504 y = num.ones(3, num. Float)1503 x = num.ones(3, num.float) 1504 y = num.ones(3, num.float) 1505 1505 try: 1506 1506 q = f(1.0, x=x, y=y) … … 1511 1511 1512 1512 try: 1513 q = num.array(q, num. Float)1513 q = num.array(q, num.float) 1514 1514 except: 1515 1515 msg = 'Return value from vector function %s could ' %f 1516 msg += 'not be converted into a Numeric array of floats.\n'1516 msg += 'not be converted into a numeric array of floats.\n' 1517 1517 msg += 'Specified function should return either list or array.' 1518 1518 raise msg … … 1520 1520 # Is this really what we want? 1521 1521 msg = 'Return vector from function %s ' %f 1522 msg += 'must have same lenght as input vectors' 1522 msg += 'must have same length as input vectors' 1523 msg += ' (type(q)=%s' % type(q) 1523 1524 assert len(q) == N, msg 1524 1525 … … 1622 1623 1623 1624 try: 1624 s_vec = self.speed * num.ones(N, num. Float)1625 s_vec = self.speed * num.ones(N, num.float) 1625 1626 except: 1626 1627 msg = 'Speed must be either callable or a scalar: %s' %self.s … … 1635 1636 1636 1637 try: 1637 phi_vec = self.phi * num.ones(N, num. Float)1638 phi_vec = self.phi * num.ones(N, num.float) 1638 1639 except: 1639 1640 msg = 'Angle must be either callable or a scalar: %s' %self.phi … … 1712 1713 quantity_name, 1713 1714 rate=0.0, 1714 1715 center=None, radius=None, 1715 1716 polygon=None, 1716 1717 default_rate=None, … … 1775 1776 assert is_inside_polygon(point, bounding_polygon), msg 1776 1777 1777 1778 1778 if polygon is not None: 1779 1779 … … 1835 1835 1836 1836 # Check and store default_rate 1837 1838 1837 msg = 'Keyword argument default_rate must be either None ' 1838 msg += 'or a function of time.\n I got %s' %(str(default_rate)) 1839 1839 assert default_rate is None or \ 1840 1840 type(default_rate) in [IntType, FloatType] or \ … … 1920 1920 1921 1921 """ 1922 1923 1924 1925 1922 if callable(self.rate): 1923 rate = self.rate(t) 1924 else: 1925 rate = self.rate 1926 1926 1927 1927 return rate … … 1964 1964 1965 1965 Used for implementing Rainfall over the entire domain. 1966 1967 1968 1969 1970 1966 1967 Current Limited to only One Gauge.. 1968 1969 Need to add Spatial Varying Capability 1970 (This module came from copying and amending the Inflow Code) 1971 1971 1972 1972 Rainfall(rain) … … 1974 1974 domain 1975 1975 rain [mm/s]: Total rain rate over the specified domain. 1976 1977 1976 NOTE: Raingauge Data needs to reflect the time step. 1977 IE: if Gauge is mm read at a time step, then the input 1978 1978 here is as mm/(timeStep) so 10mm in 5minutes becomes 1979 1979 10/(5x60) = 0.0333mm/s. 1980 1981 1980 1982 1981 This parameter can be either a constant or a 1983 1982 function of time. Positive values indicate inflow, … … 1992 1991 Examples 1993 1992 How to put them in a run File... 1994 1993 1995 1994 #------------------------------------------------------------------------ 1996 1995 # Setup specialised forcing terms … … 2009 2008 def __init__(self, 2010 2009 domain, 2011 2012 2010 rate=0.0, 2011 center=None, radius=None, 2013 2012 polygon=None, 2014 2013 default_rate=None, … … 2071 2070 # The outflow area is 0.07**2*pi=0.0154 m^2 2072 2071 # This corresponds to a rate of change of 0.003/0.0154 = 0.2 m/s 2073 # 2072 # 2074 2073 Inflow((0.7, 0.4), 0.07, -0.003) 2075 2074 … … 2098 2097 def __init__(self, 2099 2098 domain, 2100 2101 2099 rate=0.0, 2100 center=None, radius=None, 2102 2101 polygon=None, 2103 2102 default_rate=None, … … 2123 2122 """ 2124 2123 2125 2126 2127 2128 2124 if callable(self.rate): 2125 _rate = self.rate(t)/self.exchange_area 2126 else: 2127 _rate = self.rate/self.exchange_area 2129 2128 2130 2129 return _rate -
branches/numpy/anuga/shallow_water/shallow_water_ext.c
r5967 r6304 15 15 16 16 #include "Python.h" 17 #include " Numeric/arrayobject.h"17 #include "numpy/arrayobject.h" 18 18 #include "math.h" 19 19 #include <stdio.h> -
branches/numpy/anuga/shallow_water/smf.py
r6157 r6304 47 47 """ 48 48 49 import Numericas num49 import numpy as num 50 50 51 51 … … 388 388 389 389 from math import sin, cos, radians, exp, cosh 390 # from Numeric import zeros, Float391 390 392 391 #ensure vectors x and y have the same length … … 416 415 yr = ((x-x0) * sina + (y-y0) * cosa) + y0 417 416 418 z = num.zeros(N, num. Float)417 z = num.zeros(N, num.float) 419 418 maxz = 0.0 420 419 minz = 0.0 -
branches/numpy/anuga/shallow_water/test_all.py
r3691 r6304 78 78 if __name__ == '__main__': 79 79 suite = regressionTest() 80 runner = unittest.TextTestRunner() # (verbosity=2)80 runner = unittest.TextTestRunner() #verbosity=2) 81 81 runner.run(suite) -
branches/numpy/anuga/shallow_water/test_data_manager.py
r6224 r6304 7 7 import unittest 8 8 import copy 9 import Numericas num9 import numpy as num 10 10 11 11 from anuga.utilities.numerical_tools import mean … … 25 25 from anuga.utilities.system_tools import get_pathname_from_package 26 26 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 27 from anuga.config import netcdf_float 27 28 28 29 # This is needed to run the tests of local functions … … 67 68 #Initial condition - with jumps 68 69 bed = domain.quantities['elevation'].vertex_values 69 stage = num.zeros(bed.shape, num. Float)70 stage = num.zeros(bed.shape, num.float) 70 71 71 72 h = 0.3 … … 109 110 110 111 fid.createDimension(long_name,nx) 111 fid.createVariable(long_name, 'd',(long_name,))112 fid.createVariable(long_name,netcdf_float,(long_name,)) 112 113 fid.variables[long_name].point_spacing='uneven' 113 114 fid.variables[long_name].units='degrees_east' … … 115 116 116 117 fid.createDimension(lat_name,ny) 117 fid.createVariable(lat_name, 'd',(lat_name,))118 fid.createVariable(lat_name,netcdf_float,(lat_name,)) 118 119 fid.variables[lat_name].point_spacing='uneven' 119 120 fid.variables[lat_name].units='degrees_north' … … 121 122 122 123 fid.createDimension('TIME',six) 123 fid.createVariable('TIME', 'd',('TIME',))124 fid.createVariable('TIME',netcdf_float,('TIME',)) 124 125 fid.variables['TIME'].point_spacing='uneven' 125 126 fid.variables['TIME'].units='seconds' … … 129 130 name = ext[1:3].upper() 130 131 if name == 'E.': name = 'ELEVATION' 131 fid.createVariable(name, 'd',('TIME', lat_name, long_name))132 fid.createVariable(name,netcdf_float,('TIME', lat_name, long_name)) 132 133 fid.variables[name].units='CENTIMETERS' 133 134 fid.variables[name].missing_value=-1.e+034 … … 189 190 V = fid.variables['volumes'] 190 191 191 assert num.allclose (x[:], self.X.flat )192 assert num.allclose (y[:], self.Y.flat )193 assert num.allclose (z[:], self.F.flat )192 assert num.allclose (x[:], self.X.flatten()) 193 assert num.allclose (y[:], self.Y.flatten()) 194 assert num.allclose (z[:], self.F.flatten()) 194 195 195 196 P = len(self.domain) … … 521 522 #Check contents 522 523 #Get NetCDF 523 fid = NetCDFFile(sww.filename, inetcdf_mode_r)524 fid = NetCDFFile(sww.filename, netcdf_mode_r) 524 525 525 526 # Get the variables … … 589 590 if t == 0.0: 590 591 assert num.allclose(stage, self.initial_stage) 591 assert num.allclose(stage_file[:], stage.flat )592 assert num.allclose(stage_file[:], stage.flatten()) 592 593 else: 593 594 assert not num.allclose(stage, self.initial_stage) 594 assert not num.allclose(stage_file[:], stage.flat )595 assert not num.allclose(stage_file[:], stage.flatten()) 595 596 596 597 fid.close() … … 855 856 xvec = range(10) 856 857 #z = range(100) 857 z = num.zeros(100 )858 z = num.zeros(100, num.int) #array default# 858 859 NODATA_value = -9999 859 860 count = -1 … … 914 915 915 916 #create new reference points 916 newz = num.zeros(19 )917 newz = num.zeros(19, num.int) #array default# 917 918 newz[0:2] = ref_elevation[32:34] 918 919 newz[2:5] = ref_elevation[35:38] … … 985 986 xvec = range(10) 986 987 #z = range(100) 987 z = num.zeros(100 )988 z = num.zeros(100, num.int) #array default# 988 989 NODATA_value = -9999 989 990 count = -1 … … 1044 1045 1045 1046 #create new reference points 1046 newz = num.zeros(14 )1047 newz = num.zeros(14, num.int) #array default# 1047 1048 newz[0:2] = ref_elevation[32:34] 1048 1049 newz[2:5] = ref_elevation[35:38] … … 2543 2544 2544 2545 bed = domain.quantities['elevation'].vertex_values 2545 stage = num.zeros(bed.shape, num. Float)2546 stage = num.zeros(bed.shape, num.float) 2546 2547 2547 2548 h = 0.3 … … 2793 2794 2794 2795 # Invoke interpolation for vertex points 2795 points = num.concatenate( (x[:,num. NewAxis],y[:,num.NewAxis]), axis=1 )2796 points = num.concatenate( (x[:,num.newaxis],y[:,num.newaxis]), axis=1 ) 2796 2797 sww2pts(self.domain.get_name(), 2797 2798 quantity = 'elevation', … … 3171 3172 for fid in [fid1,fid2,fid3]: 3172 3173 fid.createDimension(long_name,nx) 3173 fid.createVariable(long_name, 'd',(long_name,))3174 fid.createVariable(long_name,netcdf_float,(long_name,)) 3174 3175 fid.variables[long_name].point_spacing='uneven' 3175 3176 fid.variables[long_name].units='degrees_east' … … 3177 3178 3178 3179 fid.createDimension(lat_name,ny) 3179 fid.createVariable(lat_name, 'd',(lat_name,))3180 fid.createVariable(lat_name,netcdf_float,(lat_name,)) 3180 3181 fid.variables[lat_name].point_spacing='uneven' 3181 3182 fid.variables[lat_name].units='degrees_north' … … 3183 3184 3184 3185 fid.createDimension(time_name,2) 3185 fid.createVariable(time_name, 'd',(time_name,))3186 fid.createVariable(time_name,netcdf_float,(time_name,)) 3186 3187 fid.variables[time_name].point_spacing='uneven' 3187 3188 fid.variables[time_name].units='seconds' … … 3192 3193 for fid in [fid4]: 3193 3194 fid.createDimension(long_name,nx) 3194 fid.createVariable(long_name, 'd',(long_name,))3195 fid.createVariable(long_name,netcdf_float,(long_name,)) 3195 3196 fid.variables[long_name].point_spacing='uneven' 3196 3197 fid.variables[long_name].units='degrees_east' … … 3198 3199 3199 3200 fid.createDimension(lat_name,ny) 3200 fid.createVariable(lat_name, 'd',(lat_name,))3201 fid.createVariable(lat_name,netcdf_float,(lat_name,)) 3201 3202 fid.variables[lat_name].point_spacing='uneven' 3202 3203 fid.variables[lat_name].units='degrees_north' … … 3222 3223 3223 3224 for fid in [fid1,fid2,fid3]: 3224 fid.createVariable(name[fid], 'd',(time_name,lat_name,long_name))3225 fid.createVariable(name[fid],netcdf_float,(time_name,lat_name,long_name)) 3225 3226 fid.variables[name[fid]].point_spacing='uneven' 3226 3227 fid.variables[name[fid]].units=units[fid] … … 3230 3231 3231 3232 for fid in [fid4]: 3232 fid.createVariable(name[fid], 'd',(lat_name,long_name))3233 fid.createVariable(name[fid],netcdf_float,(lat_name,long_name)) 3233 3234 fid.variables[name[fid]].point_spacing='uneven' 3234 3235 fid.variables[name[fid]].units=units[fid] … … 3335 3336 for fid in [fid1,fid2,fid3]: 3336 3337 fid.createDimension(long_name,nx) 3337 fid.createVariable(long_name, 'd',(long_name,))3338 fid.createVariable(long_name,netcdf_float,(long_name,)) 3338 3339 fid.variables[long_name].point_spacing='uneven' 3339 3340 fid.variables[long_name].units='degrees_east' … … 3341 3342 3342 3343 fid.createDimension(lat_name,ny) 3343 fid.createVariable(lat_name, 'd',(lat_name,))3344 fid.createVariable(lat_name,netcdf_float,(lat_name,)) 3344 3345 fid.variables[lat_name].point_spacing='uneven' 3345 3346 fid.variables[lat_name].units='degrees_north' … … 3347 3348 3348 3349 fid.createDimension(time_name,2) 3349 fid.createVariable(time_name, 'd',(time_name,))3350 fid.createVariable(time_name,netcdf_float,(time_name,)) 3350 3351 fid.variables[time_name].point_spacing='uneven' 3351 3352 fid.variables[time_name].units='seconds' … … 3356 3357 for fid in [fid4]: 3357 3358 fid.createDimension(long_name,nx) 3358 fid.createVariable(long_name, 'd',(long_name,))3359 fid.createVariable(long_name,netcdf_float,(long_name,)) 3359 3360 fid.variables[long_name].point_spacing='uneven' 3360 3361 fid.variables[long_name].units='degrees_east' … … 3362 3363 3363 3364 fid.createDimension(lat_name,ny) 3364 fid.createVariable(lat_name, 'd',(lat_name,))3365 fid.createVariable(lat_name,netcdf_float,(lat_name,)) 3365 3366 fid.variables[lat_name].point_spacing='uneven' 3366 3367 fid.variables[lat_name].units='degrees_north' … … 3386 3387 3387 3388 for fid in [fid1,fid2,fid3]: 3388 fid.createVariable(name[fid], 'd',(time_name,lat_name,long_name))3389 fid.createVariable(name[fid],netcdf_float,(time_name,lat_name,long_name)) 3389 3390 fid.variables[name[fid]].point_spacing='uneven' 3390 3391 fid.variables[name[fid]].units=units[fid] … … 3394 3395 3395 3396 for fid in [fid4]: 3396 fid.createVariable(name[fid], 'd',(lat_name,long_name))3397 fid.createVariable(name[fid],netcdf_float,(lat_name,long_name)) 3397 3398 fid.variables[name[fid]].point_spacing='uneven' 3398 3399 fid.variables[name[fid]].units=units[fid] … … 3966 3967 fid.createDimension('number_of_points', nrows*ncols) 3967 3968 3968 fid.createVariable('elevation', n um.Float, ('number_of_points',))3969 fid.createVariable('elevation', netcdf_float, ('number_of_points',)) 3969 3970 3970 3971 elevation = fid.variables['elevation'] … … 3993 3994 3994 3995 #generate a stencil for computing the decimated values 3995 stencil = num.ones((3,3), num. Float) / 9.03996 stencil = num.ones((3,3), num.float) / 9.0 3996 3997 3997 3998 decimate_dem(root, stencil=stencil, cellsize_new=100) … … 4049 4050 fid.createDimension('number_of_points', nrows*ncols) 4050 4051 4051 fid.createVariable('elevation', n um.Float, ('number_of_points',))4052 fid.createVariable('elevation', netcdf_float, ('number_of_points',)) 4052 4053 4053 4054 elevation = fid.variables['elevation'] … … 4087 4088 4088 4089 #generate a stencil for computing the decimated values 4089 stencil = num.ones((3,3), num. Float) / 9.04090 stencil = num.ones((3,3), num.float) / 9.0 4090 4091 4091 4092 decimate_dem(root, stencil=stencil, cellsize_new=100) … … 4950 4951 4951 4952 ## 7th test 4952 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]] , num.Int) #array default#4953 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) 4953 4954 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( 4954 4955 latitudes,longitudes, … … 4963 4964 #print "longitudes_news",longitudes_news 4964 4965 4965 self.failUnless(latitudes_new == [2, 1] and \ 4966 longitudes_news == [10, 20], 4967 'failed') 4968 4969 self.failUnless(m2d == [[5,6],[9,10]], 4970 'failed') 4966 self.failUnless(num.alltrue(latitudes_new == [2, 1]) and 4967 num.alltrue(longitudes_news == [10, 20]), 4968 'failed') 4969 4970 self.failUnless(num.alltrue(m2d == [[5,6],[9,10]]), 'failed') 4971 4971 4972 4972 def test_get_min_max_indexes_lat_ascending(self): … … 5010 5010 longitudes = [148,149,150,151] 5011 5011 5012 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]] , num.Int) #array default#5012 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) 5013 5013 5014 5014 # k - lat … … 5031 5031 #print "longitudes_new",longitudes_new 5032 5032 5033 self.failUnless(latitudes_new == [-30, -35, -40] and \5033 self.failUnless(latitudes_new == [-30, -35, -40] and 5034 5034 longitudes_new == [148, 149,150], 5035 5036 self.failUnless( m2d == [[0,1,2],[4,5,6],[8,9,10]],5037 5035 'failed') 5036 self.failUnless(num.alltrue(m2d == [[0,1,2],[4,5,6],[8,9,10]]), 5037 'failed') 5038 5038 5039 5039 def test_get_min_max_indexes3(self): … … 5477 5477 quantities_init[i] = ensure_numeric(quantities_init[i]) 5478 5478 #print "HA_init", HA_init 5479 q_time = num.zeros((time_step_count, points_num), num. Float)5479 q_time = num.zeros((time_step_count, points_num), num.float) 5480 5480 for time in range(time_step_count): 5481 5481 q_time[time,:] = quantities_init[i] #* time * 4 … … 5561 5561 quantities_init[i] = ensure_numeric(quantities_init[i]) 5562 5562 #print "HA_init", HA_init 5563 q_time = num.zeros((time_step_count, points_num), num. Float)5563 q_time = num.zeros((time_step_count, points_num), num.float) 5564 5564 for time in range(time_step_count): 5565 5565 q_time[time,:] = quantities_init[i] #* time * 4 … … 6017 6017 if ha is None: 6018 6018 this_ha = e 6019 quantities_init[0].append(num.ones(time_step_count,num. Float)*this_ha) # HA6019 quantities_init[0].append(num.ones(time_step_count,num.float)*this_ha) # HA 6020 6020 else: 6021 6021 quantities_init[0].append(ha[i]) 6022 6022 if ua is None: 6023 6023 this_ua = n 6024 quantities_init[1].append(num.ones(time_step_count,num. Float)*this_ua) # UA6024 quantities_init[1].append(num.ones(time_step_count,num.float)*this_ua) # UA 6025 6025 else: 6026 6026 quantities_init[1].append(ua[i]) 6027 6027 if va is None: 6028 6028 this_va = e 6029 quantities_init[2].append(num.ones(time_step_count,num. Float)*this_va) #6029 quantities_init[2].append(num.ones(time_step_count,num.float)*this_va) # 6030 6030 else: 6031 6031 quantities_init[2].append(va[i]) … … 6037 6037 files = [] 6038 6038 for i, q in enumerate(quantities): 6039 q_time = num.zeros((time_step_count, points_num), num. Float)6039 q_time = num.zeros((time_step_count, points_num), num.float) 6040 6040 quantities_init[i] = ensure_numeric(quantities_init[i]) 6041 6041 for time in range(time_step_count): … … 6106 6106 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6107 6107 n=len(lat_long_points) 6108 first_tstep=num.ones(n,num. Int)6109 last_tstep=time_step_count*num.ones(n,num. Int)6110 depth=20*num.ones(n,num. Float)6111 ha=2*num.ones((n,time_step_count),num. Float)6112 ua=5*num.ones((n,time_step_count),num. Float)6113 va=-10*num.ones((n,time_step_count),num. Float)6108 first_tstep=num.ones(n,num.int) 6109 last_tstep=time_step_count*num.ones(n,num.int) 6110 depth=20*num.ones(n,num.float) 6111 ha=2*num.ones((n,time_step_count),num.float) 6112 ua=5*num.ones((n,time_step_count),num.float) 6113 va=-10*num.ones((n,time_step_count),num.float) 6114 6114 #-ve added to take into account mux file format where south is positive. 6115 6115 base_name, files = self.write_mux2(lat_long_points, … … 6121 6121 va=va) 6122 6122 6123 weights=num.ones(1, num. Float)6123 weights=num.ones(1, num.float) 6124 6124 #ensure that files are indeed mux2 files 6125 6125 times, latitudes, longitudes, elevation, stage, starttime = read_mux2_py([files[0]],weights) … … 6161 6161 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6162 6162 n=len(lat_long_points) 6163 first_tstep=num.ones(n,num. Int)6164 last_tstep=(time_step_count)*num.ones(n,num. Int)6165 depth=20*num.ones(n,num. Float)6166 ha=2*num.ones((n,time_step_count),num. Float)6163 first_tstep=num.ones(n,num.int) 6164 last_tstep=(time_step_count)*num.ones(n,num.int) 6165 depth=20*num.ones(n,num.float) 6166 ha=2*num.ones((n,time_step_count),num.float) 6167 6167 ha[0]=num.arange(0,time_step_count)+1 6168 6168 ha[1]=time_step_count-num.arange(1,time_step_count+1) … … 6170 6170 ha[2]=num.arange(2*time_step_count,3*time_step_count) 6171 6171 ha[3]=num.arange(3*time_step_count,4*time_step_count) 6172 ua=5*num.ones((n,time_step_count),num. Float)6173 va=-10*num.ones((n,time_step_count),num. Float)6172 ua=5*num.ones((n,time_step_count),num.float) 6173 va=-10*num.ones((n,time_step_count),num.float) 6174 6174 #-ve added to take into account mux file format where south is positive. 6175 6175 base_name, files = self.write_mux2(lat_long_points, … … 6181 6181 va=va) 6182 6182 6183 weights=num.ones(1, num. Float)6183 weights=num.ones(1, num.float) 6184 6184 #ensure that files are indeed mux2 files 6185 6185 times, latitudes, longitudes, elevation, stage,starttime=read_mux2_py([files[0]],weights) … … 6219 6219 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6220 6220 n=len(lat_long_points) 6221 first_tstep=num.ones(n,num. Int)6221 first_tstep=num.ones(n,num.int) 6222 6222 first_tstep[0]+=1 6223 6223 first_tstep[2]+=1 6224 last_tstep=(time_step_count)*num.ones(n,num. Int)6224 last_tstep=(time_step_count)*num.ones(n,num.int) 6225 6225 last_tstep[0]-=1 6226 6226 6227 depth=20*num.ones(n,num. Float)6228 ha=2*num.ones((n,time_step_count),num. Float)6227 depth=20*num.ones(n,num.float) 6228 ha=2*num.ones((n,time_step_count),num.float) 6229 6229 ha[0]=num.arange(0,time_step_count) 6230 6230 ha[1]=num.arange(time_step_count,2*time_step_count) 6231 6231 ha[2]=num.arange(2*time_step_count,3*time_step_count) 6232 6232 ha[3]=num.arange(3*time_step_count,4*time_step_count) 6233 ua=5*num.ones((n,time_step_count),num. Float)6234 va=-10*num.ones((n,time_step_count),num. Float)6233 ua=5*num.ones((n,time_step_count),num.float) 6234 va=-10*num.ones((n,time_step_count),num.float) 6235 6235 #-ve added to take into account mux file format where south is positive. 6236 6236 base_name, files = self.write_mux2(lat_long_points, … … 6242 6242 va=va) 6243 6243 6244 weights=num.ones(1, num. Float)6244 weights=num.ones(1, num.float) 6245 6245 #ensure that files are indeed mux2 files 6246 6246 times, latitudes, longitudes, elevation, stage, starttime=read_mux2_py([files[0]],weights) … … 6308 6308 6309 6309 # Create different timeseries starting and ending at different times 6310 first_tstep=num.ones(n, num. Int)6310 first_tstep=num.ones(n, num.int) 6311 6311 first_tstep[0]+=2 # Point 0 starts at 2 6312 6312 first_tstep[1]+=4 # Point 1 starts at 4 6313 6313 first_tstep[2]+=3 # Point 2 starts at 3 6314 6314 6315 last_tstep=(time_step_count)*num.ones(n,num. Int)6315 last_tstep=(time_step_count)*num.ones(n,num.int) 6316 6316 last_tstep[0]-=1 # Point 0 ends 1 step early 6317 6317 last_tstep[1]-=2 # Point 1 ends 2 steps early … … 6319 6319 6320 6320 # Create varying elevation data (positive values for seafloor) 6321 gauge_depth=20*num.ones(n,num. Float)6321 gauge_depth=20*num.ones(n,num.float) 6322 6322 for i in range(n): 6323 6323 gauge_depth[i] += i**2 6324 6324 6325 6325 # Create data to be written to first mux file 6326 ha0=2*num.ones((n,time_step_count),num. Float)6326 ha0=2*num.ones((n,time_step_count),num.float) 6327 6327 ha0[0]=num.arange(0,time_step_count) 6328 6328 ha0[1]=num.arange(time_step_count,2*time_step_count) 6329 6329 ha0[2]=num.arange(2*time_step_count,3*time_step_count) 6330 6330 ha0[3]=num.arange(3*time_step_count,4*time_step_count) 6331 ua0=5*num.ones((n,time_step_count),num. Float)6332 va0=-10*num.ones((n,time_step_count),num. Float)6331 ua0=5*num.ones((n,time_step_count),num.float) 6332 va0=-10*num.ones((n,time_step_count),num.float) 6333 6333 6334 6334 # Ensure data used to write mux file to be zero when gauges are … … 6369 6369 # For each quantity read the associated list of source mux2 file with 6370 6370 # extention associated with that quantity 6371 file_params=-1*num.ones(3,num. Float) #[nsta,dt,nt]6371 file_params=-1*num.ones(3,num.float) #[nsta,dt,nt] 6372 6372 OFFSET = 5 6373 6373 … … 6414 6414 6415 6415 # Create different timeseries starting and ending at different times 6416 first_tstep=num.ones(n,num. Int)6416 first_tstep=num.ones(n,num.int) 6417 6417 first_tstep[0]+=2 # Point 0 starts at 2 6418 6418 first_tstep[1]+=4 # Point 1 starts at 4 6419 6419 first_tstep[2]+=3 # Point 2 starts at 3 6420 6420 6421 last_tstep=(time_step_count)*num.ones(n,num. Int)6421 last_tstep=(time_step_count)*num.ones(n,num.int) 6422 6422 last_tstep[0]-=1 # Point 0 ends 1 step early 6423 6423 last_tstep[1]-=2 # Point 1 ends 2 steps early … … 6425 6425 6426 6426 # Create varying elevation data (positive values for seafloor) 6427 gauge_depth=20*num.ones(n,num. Float)6427 gauge_depth=20*num.ones(n,num.float) 6428 6428 for i in range(n): 6429 6429 gauge_depth[i] += i**2 6430 6430 6431 6431 # Create data to be written to second mux file 6432 ha1=num.ones((n,time_step_count),num. Float)6432 ha1=num.ones((n,time_step_count),num.float) 6433 6433 ha1[0]=num.sin(times_ref) 6434 6434 ha1[1]=2*num.sin(times_ref - 3) … … 6437 6437 ha1[4]=num.sin(2*times_ref-0.7) 6438 6438 6439 ua1=num.zeros((n,time_step_count),num. Float)6439 ua1=num.zeros((n,time_step_count),num.float) 6440 6440 ua1[0]=3*num.cos(times_ref) 6441 6441 ua1[1]=2*num.sin(times_ref-0.7) … … 6443 6443 ua1[4]=2*num.ones(time_step_count) 6444 6444 6445 va1=num.zeros((n,time_step_count),num. Float)6445 va1=num.zeros((n,time_step_count),num.float) 6446 6446 va1[0]=2*num.cos(times_ref-0.87) 6447 6447 va1[1]=3*num.ones(time_step_count) … … 6516 6516 if ha is None: 6517 6517 this_ha = e 6518 quantities_init[0].append(num.ones(time_step_count,num. Float)*this_ha) # HA6518 quantities_init[0].append(num.ones(time_step_count,num.float)*this_ha) # HA 6519 6519 else: 6520 6520 quantities_init[0].append(ha[i]) 6521 6521 if ua is None: 6522 6522 this_ua = n 6523 quantities_init[1].append(num.ones(time_step_count,num. Float)*this_ua) # UA6523 quantities_init[1].append(num.ones(time_step_count,num.float)*this_ua) # UA 6524 6524 else: 6525 6525 quantities_init[1].append(ua[i]) 6526 6526 if va is None: 6527 6527 this_va = e 6528 quantities_init[2].append(num.ones(time_step_count,num. Float)*this_va) #6528 quantities_init[2].append(num.ones(time_step_count,num.float)*this_va) # 6529 6529 else: 6530 6530 quantities_init[2].append(va[i]) … … 6534 6534 #print i, q 6535 6535 6536 q_time = num.zeros((time_step_count, points_num), num. Float)6536 q_time = num.zeros((time_step_count, points_num), num.float) 6537 6537 quantities_init[i] = ensure_numeric(quantities_init[i]) 6538 6538 for time in range(time_step_count): … … 6620 6620 # For each quantity read the associated list of source mux2 file with 6621 6621 # extention associated with that quantity 6622 file_params=-1*num.ones(3,num. Float) # [nsta,dt,nt]6622 file_params=-1*num.ones(3,num.float) # [nsta,dt,nt] 6623 6623 OFFSET = 5 6624 6624 … … 6639 6639 parameters_index = data.shape[1]-OFFSET 6640 6640 6641 quantity=num.zeros((number_of_selected_stations, parameters_index), num. Float)6641 quantity=num.zeros((number_of_selected_stations, parameters_index), num.float) 6642 6642 6643 6643 … … 6674 6674 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6675 6675 n=len(lat_long_points) 6676 first_tstep=num.ones(n,num. Int)6676 first_tstep=num.ones(n,num.int) 6677 6677 first_tstep[0]+=1 6678 6678 first_tstep[2]+=1 6679 last_tstep=(time_step_count)*num.ones(n,num. Int)6679 last_tstep=(time_step_count)*num.ones(n,num.int) 6680 6680 last_tstep[0]-=1 6681 6681 6682 gauge_depth=20*num.ones(n,num. Float)6683 ha=2*num.ones((n,time_step_count),num. Float)6682 gauge_depth=20*num.ones(n,num.float) 6683 ha=2*num.ones((n,time_step_count),num.float) 6684 6684 ha[0]=num.arange(0,time_step_count) 6685 6685 ha[1]=num.arange(time_step_count,2*time_step_count) 6686 6686 ha[2]=num.arange(2*time_step_count,3*time_step_count) 6687 6687 ha[3]=num.arange(3*time_step_count,4*time_step_count) 6688 ua=5*num.ones((n,time_step_count),num. Float)6689 va=-10*num.ones((n,time_step_count),num. Float)6688 ua=5*num.ones((n,time_step_count),num.float) 6689 va=-10*num.ones((n,time_step_count),num.float) 6690 6690 6691 6691 base_name, files = self.write_mux2(lat_long_points, … … 6760 6760 #momentum = velocity_ua *(stage+depth) 6761 6761 6762 depth=num.zeros((len(lat_long_points),time_step_count),num. Float)6762 depth=num.zeros((len(lat_long_points),time_step_count),num.float) 6763 6763 for i in range(len(lat_long_points)): 6764 6764 depth[i]=gauge_depth[i]+tide+ha[i] … … 6789 6789 lat_long_points =[(-21.,114.5),(-21.,113.5),(-21.,114.), (-21.,115.)] 6790 6790 n=len(lat_long_points) 6791 first_tstep=num.ones(n,num. Int)6791 first_tstep=num.ones(n,num.int) 6792 6792 first_tstep[0]+=1 6793 6793 first_tstep[2]+=1 6794 last_tstep=(time_step_count)*num.ones(n,num. Int)6794 last_tstep=(time_step_count)*num.ones(n,num.int) 6795 6795 last_tstep[0]-=1 6796 6796 6797 gauge_depth=20*num.ones(n,num. Float)6798 ha=2*num.ones((n,time_step_count),num. Float)6797 gauge_depth=20*num.ones(n,num.float) 6798 ha=2*num.ones((n,time_step_count),num.float) 6799 6799 ha[0]=num.arange(0,time_step_count) 6800 6800 ha[1]=num.arange(time_step_count,2*time_step_count) 6801 6801 ha[2]=num.arange(2*time_step_count,3*time_step_count) 6802 6802 ha[3]=num.arange(3*time_step_count,4*time_step_count) 6803 ua=5*num.ones((n,time_step_count),num. Float)6804 va=-10*num.ones((n,time_step_count),num. Float)6803 ua=5*num.ones((n,time_step_count),num.float) 6804 va=-10*num.ones((n,time_step_count),num.float) 6805 6805 6806 6806 base_name, files = self.write_mux2(lat_long_points, … … 6851 6851 lat_long_points =[(-21.,113.5),(-21.,114.5),(-21.,114.), (-21.,115.)] 6852 6852 n=len(lat_long_points) 6853 first_tstep=num.ones(n,num. Int)6853 first_tstep=num.ones(n,num.int) 6854 6854 first_tstep[0]+=1 6855 6855 first_tstep[2]+=1 6856 last_tstep=(time_step_count)*num.ones(n,num. Int)6856 last_tstep=(time_step_count)*num.ones(n,num.int) 6857 6857 last_tstep[0]-=1 6858 6858 6859 gauge_depth=20*num.ones(n,num. Float)6860 ha=2*num.ones((n,time_step_count),num. Float)6859 gauge_depth=20*num.ones(n,num.float) 6860 ha=2*num.ones((n,time_step_count),num.float) 6861 6861 ha[0]=num.arange(0,time_step_count) 6862 6862 ha[1]=num.arange(time_step_count,2*time_step_count) 6863 6863 ha[2]=num.arange(2*time_step_count,3*time_step_count) 6864 6864 ha[3]=num.arange(3*time_step_count,4*time_step_count) 6865 ua=5*num.ones((n,time_step_count),num. Float)6866 va=-10*num.ones((n,time_step_count),num. Float)6865 ua=5*num.ones((n,time_step_count),num.float) 6866 va=-10*num.ones((n,time_step_count),num.float) 6867 6867 6868 6868 base_name, files = self.write_mux2(lat_long_points, … … 6914 6914 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6915 6915 n=len(lat_long_points) 6916 first_tstep=num.ones(n,num. Int)6916 first_tstep=num.ones(n,num.int) 6917 6917 first_tstep[0]+=1 6918 6918 first_tstep[2]+=1 6919 last_tstep=(time_step_count)*num.ones(n,num. Int)6919 last_tstep=(time_step_count)*num.ones(n,num.int) 6920 6920 last_tstep[0]-=1 6921 6921 6922 gauge_depth=20*num.ones(n,num. Float)6923 ha=2*num.ones((n,time_step_count),num. Float)6922 gauge_depth=20*num.ones(n,num.float) 6923 ha=2*num.ones((n,time_step_count),num.float) 6924 6924 ha[0]=num.arange(0,time_step_count) 6925 6925 ha[1]=num.arange(time_step_count,2*time_step_count) 6926 6926 ha[2]=num.arange(2*time_step_count,3*time_step_count) 6927 6927 ha[3]=num.arange(3*time_step_count,4*time_step_count) 6928 ua=5*num.ones((n,time_step_count),num. Float)6929 va=-10*num.ones((n,time_step_count),num. Float)6928 ua=5*num.ones((n,time_step_count),num.float) 6929 va=-10*num.ones((n,time_step_count),num.float) 6930 6930 6931 6931 # Create two identical mux files to be combined by urs2sts … … 7016 7016 #momentum = velocity_ua *(stage+depth) 7017 7017 7018 depth=num.zeros((len(lat_long_points),time_step_count),num. Float)7018 depth=num.zeros((len(lat_long_points),time_step_count),num.float) 7019 7019 for i in range(len(lat_long_points)): 7020 7020 depth[i]=gauge_depth[i]+tide+2.0*ha[i] … … 7386 7386 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 7387 7387 n=len(lat_long_points) 7388 first_tstep=num.ones(n,num. Int)7388 first_tstep=num.ones(n,num.int) 7389 7389 first_tstep[0]+=1 7390 7390 first_tstep[2]+=1 7391 last_tstep=(time_step_count)*num.ones(n,num. Int)7391 last_tstep=(time_step_count)*num.ones(n,num.int) 7392 7392 last_tstep[0]-=1 7393 7393 7394 gauge_depth=20*num.ones(n,num. Float)7395 ha=2*num.ones((n,time_step_count),num. Float)7394 gauge_depth=20*num.ones(n,num.float) 7395 ha=2*num.ones((n,time_step_count),num.float) 7396 7396 ha[0]=num.arange(0,time_step_count) 7397 7397 ha[1]=num.arange(time_step_count,2*time_step_count) 7398 7398 ha[2]=num.arange(2*time_step_count,3*time_step_count) 7399 7399 ha[3]=num.arange(3*time_step_count,4*time_step_count) 7400 ua=5*num.ones((n,time_step_count),num. Float)7401 va=-10*num.ones((n,time_step_count),num. Float)7400 ua=5*num.ones((n,time_step_count),num.float) 7401 va=-10*num.ones((n,time_step_count),num.float) 7402 7402 7403 7403 # Create two identical mux files to be combined by urs2sts … … 7530 7530 #momentum = velocity_ua *(stage+depth) 7531 7531 7532 depth=num.zeros((len(lat_long_points),time_step_count),num. Float)7532 depth=num.zeros((len(lat_long_points),time_step_count),num.float) 7533 7533 for i in range(len(lat_long_points)): 7534 7534 depth[i]=gauge_depth[i]+tide+2.0*ha[i] … … 7573 7573 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 7574 7574 n=len(lat_long_points) 7575 first_tstep=num.ones(n,num. Int)7575 first_tstep=num.ones(n,num.int) 7576 7576 first_tstep[0]+=1 7577 7577 first_tstep[2]+=1 7578 last_tstep=(time_step_count)*num.ones(n,num. Int)7578 last_tstep=(time_step_count)*num.ones(n,num.int) 7579 7579 last_tstep[0]-=1 7580 7580 7581 gauge_depth=20*num.ones(n,num. Float)7582 ha=2*num.ones((n,time_step_count),num. Float)7581 gauge_depth=20*num.ones(n,num.float) 7582 ha=2*num.ones((n,time_step_count),num.float) 7583 7583 ha[0]=num.arange(0,time_step_count) 7584 7584 ha[1]=num.arange(time_step_count,2*time_step_count) 7585 7585 ha[2]=num.arange(2*time_step_count,3*time_step_count) 7586 7586 ha[3]=num.arange(3*time_step_count,4*time_step_count) 7587 ua=5*num.ones((n,time_step_count),num. Float)7588 va=-10*num.ones((n,time_step_count),num. Float)7587 ua=5*num.ones((n,time_step_count),num.float) 7588 va=-10*num.ones((n,time_step_count),num.float) 7589 7589 7590 7590 # Create two identical mux files to be combined by urs2sts … … 7669 7669 7670 7670 # Create different timeseries starting and ending at different times 7671 first_tstep=num.ones(n,num. Int)7671 first_tstep=num.ones(n,num.int) 7672 7672 first_tstep[0]+=2 # Point 0 starts at 2 7673 7673 first_tstep[1]+=4 # Point 1 starts at 4 7674 7674 first_tstep[2]+=3 # Point 2 starts at 3 7675 7675 7676 last_tstep=(time_step_count)*num.ones(n,num. Int)7676 last_tstep=(time_step_count)*num.ones(n,num.int) 7677 7677 last_tstep[0]-=1 # Point 0 ends 1 step early 7678 7678 last_tstep[1]-=2 # Point 1 ends 2 steps early … … 7687 7687 7688 7688 # Create varying elevation data (positive values for seafloor) 7689 gauge_depth=20*num.ones(n,num. Float)7689 gauge_depth=20*num.ones(n,num.float) 7690 7690 for i in range(n): 7691 7691 gauge_depth[i] += i**2 … … 7694 7694 7695 7695 # Create data to be written to first mux file 7696 ha0=2*num.ones((n,time_step_count),num. Float)7696 ha0=2*num.ones((n,time_step_count),num.float) 7697 7697 ha0[0]=num.arange(0,time_step_count) 7698 7698 ha0[1]=num.arange(time_step_count,2*time_step_count) 7699 7699 ha0[2]=num.arange(2*time_step_count,3*time_step_count) 7700 7700 ha0[3]=num.arange(3*time_step_count,4*time_step_count) 7701 ua0=5*num.ones((n,time_step_count),num. Float)7702 va0=-10*num.ones((n,time_step_count),num. Float)7701 ua0=5*num.ones((n,time_step_count),num.float) 7702 va0=-10*num.ones((n,time_step_count),num.float) 7703 7703 7704 7704 # Ensure data used to write mux file to be zero when gauges are … … 7731 7731 7732 7732 # Create data to be written to second mux file 7733 ha1=num.ones((n,time_step_count),num. Float)7733 ha1=num.ones((n,time_step_count),num.float) 7734 7734 ha1[0]=num.sin(times_ref) 7735 7735 ha1[1]=2*num.sin(times_ref - 3) … … 7738 7738 ha1[4]=num.sin(2*times_ref-0.7) 7739 7739 7740 ua1=num.zeros((n,time_step_count),num. Float)7740 ua1=num.zeros((n,time_step_count),num.float) 7741 7741 ua1[0]=3*num.cos(times_ref) 7742 7742 ua1[1]=2*num.sin(times_ref-0.7) … … 7744 7744 ua1[4]=2*num.ones(time_step_count) 7745 7745 7746 va1=num.zeros((n,time_step_count),num. Float)7746 va1=num.zeros((n,time_step_count),num.float) 7747 7747 va1[0]=2*num.cos(times_ref-0.87) 7748 va1[1]=3*num.ones(time_step_count )7748 va1[1]=3*num.ones(time_step_count, num.int) #array default# 7749 7749 va1[3]=2*num.sin(times_ref-0.71) 7750 7750 … … 7873 7873 #momentum = velocity_ua *(stage+depth) 7874 7874 7875 depth_ref = num.zeros((len(permutation), time_step_count), num. Float)7875 depth_ref = num.zeros((len(permutation), time_step_count), num.float) 7876 7876 for i in range(len(permutation)): 7877 7877 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 7986 7986 #momentum = velocity_ua *(stage+depth) 7987 7987 7988 depth_ref = num.zeros((len(permutation), time_step_count), num. Float)7988 depth_ref = num.zeros((len(permutation), time_step_count), num.float) 7989 7989 for i in range(len(permutation)): 7990 7990 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 8092 8092 #momentum = velocity_ua *(stage+depth) 8093 8093 8094 depth_ref = num.zeros((len(permutation), time_step_count), num. Float)8094 depth_ref = num.zeros((len(permutation), time_step_count), num.float) 8095 8095 for i in range(len(permutation)): 8096 8096 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 8161 8161 lat_long_points =bounding_polygon[0:3] 8162 8162 n=len(lat_long_points) 8163 first_tstep=num.ones(n,num. Int)8164 last_tstep=(time_step_count)*num.ones(n,num. Int)8163 first_tstep=num.ones(n,num.int) 8164 last_tstep=(time_step_count)*num.ones(n,num.int) 8165 8165 8166 8166 h = 20 … … 8168 8168 u = 10 8169 8169 v = -10 8170 gauge_depth=h*num.ones(n,num. Float)8171 ha=w*num.ones((n,time_step_count),num. Float)8172 ua=u*num.ones((n,time_step_count),num. Float)8173 va=v*num.ones((n,time_step_count),num. Float)8170 gauge_depth=h*num.ones(n,num.float) 8171 ha=w*num.ones((n,time_step_count),num.float) 8172 ua=u*num.ones((n,time_step_count),num.float) 8173 va=v*num.ones((n,time_step_count),num.float) 8174 8174 base_name, files = self.write_mux2(lat_long_points, 8175 8175 time_step_count, time_step, … … 8224 8224 finaltime=time_step*(time_step_count-1) 8225 8225 yieldstep=time_step 8226 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num. Float)8226 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float) 8227 8227 8228 8228 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8250 8250 8251 8251 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8252 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num. Float)8252 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float) 8253 8253 8254 8254 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8305 8305 lat_long_points = bounding_polygon[0:3] 8306 8306 n=len(lat_long_points) 8307 first_tstep=num.ones(n,num. Int)8308 last_tstep=(time_step_count)*num.ones(n,num. Int)8307 first_tstep=num.ones(n,num.int) 8308 last_tstep=(time_step_count)*num.ones(n,num.int) 8309 8309 8310 8310 h = 20 … … 8312 8312 u = 10 8313 8313 v = -10 8314 gauge_depth=h*num.ones(n,num. Float)8315 ha=w*num.ones((n,time_step_count),num. Float)8316 ua=u*num.ones((n,time_step_count),num. Float)8317 va=v*num.ones((n,time_step_count),num. Float)8314 gauge_depth=h*num.ones(n,num.float) 8315 ha=w*num.ones((n,time_step_count),num.float) 8316 ua=u*num.ones((n,time_step_count),num.float) 8317 va=v*num.ones((n,time_step_count),num.float) 8318 8318 base_name, files = self.write_mux2(lat_long_points, 8319 8319 time_step_count, time_step, … … 8377 8377 finaltime = data_finaltime + 10 # Let model time exceed available data 8378 8378 yieldstep = time_step 8379 temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num. Float)8379 temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.float) 8380 8380 8381 8381 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8409 8409 8410 8410 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8411 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num. Float)8411 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float) 8412 8412 8413 8413 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8463 8463 lat_long_points = bounding_polygon[0:3] 8464 8464 n=len(lat_long_points) 8465 first_tstep=num.ones(n,num. Int)8466 last_tstep=(time_step_count)*num.ones(n,num. Int)8465 first_tstep=num.ones(n,num.int) 8466 last_tstep=(time_step_count)*num.ones(n,num.int) 8467 8467 8468 8468 h = 20 … … 8470 8470 u = 10 8471 8471 v = -10 8472 gauge_depth=h*num.ones(n,num. Float)8473 ha=w*num.ones((n,time_step_count),num. Float)8474 ua=u*num.ones((n,time_step_count),num. Float)8475 va=v*num.ones((n,time_step_count),num. Float)8472 gauge_depth=h*num.ones(n,num.float) 8473 ha=w*num.ones((n,time_step_count),num.float) 8474 ua=u*num.ones((n,time_step_count),num.float) 8475 va=v*num.ones((n,time_step_count),num.float) 8476 8476 base_name, files = self.write_mux2(lat_long_points, 8477 8477 time_step_count, time_step, … … 8538 8538 finaltime = data_finaltime + 10 # Let model time exceed available data 8539 8539 yieldstep = time_step 8540 temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num. Float)8540 temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.float) 8541 8541 8542 8542 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8582 8582 lat_long_points.insert(0,[6.0,97.01]) 8583 8583 n=len(lat_long_points) 8584 first_tstep=num.ones(n,num. Int)8585 last_tstep=(time_step_count)*num.ones(n,num. Int)8586 gauge_depth=20*num.ones(n,num. Float)8587 ha=2*num.ones((n,time_step_count),num. Float)8588 ua=10*num.ones((n,time_step_count),num. Float)8589 va=-10*num.ones((n,time_step_count),num. Float)8584 first_tstep=num.ones(n,num.int) 8585 last_tstep=(time_step_count)*num.ones(n,num.int) 8586 gauge_depth=20*num.ones(n,num.float) 8587 ha=2*num.ones((n,time_step_count),num.float) 8588 ua=10*num.ones((n,time_step_count),num.float) 8589 va=-10*num.ones((n,time_step_count),num.float) 8590 8590 base_name, files = self.write_mux2(lat_long_points, 8591 8591 time_step_count, … … 8629 8629 finaltime=time_step*(time_step_count-1) 8630 8630 yieldstep=time_step 8631 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num. Float)8631 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float) 8632 8632 8633 8633 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8641 8641 Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) 8642 8642 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8643 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num. Float)8643 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float) 8644 8644 8645 8645 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8688 8688 time_step = 2 8689 8689 n=len(lat_long_points) 8690 first_tstep=num.ones(n,num. Int)8691 last_tstep=(time_step_count)*num.ones(n,num. Int)8692 gauge_depth=20*num.ones(n,num. Float)8693 ha=2*num.ones((n,time_step_count),num. Float)8694 ua=10*num.ones((n,time_step_count),num. Float)8695 va=-10*num.ones((n,time_step_count),num. Float)8690 first_tstep=num.ones(n,num.int) 8691 last_tstep=(time_step_count)*num.ones(n,num.int) 8692 gauge_depth=20*num.ones(n,num.float) 8693 ha=2*num.ones((n,time_step_count),num.float) 8694 ua=10*num.ones((n,time_step_count),num.float) 8695 va=-10*num.ones((n,time_step_count),num.float) 8696 8696 base_name, files = self.write_mux2(lat_long_points, 8697 8697 time_step_count, … … 8779 8779 finaltime=time_step*(time_step_count-1) 8780 8780 yieldstep=time_step 8781 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num. Float)8781 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float) 8782 8782 8783 8783 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8792 8792 Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) 8793 8793 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8794 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num. Float)8794 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.float) 8795 8795 8796 8796 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8854 8854 8855 8855 n=len(lat_long_points) 8856 first_tstep=num.ones(n,num. Int)8857 last_tstep=(time_step_count)*num.ones(n,num. Int)8858 8859 gauge_depth=20*num.ones(n,num. Float)8860 8861 ha1=num.ones((n,time_step_count),num. Float)8862 ua1=3.*num.ones((n,time_step_count),num. Float)8863 va1=2.*num.ones((n,time_step_count),num. Float)8856 first_tstep=num.ones(n,num.int) 8857 last_tstep=(time_step_count)*num.ones(n,num.int) 8858 8859 gauge_depth=20*num.ones(n,num.float) 8860 8861 ha1=num.ones((n,time_step_count),num.float) 8862 ua1=3.*num.ones((n,time_step_count),num.float) 8863 va1=2.*num.ones((n,time_step_count),num.float) 8864 8864 for i in range(n): 8865 8865 ha1[i]=num.sin(times_ref) … … 8976 8976 finaltime=time_step*(time_step_count-1) 8977 8977 yieldstep=time_step 8978 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num. Float)8978 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.float) 8979 8979 8980 8980 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8991 8991 domain_time.set_boundary({'ocean': Bw,'otherocean': Br}) 8992 8992 8993 temp_time=num.zeros(int(finaltime/yieldstep)+1,num. Float)8993 temp_time=num.zeros(int(finaltime/yieldstep)+1,num.float) 8994 8994 for i, t in enumerate(domain_time.evolve(yieldstep=yieldstep, 8995 8995 finaltime=finaltime, … … 9050 9050 9051 9051 n=len(lat_long_points) 9052 first_tstep=num.ones(n,num. Int)9053 last_tstep=(time_step_count)*num.ones(n,num. Int)9054 9055 gauge_depth=20*num.ones(n,num. Float)9056 9057 ha1=num.ones((n,time_step_count),num. Float)9058 ua1=3.*num.ones((n,time_step_count),num. Float)9059 va1=2.*num.ones((n,time_step_count),num. Float)9052 first_tstep=num.ones(n,num.int) 9053 last_tstep=(time_step_count)*num.ones(n,num.int) 9054 9055 gauge_depth=20*num.ones(n,num.float) 9056 9057 ha1=num.ones((n,time_step_count),num.float) 9058 ua1=3.*num.ones((n,time_step_count),num.float) 9059 va1=2.*num.ones((n,time_step_count),num.float) 9060 9060 for i in range(n): 9061 9061 ha1[i]=num.sin(times_ref) … … 10127 10127 sww.store_header(outfile, times, number_of_volumes, 10128 10128 number_of_points, description='fully sick testing', 10129 verbose=self.verbose,sww_precision=n um.Float)10129 verbose=self.verbose,sww_precision=netcdf_float) 10130 10130 sww.store_triangulation(outfile, points_utm, volumes, 10131 10131 elevation, new_origin=new_origin, … … 10159 10159 sww.store_header(outfile, times, number_of_volumes, 10160 10160 number_of_points, description='fully sick testing', 10161 verbose=self.verbose,sww_precision=n um.Float)10161 verbose=self.verbose,sww_precision=netcdf_float) 10162 10162 sww.store_triangulation(outfile, points_utm, volumes, 10163 10163 elevation, new_origin=new_origin, … … 10195 10195 sww.store_header(outfile, times, number_of_volumes, 10196 10196 number_of_points, description='fully sick testing', 10197 verbose=self.verbose,sww_precision=n um.Float)10197 verbose=self.verbose,sww_precision=netcdf_float) 10198 10198 sww.store_triangulation(outfile, points_utm, volumes, 10199 10199 elevation, new_origin=new_origin, … … 10234 10234 sww.store_header(outfile, times, number_of_volumes, 10235 10235 number_of_points, description='fully sick testing', 10236 verbose=self.verbose,sww_precision=n um.Float)10236 verbose=self.verbose,sww_precision=netcdf_float) 10237 10237 sww.store_triangulation(outfile, points_utm, volumes, 10238 10238 elevation, new_origin=new_origin, … … 10270 10270 sww.store_header(outfile, times, number_of_volumes, 10271 10271 number_of_points, description='fully sick testing', 10272 verbose=self.verbose,sww_precision=n um.Float)10272 verbose=self.verbose,sww_precision=netcdf_float) 10273 10273 sww.store_triangulation(outfile, points_utm, volumes, 10274 10274 elevation, new_origin=new_origin, … … 10629 10629 10630 10630 # Check runup restricted to a polygon 10631 p = num.array([[50,1], [99,1], [99,49], [50,49]] , num.Int) + num.array([E, N], num.Int) #array default#10631 p = num.array([[50,1], [99,1], [99,49], [50,49]]) + num.array([E, N]) 10632 10632 10633 10633 runup = get_maximum_inundation_elevation(swwfile, polygon=p) -
branches/numpy/anuga/shallow_water/test_eq.py
r6157 r6304 1 1 import unittest 2 import Numericas num2 import numpy as num 3 3 from eqf import earthquake_tsunami, Okada_func 4 4 -
branches/numpy/anuga/shallow_water/test_most2nc.py
r6157 r6304 1 1 import unittest 2 import Numericas num2 import numpy as num 3 3 from Scientific.IO.NetCDF import NetCDFFile 4 4 import most2nc -
branches/numpy/anuga/shallow_water/test_shallow_water_domain.py
r6244 r6304 7 7 from anuga.config import g, epsilon 8 8 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a 9 import Numericas num9 import numpy as num 10 10 from anuga.utilities.numerical_tools import mean 11 11 from anuga.utilities.polygon import is_inside_polygon … … 37 37 assert N == len(y) 38 38 39 z = num.zeros(N, num. Float)39 z = num.zeros(N, num.float) 40 40 for i in range(N): 41 41 z[i] = -x[i]/2 #General slope … … 142 142 assert N == len(y) 143 143 144 z = num.zeros(N, num. Float)144 z = num.zeros(N, num.float) 145 145 for i in range(N): 146 146 z[i] = -x[i] #General slope … … 195 195 def scalar_func(t,x,y): 196 196 """Function that returns a scalar. 197 Used to test error message when Numeric array is expected197 Used to test error message when numeric array is expected 198 198 """ 199 199 … … 254 254 #Check error check 255 255 try: 256 rotate(r, num.array([1,1,1] , num.Int)) #array default#256 rotate(r, num.array([1,1,1])) 257 257 except: 258 258 pass … … 263 263 # Individual flux tests 264 264 def test_flux_zero_case(self): 265 ql = num.zeros( 3, num. Float )266 qr = num.zeros( 3, num. Float )267 normal = num.zeros( 2, num. Float )268 edgeflux = num.zeros( 3, num. Float )265 ql = num.zeros( 3, num.float ) 266 qr = num.zeros( 3, num.float ) 267 normal = num.zeros( 2, num.float ) 268 edgeflux = num.zeros( 3, num.float ) 269 269 zl = zr = 0. 270 270 H0 = 0.0 … … 281 281 ql = num.array([w, 0, 0]) 282 282 qr = num.array([w, 0, 0]) 283 edgeflux = num.zeros(3, num. Float)283 edgeflux = num.zeros(3, num.float) 284 284 zl = zr = 0. 285 285 h = w - (zl+zr)/2 … … 312 312 qr = num.array([-0.2, 2, 3]) 313 313 zl = zr = -0.5 314 edgeflux = num.zeros(3, num. Float)314 edgeflux = num.zeros(3, num.float) 315 315 316 316 H0 = 0.0 … … 329 329 zl = zr = -0.375 330 330 331 edgeflux = num.zeros(3, num. Float)331 edgeflux = num.zeros(3, num.float) 332 332 H0 = 0.0 333 333 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) … … 343 343 zl = zr = -0.375 344 344 345 edgeflux = num.zeros(3, num. Float)345 edgeflux = num.zeros(3, num.float) 346 346 H0 = 0.0 347 347 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) … … 357 357 zl = zr = -0.375 358 358 359 edgeflux = num.zeros(3, num. Float)359 edgeflux = num.zeros(3, num.float) 360 360 H0 = 0.0 361 361 max_speed = flux_function(normal, ql, qr, zl, zr, edgeflux, epsilon, g, H0) … … 433 433 assert domain.quantities.has_key(name) 434 434 435 436 assert domain.get_conserved_quantities(0, edge=1) == 0. 435 assert num.alltrue(domain.get_conserved_quantities(0, edge=1) == 0.) 437 436 438 437 … … 709 708 zl=zr=0. # Assume flat bed 710 709 711 edgeflux = num.zeros(3, num. Float)712 edgeflux0 = num.zeros(3, num. Float)713 edgeflux1 = num.zeros(3, num. Float)714 edgeflux2 = num.zeros(3, num. Float)710 edgeflux = num.zeros(3, num.float) 711 edgeflux0 = num.zeros(3, num.float) 712 edgeflux1 = num.zeros(3, num.float) 713 edgeflux2 = num.zeros(3, num.float) 715 714 H0 = 0.0 716 715 … … 797 796 zl=zr=0. #Assume flat bed 798 797 799 edgeflux = num.zeros(3, num. Float)800 edgeflux0 = num.zeros(3, num. Float)801 edgeflux1 = num.zeros(3, num. Float)802 edgeflux2 = num.zeros(3, num. Float)798 edgeflux = num.zeros(3, num.float) 799 edgeflux0 = num.zeros(3, num.float) 800 edgeflux1 = num.zeros(3, num.float) 801 edgeflux2 = num.zeros(3, num.float) 803 802 H0 = 0.0 804 803 … … 905 904 906 905 zl=zr=0 #Assume flat zero bed 907 edgeflux = num.zeros(3, num. Float)908 edgeflux0 = num.zeros(3, num. Float)909 edgeflux1 = num.zeros(3, num. Float)910 edgeflux2 = num.zeros(3, num. Float)906 edgeflux = num.zeros(3, num.float) 907 edgeflux0 = num.zeros(3, num.float) 908 edgeflux1 = num.zeros(3, num.float) 909 edgeflux2 = num.zeros(3, num.float) 911 910 H0 = 0.0 912 911 913 912 914 domain.set_quantity('elevation', zl*num.ones( (4,3) ))913 domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default# 915 914 916 915 … … 988 987 989 988 zl=zr=-3.75 #Assume constant bed (must be less than stage) 990 domain.set_quantity('elevation', zl*num.ones( (4,3) ))991 992 993 edgeflux = num.zeros(3, num. Float)994 edgeflux0 = num.zeros(3, num. Float)995 edgeflux1 = num.zeros(3, num. Float)996 edgeflux2 = num.zeros(3, num. Float)989 domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default# 990 991 992 edgeflux = num.zeros(3, num.float) 993 edgeflux0 = num.zeros(3, num.float) 994 edgeflux1 = num.zeros(3, num.float) 995 edgeflux2 = num.zeros(3, num.float) 997 996 H0 = 0.0 998 997 … … 1071 1070 1072 1071 zl=zr=4 #Too large 1073 domain.set_quantity('elevation', zl*num.ones( (4,3) ))1072 domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default# 1074 1073 domain.set_quantity('stage', [[val0, val0-1, val0-2], 1075 1074 [val1, val1+1, val1], … … 1105 1104 1106 1105 zl=zr=5 1107 domain.set_quantity('elevation', zl*num.ones( (4,3) ))1106 domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default# 1108 1107 domain.set_quantity('stage', [[val0, val0-1, val0-2], 1109 1108 [val1, val1+1, val1], … … 2621 2620 def test_time_dependent_rainfall_using_starttime(self): 2622 2621 2623 rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num. Float)2622 rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float) 2624 2623 2625 2624 a = [0.0, 0.0] … … 2692 2691 2693 2692 2694 rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num. Float)2693 rainfall_poly = ensure_numeric([[1,1], [2,1], [2,2], [1,2]], num.float) 2695 2694 rainfall_poly += [x0, y0] 2696 2695 … … 3142 3141 3143 3142 zl=zr=-3.75 #Assume constant bed (must be less than stage) 3144 domain.set_quantity('elevation', zl*num.ones( (4,3) ))3143 domain.set_quantity('elevation', zl*num.ones( (4,3), num.int )) #array default# 3145 3144 domain.set_quantity('stage', [[val0, val0-1, val0-2], 3146 3145 [val1, val1+1, val1], … … 4560 4559 if V: 4561 4560 #Set centroids as if system had been evolved 4562 L = num.zeros(2*N*N, num. Float)4561 L = num.zeros(2*N*N, num.float) 4563 4562 L[:32] = [7.21205592e-003, 5.35214298e-002, 1.00910824e-002, 4564 4563 5.35439433e-002, 1.00910824e-002, 5.35439433e-002, … … 4573 4572 0.00000000e+000, 5.57305948e-005] 4574 4573 4575 X = num.zeros(2*N*N, num. Float)4574 X = num.zeros(2*N*N, num.float) 4576 4575 X[:32] = [6.48351607e-003, 3.68571894e-002, 8.50733285e-003, 4577 4576 3.68731327e-002, 8.50733285e-003, 3.68731327e-002, … … 4586 4585 0.00000000e+000, 4.57662812e-005] 4587 4586 4588 Y = num.zeros(2*N*N, num. Float)4587 Y = num.zeros(2*N*N, num.float) 4589 4588 Y[:32]=[-1.39463104e-003, 6.15600298e-004, -6.03637382e-004, 4590 4589 6.18272251e-004, -6.03637382e-004, 6.18272251e-004, … … 5691 5690 5692 5691 #print points[0], points[5], points[10], points[15] 5693 assert num.allclose( num.take(points, [0,5,10,15]), 5694 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]) 5692 msg = ('value was %s,\nshould be [[0,0], [1.0/3, 1.0/3], ' 5693 '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15]))) 5694 assert num.allclose(num.take(points, [0,5,10,15]), 5695 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg 5695 5696 5696 5697 … … 5872 5873 5873 5874 #print points[0], points[5], points[10], points[15] 5874 assert num.allclose( num.take(points, [0,5,10,15]), 5875 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]) 5875 msg = ('values was %s,\nshould be [[0,0], [1.0/3, 1.0/3], ' 5876 '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15]))) 5877 assert num.allclose(num.take(points, [0,5,10,15]), 5878 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg 5876 5879 5877 5880 … … 6045 6048 6046 6049 #print points[0], points[5], points[10], points[15] 6047 assert num.allclose( num.take(points, [0,5,10,15]), 6048 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]) 6050 msg = ('value was %s,\nshould be [[0,0], [1.0/3, 1.0/3], ' 6051 '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15]))) 6052 assert num.allclose(num.take(points, [0,5,10,15]), 6053 [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg 6054 6049 6055 6050 6056 … … 6237 6243 6238 6244 bed = domain.quantities['elevation'].vertex_values 6239 stage = num.zeros(bed.shape, num. Float)6245 stage = num.zeros(bed.shape, num.float) 6240 6246 6241 6247 h = 0.3 -
branches/numpy/anuga/shallow_water/test_smf.py
r6157 r6304 1 1 import unittest 2 import Numericas num2 import numpy as num 3 3 from smf import slide_tsunami, slump_tsunami, Double_gaussian 4 4 -
branches/numpy/anuga/shallow_water/test_system.py
r6157 r6304 9 9 10 10 from Scientific.IO.NetCDF import NetCDFFile 11 import Numericas num11 import numpy as num 12 12 13 13 from anuga.shallow_water import Domain … … 34 34 20 13.9773 35 35 """ 36 36 37 tide = 5 37 38 boundary_filename = tempfile.mktemp(".sww") … … 85 86 boundary_filename = self.create_sww_boundary(boundary_starttime) 86 87 filename = tempfile.mktemp(".sww") 87 #print "filename",filename88 88 dir, base = os.path.split(filename) 89 89 senario_name = base[:-4] -
branches/numpy/anuga/shallow_water/test_tsunami_okada.py
r6157 r6304 1 1 import unittest 2 import Numericas num2 import numpy as num 3 3 from tsunami_okada import earthquake_tsunami,Okada_func 4 4 -
branches/numpy/anuga/shallow_water/tsunami_okada.py
r6157 r6304 30 30 """ 31 31 32 import Numericas num32 import numpy as num 33 33 34 34 … … 45 45 zrec=zrec0.get_vertex_values(xy=True) 46 46 47 x0= num.zeros(ns,num. Float)48 y0= num.zeros(ns,num. Float)47 x0= num.zeros(ns,num.float) 48 y0= num.zeros(ns,num.float) 49 49 if ns ==1: 50 50 x0[0]=xi … … 151 151 zrec=self.zrec 152 152 #initialization 153 disp0=num.zeros(3,num. Float)154 strain0=num.zeros(6,num. Float)155 tilt0 = num.zeros(2,num. Float)156 dislocations=num.zeros(ns,num. Float)157 depths=num.zeros(ns,num. Float)158 strikes= num.zeros(ns,num. Float)159 lengths= num.zeros(ns,num. Float)160 slips= num.zeros(ns,num. Float)161 rakes= num.zeros(ns,num. Float)162 widths= num.zeros(ns,num. Float)163 dips= num.zeros(ns,num. Float)164 strikes= num.zeros(ns,num. Float)165 strikes= num.zeros(ns,num. Float)166 strain = num.zeros((N,6),num. Float)167 disp = num.zeros((N,3),num. Float)168 tilt = num.zeros((N,2),num. Float)169 xs =num.zeros(ns,num. Float)170 ys =num.zeros(ns,num. Float)153 disp0=num.zeros(3,num.float) 154 strain0=num.zeros(6,num.float) 155 tilt0 = num.zeros(2,num.float) 156 dislocations=num.zeros(ns,num.float) 157 depths=num.zeros(ns,num.float) 158 strikes= num.zeros(ns,num.float) 159 lengths= num.zeros(ns,num.float) 160 slips= num.zeros(ns,num.float) 161 rakes= num.zeros(ns,num.float) 162 widths= num.zeros(ns,num.float) 163 dips= num.zeros(ns,num.float) 164 strikes= num.zeros(ns,num.float) 165 strikes= num.zeros(ns,num.float) 166 strain = num.zeros((N,6),num.float) 167 disp = num.zeros((N,3),num.float) 168 tilt = num.zeros((N,2),num.float) 169 xs =num.zeros(ns,num.float) 170 ys =num.zeros(ns,num.float) 171 171 z=[] 172 172 if ns==1: … … 378 378 379 379 F0=0.0 380 U=num.zeros((12,1),num. Float)381 DUA=num.zeros((12,1),num. Float)382 DUB=num.zeros((12,1),num. Float)383 DUC=num.zeros((12,1),num. Float)380 U=num.zeros((12,1),num.float) 381 DUA=num.zeros((12,1),num.float) 382 DUB=num.zeros((12,1),num.float) 383 DUC=num.zeros((12,1),num.float) 384 384 385 385 … … 526 526 WZ=self.WZ 527 527 528 DUA=num.zeros((12,1),num. Float)529 DU=num.zeros((12,1),num. Float)530 U=num.zeros((12,1),num. Float)528 DUA=num.zeros((12,1),num.float) 529 DU=num.zeros((12,1),num.float) 530 U=num.zeros((12,1),num.float) 531 531 #----- 532 532 for I in range(0,12): … … 636 636 # DATA PI2/6.283185307179586D0/ 637 637 638 DUB=num.zeros((12,1),num. Float)639 DU=num.zeros((12,1),num. Float)640 U=num.zeros((12,1),num. Float)638 DUB=num.zeros((12,1),num.float) 639 DU=num.zeros((12,1),num.float) 640 U=num.zeros((12,1),num.float) 641 641 642 642 F0=0.0 … … 811 811 812 812 813 DUC=num.zeros((12,1),num. Float)814 DU=num.zeros((12,1),num. Float)815 U=num.zeros((12,1),num. Float)813 DUC=num.zeros((12,1),num.float) 814 DU=num.zeros((12,1),num.float) 815 U=num.zeros((12,1),num.float) 816 816 817 817 F0=0.0 … … 1005 1005 EPS=0.000001 1006 1006 1007 XI=num.zeros(2,num. Float)1008 ET=num.zeros(2,num. Float)1009 KXI=num.zeros(2,num. Float)1010 KET=num.zeros(2,num. Float)1011 U=num.zeros(12,num. Float)1012 DU=num.zeros(12,num. Float)1013 DUA=num.zeros(12,num. Float)1014 DUB=num.zeros(12,num. Float)1015 DUC=num.zeros(12,num. Float)1007 XI=num.zeros(2,num.float) 1008 ET=num.zeros(2,num.float) 1009 KXI=num.zeros(2,num.float) 1010 KET=num.zeros(2,num.float) 1011 U=num.zeros(12,num.float) 1012 DU=num.zeros(12,num.float) 1013 DUA=num.zeros(12,num.float) 1014 DUB=num.zeros(12,num.float) 1015 DUC=num.zeros(12,num.float) 1016 1016 1017 1017 #----- … … 1211 1211 1212 1212 1213 U=num.zeros(12,num. Float)1214 DU=num.zeros(12,num. Float)1215 DUA=num.zeros(12,num. Float)1213 U=num.zeros(12,num.float) 1214 DU=num.zeros(12,num.float) 1215 DUA=num.zeros(12,num.float) 1216 1216 F0 =0.0 1217 1217 F2=2.0 … … 1342 1342 # DATA F0,F1,F2,PI2/0.D0,1.D0,2.D0,6.283185307179586D0/ 1343 1343 1344 DUB=num.zeros(12,num. Float)1345 DU=num.zeros(12,num. Float)1346 U=num.zeros(12,num. Float)1344 DUB=num.zeros(12,num.float) 1345 DU=num.zeros(12,num.float) 1346 U=num.zeros(12,num.float) 1347 1347 1348 1348 F0=0.0 … … 1507 1507 # DATA F0,F1,F2,F3,PI2/0.D0,1.D0,2.D0,3.D0,6.283185307179586D0/ 1508 1508 1509 DUC=num.zeros(12,num. Float)1510 DU=num.zeros(12,num. Float)1511 U=num.zeros(12,num. Float)1509 DUC=num.zeros(12,num.float) 1510 DU=num.zeros(12,num.float) 1511 U=num.zeros(12,num.float) 1512 1512 1513 1513 F0=0.0 -
branches/numpy/anuga/shallow_water/urs_ext.c
r5972 r6304 5 5 6 6 #include "Python.h" 7 #include " Numeric/arrayobject.h"7 #include "numpy/arrayobject.h" 8 8 #include "structure.h" 9 9 #include "math.h"
Note: See TracChangeset
for help on using the changeset viewer.