Changeset 6157
- Timestamp:
- Jan 13, 2009, 5:42:30 PM (16 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/benchmark_sww2dem.py
r6086 r6157 25 25 26 26 from Scientific.IO.NetCDF import NetCDFFile 27 from Numeric import array, Float 27 import Numeric 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 = array(range(len(mesh_dict["vertices"])))103 elevation = num.array(range(len(mesh_dict["vertices"]))) 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= Float)113 len(mesh_dict["vertices"]),sww_precision=num.Float) 114 114 sww.store_triangulation(fid, 115 115 mesh_dict["vertices"], mesh_dict['triangles'], -
anuga_core/source/anuga/shallow_water/data_manager.py
r6132 r6157 61 61 from os import sep, path, remove, mkdir, access, F_OK, W_OK, getcwd 62 62 63 from Numeric import concatenate, array, Float, Int, Int32, resize, \ 64 sometrue, searchsorted, zeros, allclose, around, reshape, \ 65 transpose, sort, NewAxis, ArrayType, compress, take, arange, \ 66 argmax, alltrue, shape, Float32, size 63 import Numeric as num 67 64 68 65 from Scientific.IO.NetCDF import NetCDFFile … … 345 342 def __init__(self, domain, mode=netcdf_mode_w, max_size=2000000000, recursion=False): 346 343 from Scientific.IO.NetCDF import NetCDFFile 347 from Numeric import Int, Float, Float32 348 349 self.precision = Float32 #Use single precision for quantities 344 345 self.precision = num.Float32 #Use single precision for quantities 350 346 self.recursion = recursion 351 347 self.mode = mode … … 425 421 426 422 from Scientific.IO.NetCDF import NetCDFFile 427 from Numeric import concatenate, Int428 423 429 424 domain = self.domain … … 443 438 444 439 # store the connectivity data 445 points = concatenate( (X[:,NewAxis],Y[:,NewAxis]), axis=1 )440 points = num.concatenate( (X[:,num.NewAxis],Y[:,num.NewAxis]), axis=1 ) 446 441 self.writer.store_triangulation(fid, 447 442 points, 448 443 # V.astype(volumes.typecode()), 449 V.astype( Float32),444 V.astype(num.Float32), 450 445 Z, 451 446 points_georeference=\ … … 466 461 from time import sleep 467 462 from os import stat 468 from Numeric import choose469 463 470 464 if names is None: … … 563 557 564 558 storable_indices = (A-z[:] >= self.minimum_storable_height) 565 stage = choose(storable_indices, (z[:], A))559 stage = num.choose(storable_indices, (z[:], A)) 566 560 567 561 # Define a zero vector of same size and type as A 568 562 # for use with momenta 569 null = zeros(size(A), A.typecode())563 null = num.zeros(num.size(A), A.typecode()) 570 564 571 565 # Get xmomentum where depth exceeds minimum_storable_height … … 573 567 xmom, _ = Q.get_vertex_values(xy=False, 574 568 precision=self.precision) 575 xmomentum = choose(storable_indices, (null, xmom))569 xmomentum = num.choose(storable_indices, (null, xmom)) 576 570 577 571 … … 580 574 ymom, _ = Q.get_vertex_values(xy=False, 581 575 precision=self.precision) 582 ymomentum = choose(storable_indices, (null, ymom))576 ymomentum = num.choose(storable_indices, (null, ymom)) 583 577 584 578 # Write quantities to underlying data file … … 627 621 def __init__(self, domain, mode=netcdf_mode_w): 628 622 from Scientific.IO.NetCDF import NetCDFFile 629 from Numeric import Int, Float, Float 630 631 self.precision = Float #Use full precision 623 624 self.precision = num.Float #Use full precision 632 625 633 626 Data_format.__init__(self, domain, 'sww', mode) … … 657 650 658 651 659 fid.createVariable('volumes', Int, ('number_of_volumes',660 'number_of_vertices'))652 fid.createVariable('volumes', num.Int, ('number_of_volumes', 653 'number_of_vertices')) 661 654 662 655 fid.createVariable('time', self.precision, ('number_of_timesteps',)) … … 680 673 681 674 from Scientific.IO.NetCDF import NetCDFFile 682 from Numeric import concatenate683 675 684 676 domain = self.domain … … 1151 1143 Y = {} 1152 1144 for key in X.keys(): 1153 Y[key] = array([float(x) for x in X[key]])1145 Y[key] = num.array([float(x) for x in X[key]]) 1154 1146 1155 1147 return Y … … 1269 1261 1270 1262 from Scientific.IO.NetCDF import NetCDFFile 1271 from Numeric import Float, zeros1272 1263 1273 1264 # Get NetCDF … … 1284 1275 1285 1276 M = size #Number of lines 1286 xx = zeros((M,3),Float)1287 yy = zeros((M,3),Float)1288 zz = zeros((M,3),Float)1277 xx = num.zeros((M,3), num.Float) 1278 yy = num.zeros((M,3), num.Float) 1279 zz = num.zeros((M,3), num.Float) 1289 1280 1290 1281 for i in range(M): … … 1324 1315 import glob, os 1325 1316 from anuga.config import data_dir 1326 from Numeric import zeros, Float1327 1317 1328 1318 # Get bathymetry and x,y's … … 1330 1320 1331 1321 M = len(lines) #Number of lines 1332 x = zeros((M,3),Float)1333 y = zeros((M,3),Float)1334 z = zeros((M,3),Float)1322 x = num.zeros((M,3), num.Float) 1323 y = num.zeros((M,3), num.Float) 1324 z = num.zeros((M,3), num.Float) 1335 1325 1336 1326 for i, line in enumerate(lines): … … 1524 1514 import os 1525 1515 from Scientific.IO.NetCDF import NetCDFFile 1526 from Numeric import Float, zeros, reshape, sum1527 1516 1528 1517 root = basename_in … … 1591 1580 outfile.nrows = nrows 1592 1581 1593 dem_elevation_r = reshape(dem_elevation, (nrows, ncols))1582 dem_elevation_r = num.reshape(dem_elevation, (nrows, ncols)) 1594 1583 totalnopoints = nrows*ncols 1595 1584 … … 1640 1629 1641 1630 # Variable definitions 1642 outfile.createVariable('points', Float, ('number_of_points',1643 'number_of_dimensions'))1644 outfile.createVariable('elevation', Float, ('number_of_points',))1631 outfile.createVariable('points', num.Float, ('number_of_points', 1632 'number_of_dimensions')) 1633 outfile.createVariable('elevation', num.Float, ('number_of_points',)) 1645 1634 1646 1635 # Get handles to the variables … … 1660 1649 1661 1650 v = dem_elevation_r[i,index1:index2+1] 1662 no_NODATA = sum(v == NODATA_value)1651 no_NODATA = num.sum(v == NODATA_value) 1663 1652 if no_NODATA > 0: 1664 1653 newcols = lenv - no_NODATA # ncols_in_bounding_box - no_NODATA … … 1666 1655 newcols = lenv # ncols_in_bounding_box 1667 1656 1668 telev = zeros(newcols,Float)1669 tpoints = zeros((newcols, 2),Float)1657 telev = num.zeros(newcols, num.Float) 1658 tpoints = num.zeros((newcols, 2), num.Float) 1670 1659 1671 1660 local_index = 0 … … 1789 1778 import os 1790 1779 from Scientific.IO.NetCDF import NetCDFFile 1791 from Numeric import Float, zeros, reshape1792 1780 1793 1781 root = basename_in … … 2133 2121 2134 2122 import sys 2135 from Numeric import array, Float, concatenate, NewAxis, zeros, reshape2136 from Numeric import array2string, sometrue2137 2123 2138 2124 from anuga.utilities.polygon import inside_polygon, outside_polygon, \ … … 2254 2240 #q has a time component, must be reduced alongthe temporal dimension 2255 2241 if verbose: print 'Reducing quantity %s' %quantity 2256 q_reduced = zeros(number_of_points,Float)2242 q_reduced = num.zeros(number_of_points, num.Float) 2257 2243 2258 2244 if timestep is not None: … … 2314 2300 y = y + yllcorner - newyllcorner 2315 2301 2316 vertex_points = concatenate ((x[:,NewAxis], y[:,NewAxis]), axis=1)2302 vertex_points = num.concatenate ((x[:,num.NewAxis], y[:,num.NewAxis]), axis=1) 2317 2303 assert len(vertex_points.shape) == 2 2318 2304 2319 grid_points = zeros ((ncols*nrows, 2),Float)2305 grid_points = num.zeros ((ncols*nrows, 2), num.Float) 2320 2306 2321 2307 for i in xrange(nrows): … … 2359 2345 if format.lower() == 'ers': 2360 2346 # setup ERS header information 2361 grid_values = reshape(grid_values, (nrows, ncols))2347 grid_values = num.reshape(grid_values, (nrows, ncols)) 2362 2348 header = {} 2363 2349 header['datum'] = '"' + datum + '"' … … 2426 2412 slice = grid_values[base_index:base_index+ncols] 2427 2413 #s = array2string(slice, max_line_width=sys.maxint) 2428 s = array2string(slice, max_line_width=sys.maxint,2429 precision=number_of_decimal_places)2414 s = num.array2string(slice, max_line_width=sys.maxint, 2415 precision=number_of_decimal_places) 2430 2416 ascid.write(s[1:-1] + '\n') 2431 2417 … … 2543 2529 2544 2530 import sys 2545 from Numeric import array, Float, concatenate, NewAxis, zeros, reshape2546 from Numeric import array2string, sometrue2547 2531 from anuga.utilities.polygon import inside_polygon, outside_polygon, \ 2548 2532 separate_points_by_polygon … … 2631 2615 if verbose: print 'Reducing quantity %s' % quantity 2632 2616 2633 q_reduced = zeros(number_of_points,Float)2617 q_reduced = num.zeros(number_of_points, num.Float) 2634 2618 for k in range(number_of_points): 2635 2619 q_reduced[k] = reduction(q[:,k]) … … 2645 2629 2646 2630 # Create grid and update xll/yll corner and x,y 2647 vertex_points = concatenate((x[:, NewAxis], y[:,NewAxis]), axis=1)2631 vertex_points = num.concatenate((x[:, num.NewAxis], y[:, num.NewAxis]), axis=1) 2648 2632 assert len(vertex_points.shape) == 2 2649 2633 … … 2748 2732 import os 2749 2733 from Scientific.IO.NetCDF import NetCDFFile 2750 from Numeric import Float, array2751 2734 2752 2735 root = basename_in … … 2866 2849 2867 2850 # variable definitions 2868 fid.createVariable('elevation', Float, ('number_of_rows',2869 'number_of_columns'))2851 fid.createVariable('elevation', num.Float, ('number_of_rows', 2852 'number_of_columns')) 2870 2853 2871 2854 # Get handles to the variables … … 2878 2861 if verbose and i % ((n+10)/10) == 0: 2879 2862 print 'Processing row %d of %d' % (i, nrows) 2880 elevation[i, :] = array([float(x) for x in fields])2863 elevation[i, :] = num.array([float(x) for x in fields]) 2881 2864 2882 2865 fid.close() … … 2946 2929 import os 2947 2930 from Scientific.IO.NetCDF import NetCDFFile 2948 from Numeric import Float, Int, Int32, searchsorted, zeros, array 2949 from Numeric import allclose, around 2950 2951 precision = Float 2931 2932 precision = num.Float 2952 2933 2953 2934 msg = 'Must use latitudes and longitudes for minlat, maxlon etc' … … 3022 3003 3023 3004 # Precision used by most for lat/lon is 4 or 5 decimals 3024 e_lat = around(file_e.variables[dim_e_latitude][:], 5)3025 e_lon = around(file_e.variables[dim_e_longitude][:], 5)3005 e_lat = num.around(file_e.variables[dim_e_latitude][:], 5) 3006 e_lon = num.around(file_e.variables[dim_e_longitude][:], 5) 3026 3007 3027 3008 # Check that files are compatible 3028 assert allclose(latitudes, file_u.variables[dim_u_latitude])3029 assert allclose(latitudes, file_v.variables[dim_v_latitude])3030 assert allclose(latitudes, e_lat)3031 3032 assert allclose(longitudes, file_u.variables[dim_u_longitude])3033 assert allclose(longitudes, file_v.variables[dim_v_longitude])3034 assert allclose(longitudes, e_lon)3009 assert num.allclose(latitudes, file_u.variables[dim_u_latitude]) 3010 assert num.allclose(latitudes, file_v.variables[dim_v_latitude]) 3011 assert num.allclose(latitudes, e_lat) 3012 3013 assert num.allclose(longitudes, file_u.variables[dim_u_longitude]) 3014 assert num.allclose(longitudes, file_v.variables[dim_v_longitude]) 3015 assert num.allclose(longitudes, e_lon) 3035 3016 3036 3017 if mint is None: … … 3038 3019 mint = times[0] 3039 3020 else: 3040 jmin = searchsorted(times, mint)3021 jmin = num.searchsorted(times, mint) 3041 3022 3042 3023 if maxt is None: … … 3044 3025 maxt = times[-1] 3045 3026 else: 3046 jmax = searchsorted(times, maxt)3027 jmax = num.searchsorted(times, maxt) 3047 3028 3048 3029 kmin, kmax, lmin, lmax = _get_min_max_indexes(latitudes[:], … … 3089 3070 3090 3071 #Cleanup 3091 from Numeric import sometrue3092 3093 3072 missing = (amplitudes == nan_ha) 3094 if sometrue (missing):3073 if num.sometrue (missing): 3095 3074 if fail_on_NaN: 3096 3075 msg = 'NetCDFFile %s contains missing values' \ … … 3101 3080 3102 3081 missing = (uspeed == nan_ua) 3103 if sometrue (missing):3082 if num.sometrue (missing): 3104 3083 if fail_on_NaN: 3105 3084 msg = 'NetCDFFile %s contains missing values' \ … … 3110 3089 3111 3090 missing = (vspeed == nan_va) 3112 if sometrue (missing):3091 if num.sometrue (missing): 3113 3092 if fail_on_NaN: 3114 3093 msg = 'NetCDFFile %s contains missing values' \ … … 3119 3098 3120 3099 missing = (elevations == nan_e) 3121 if sometrue (missing):3100 if num.sometrue (missing): 3122 3101 if fail_on_NaN: 3123 3102 msg = 'NetCDFFile %s contains missing values' \ … … 3187 3166 sww.store_header(outfile, times, number_of_volumes, 3188 3167 number_of_points, description=description, 3189 verbose=verbose, sww_precision= Float)3168 verbose=verbose, sww_precision=num.Float) 3190 3169 3191 3170 # Store 3192 3171 from anuga.coordinate_transforms.redfearn import redfearn 3193 x = zeros(number_of_points,Float) #Easting3194 y = zeros(number_of_points,Float) #Northing3172 x = num.zeros(number_of_points, num.Float) #Easting 3173 y = num.zeros(number_of_points, num.Float) #Northing 3195 3174 3196 3175 if verbose: print 'Making triangular grid' … … 3226 3205 volumes.append([v4,v3,v2]) #Lower element 3227 3206 3228 volumes = array(volumes)3207 volumes = num.array(volumes) 3229 3208 3230 3209 if origin is None: … … 3242 3221 3243 3222 #FIXME use the Write_sww instance(sww) to write this info 3244 from Numeric import resize 3245 z = resize(z, outfile.variables['z'][:].shape) 3223 z = num.resize(z, outfile.variables['z'][:].shape) 3246 3224 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 3247 3225 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() 3248 3226 outfile.variables['z'][:] = z #FIXME HACK for bacwards compat. 3249 3227 outfile.variables['elevation'][:] = z 3250 outfile.variables['volumes'][:] = volumes.astype( Int32) #For Opteron 643228 outfile.variables['volumes'][:] = volumes.astype(num.Int32) #For Opteron 64 3251 3229 3252 3230 #Time stepping … … 3331 3309 3332 3310 import time, calendar 3333 from Numeric import array3334 3311 from anuga.config import time_format 3335 3312 from anuga.utilities.numerical_tools import ensure_numeric … … 3371 3348 3372 3349 # Read times proper 3373 from Numeric import zeros, Float, alltrue3374 3350 from anuga.config import time_format 3375 3351 import time, calendar … … 3382 3358 d = len(q) 3383 3359 3384 T = zeros(N,Float) # Time3385 Q = zeros((N, d),Float) # Values3360 T = num.zeros(N, num.Float) # Time 3361 Q = num.zeros((N, d), num.Float) # Values 3386 3362 3387 3363 for i, line in enumerate(lines): … … 3398 3374 msg = 'File %s must list time as a monotonuosly ' % filename 3399 3375 msg += 'increasing sequence' 3400 assert alltrue(T[1:] - T[:-1] > 0), msg3376 assert num.alltrue(T[1:] - T[:-1] > 0), msg 3401 3377 3402 3378 #Create NetCDF file … … 3419 3395 fid.createDimension('number_of_timesteps', len(T)) 3420 3396 3421 fid.createVariable('time', Float, ('number_of_timesteps',))3397 fid.createVariable('time', num.Float, ('number_of_timesteps',)) 3422 3398 3423 3399 fid.variables['time'][:] = T … … 3429 3405 name = 'Attribute%d' % i 3430 3406 3431 fid.createVariable(name, Float, ('number_of_timesteps',))3407 fid.createVariable(name, num.Float, ('number_of_timesteps',)) 3432 3408 fid.variables[name][:] = Q[:,i] 3433 3409 … … 3488 3464 from Scientific.IO.NetCDF import NetCDFFile 3489 3465 from shallow_water import Domain 3490 from Numeric import asarray, transpose, resize3491 3466 3492 3467 # initialise NaN. … … 3511 3486 starttime = fid.starttime[0] 3512 3487 volumes = fid.variables['volumes'][:] # Connectivity 3513 coordinates = transpose(asarray([x.tolist(), y.tolist()]))3488 coordinates = num.transpose(num.asarray([x.tolist(), y.tolist()])) 3514 3489 # FIXME (Ole): Something like this might be better: 3515 3490 # concatenate((x, y), axis=1) 3516 # or concatenate((x[:, NewAxis], x[:,NewAxis]), axis=1)3491 # or concatenate((x[:,num.NewAxis], x[:,num.NewAxis]), axis=1) 3517 3492 3518 3493 conserved_quantities = [] … … 3608 3583 X = (X*data) + (data==0)*NaN_filler 3609 3584 if unique: 3610 X = resize(X, (len(X)/3, 3))3585 X = num.resize(X, (len(X)/3, 3)) 3611 3586 domain.set_quantity(quantity, X) 3612 3587 # … … 3633 3608 X = (X*data) + (data==0)*NaN_filler 3634 3609 if unique: 3635 X = resize(X, (X.shape[0]/3, 3))3610 X = num.resize(X, (X.shape[0]/3, 3)) 3636 3611 domain.set_quantity(quantity, X) 3637 3612 … … 3702 3677 # @param boundary 3703 3678 def weed(coordinates, volumes, boundary=None): 3704 if type(coordinates) == ArrayType:3679 if type(coordinates) == num.ArrayType: 3705 3680 coordinates = coordinates.tolist() 3706 if type(volumes) == ArrayType:3681 if type(volumes) == num.ArrayType: 3707 3682 volumes = volumes.tolist() 3708 3683 … … 3781 3756 import os 3782 3757 from Scientific.IO.NetCDF import NetCDFFile 3783 from Numeric import Float, zeros, sum, reshape, equal3784 3758 3785 3759 root = basename_in … … 3851 3825 3852 3826 # variable definition 3853 outfile.createVariable('elevation', Float, ('number_of_points',))3827 outfile.createVariable('elevation', num.Float, ('number_of_points',)) 3854 3828 3855 3829 # Get handle to the variable 3856 3830 elevation = outfile.variables['elevation'] 3857 3831 3858 dem_elevation_r = reshape(dem_elevation, (nrows, ncols))3832 dem_elevation_r = num.reshape(dem_elevation, (nrows, ncols)) 3859 3833 3860 3834 #Store data … … 3864 3838 3865 3839 lower_index = global_index 3866 telev = zeros(ncols_new,Float)3840 telev = num.zeros(ncols_new, num.Float) 3867 3841 local_index = 0 3868 3842 trow = i * cellsize_ratio … … 3876 3850 #decimated dem to NODATA_value, else compute decimated 3877 3851 #value using stencil 3878 if sum(sum(equal(tmp, NODATA_value))) > 0:3852 if num.sum(num.sum(num.equal(tmp, NODATA_value))) > 0: 3879 3853 telev[local_index] = NODATA_value 3880 3854 else: 3881 telev[local_index] = sum(sum(tmp * stencil))3855 telev[local_index] = num.sum(num.sum(tmp * stencil)) 3882 3856 3883 3857 global_index += 1 … … 3992 3966 from anuga.coordinate_transforms.redfearn import redfearn 3993 3967 3994 precision = Float # So if we want to change the precision its done here3968 precision = num.Float # So if we want to change the precision its done here 3995 3969 3996 3970 # go in to the bath dir and load the only file, … … 4093 4067 ################################# 4094 4068 4095 outfile.createVariable('volumes', Int, ('number_of_volumes',4096 'number_of_vertices'))4069 outfile.createVariable('volumes', num.Int, ('number_of_volumes', 4070 'number_of_vertices')) 4097 4071 4098 4072 outfile.createVariable('time', precision, ('number_of_timesteps',)) … … 4110 4084 from anuga.coordinate_transforms.redfearn import redfearn 4111 4085 4112 x = zeros(number_of_points,Float) #Easting4113 y = zeros(number_of_points,Float) #Northing4086 x = num.zeros(number_of_points, num.Float) #Easting 4087 y = num.zeros(number_of_points, num.Float) #Northing 4114 4088 4115 4089 if verbose: print 'Making triangular grid' … … 4147 4121 volumes.append([v4,v2,v3]) #Lower element 4148 4122 4149 volumes = array(volumes)4123 volumes = num.array(volumes) 4150 4124 4151 4125 geo_ref = Geo_reference(refzone, min(x), min(y)) … … 4165 4139 print 'geo_ref: ', geo_ref 4166 4140 4167 z = resize(bath_grid,outfile.variables['z'][:].shape)4141 z = num.resize(bath_grid,outfile.variables['z'][:].shape) 4168 4142 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 4169 4143 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() … … 4172 4146 outfile.variables['z'][:] = z 4173 4147 outfile.variables['elevation'][:] = z 4174 outfile.variables['volumes'][:] = volumes.astype( Int32) # On Opteron 644148 outfile.variables['volumes'][:] = volumes.astype(num.Int32) # On Opteron 64 4175 4149 4176 4150 stage = outfile.variables['stage'] … … 4198 4172 # handle missing values 4199 4173 missing = (elevation_grid == elevation_meta['NODATA_value']) 4200 if sometrue (missing):4174 if num.sometrue (missing): 4201 4175 if fail_on_NaN: 4202 4176 msg = 'File %s contains missing values' \ … … 4254 4228 longitudes = ensure_numeric(longitudes) 4255 4229 4256 assert allclose(sort(longitudes), longitudes)4230 assert num.allclose(num.sort(longitudes), longitudes) 4257 4231 4258 4232 #print latitudes[0],longitudes[0] … … 4261 4235 4262 4236 lat_ascending = True 4263 if not allclose(sort(latitudes), latitudes):4237 if not num.allclose(num.sort(latitudes), latitudes): 4264 4238 lat_ascending = False 4265 4239 # reverse order of lat, so it's in ascending order 4266 4240 latitudes = latitudes[::-1] 4267 assert allclose(sort(latitudes), latitudes)4241 assert num.allclose(num.sort(latitudes), latitudes) 4268 4242 4269 4243 largest_lat_index = len(latitudes)-1 … … 4273 4247 lat_min_index = 0 4274 4248 else: 4275 lat_min_index = searchsorted(latitudes, minlat)-14249 lat_min_index = num.searchsorted(latitudes, minlat)-1 4276 4250 if lat_min_index <0: 4277 4251 lat_min_index = 0 … … 4280 4254 lat_max_index = largest_lat_index #len(latitudes) 4281 4255 else: 4282 lat_max_index = searchsorted(latitudes, maxlat)4256 lat_max_index = num.searchsorted(latitudes, maxlat) 4283 4257 if lat_max_index > largest_lat_index: 4284 4258 lat_max_index = largest_lat_index … … 4287 4261 lon_min_index = 0 4288 4262 else: 4289 lon_min_index = searchsorted(longitudes, minlon)-14263 lon_min_index = num.searchsorted(longitudes, minlon)-1 4290 4264 if lon_min_index <0: 4291 4265 lon_min_index = 0 … … 4294 4268 lon_max_index = len(longitudes) 4295 4269 else: 4296 lon_max_index = searchsorted(longitudes, maxlon)4270 lon_max_index = num.searchsorted(longitudes, maxlon) 4297 4271 4298 4272 # Reversing the indexes, if the lat array is decending … … 4349 4323 cells = line.split() 4350 4324 assert len(cells) == ncols 4351 grid.append( array([float(x) for x in cells]))4352 grid = array(grid)4325 grid.append(num.array([float(x) for x in cells])) 4326 grid = num.array(grid) 4353 4327 4354 4328 return {'xllcorner':xllcorner, … … 4364 4338 lat_name = 'LAT' 4365 4339 time_name = 'TIME' 4366 precision = Float # So if we want to change the precision its done here4340 precision = num.Float # So if we want to change the precision its done here 4367 4341 4368 4342 ## … … 4645 4619 lonlatdep = p_array.array('f') 4646 4620 lonlatdep.read(mux_file, columns * points_num) 4647 lonlatdep = array(lonlatdep, typecode=Float)4648 lonlatdep = reshape(lonlatdep, (points_num, columns))4621 lonlatdep = num.array(lonlatdep, typecode=num.Float) 4622 lonlatdep = num.reshape(lonlatdep, (points_num, columns)) 4649 4623 4650 4624 lon, lat, depth = lon_lat2grid(lonlatdep) … … 4674 4648 hz_p_array = p_array.array('f') 4675 4649 hz_p_array.read(mux_file, points_num) 4676 hz_p = array(hz_p_array, typecode=Float)4677 hz_p = reshape(hz_p, (len(lon), len(lat)))4678 hz_p = transpose(hz_p) # mux has lat varying fastest, nc has long v.f.4650 hz_p = num.array(hz_p_array, typecode=num.Float) 4651 hz_p = num.reshape(hz_p, (len(lon), len(lat))) 4652 hz_p = num.transpose(hz_p) # mux has lat varying fastest, nc has long v.f. 4679 4653 4680 4654 #write time slice to nc file … … 4711 4685 outfile.variables[lat_name][:] = ensure_numeric(lat) 4712 4686 4713 depth = reshape(depth_vector, (len(lat), len(lon)))4687 depth = num.reshape(depth_vector, (len(lat), len(lon))) 4714 4688 outfile.variables[zname][:] = depth 4715 4689 … … 4772 4746 QUANTITY = 2 4773 4747 4774 long_lat_dep = ensure_numeric(long_lat_dep, Float)4748 long_lat_dep = ensure_numeric(long_lat_dep, num.Float) 4775 4749 4776 4750 num_points = long_lat_dep.shape[0] … … 4799 4773 last = first + lenlat 4800 4774 4801 assert allclose(long_lat_dep[first:last,LAT], lat), msg4802 assert allclose(long_lat_dep[first:last,LONG], long[i]), msg4775 assert num.allclose(long_lat_dep[first:last,LAT], lat), msg 4776 assert num.allclose(long_lat_dep[first:last,LONG], long[i]), msg 4803 4777 4804 4778 msg = 'Out of range latitudes/longitudes' … … 4810 4784 # FIXME - make this faster/do this a better way 4811 4785 # use numeric transpose, after reshaping the quantity vector 4812 quantity = zeros(num_points,Float)4786 quantity = num.zeros(num_points, num.Float) 4813 4787 4814 4788 for lat_i, _ in enumerate(lat): … … 5282 5256 sww = Write_sww() 5283 5257 sww.store_header(outfile, times, len(volumes), len(points_utm), 5284 verbose=verbose, sww_precision= Float)5258 verbose=verbose, sww_precision=num.Float) 5285 5259 outfile.mean_stage = mean_stage 5286 5260 outfile.zscale = zscale … … 5306 5280 xmomentum=xmomentum, 5307 5281 ymomentum=ymomentum, 5308 sww_precision= Float)5282 sww_precision=num.Float) 5309 5283 j += 1 5310 5284 … … 5349 5323 """ 5350 5324 5351 from Numeric import ones,Float,compress,zeros,arange5352 5325 from urs_ext import read_mux2 5353 5326 5354 5327 numSrc = len(filenames) 5355 5328 5356 file_params = -1 * ones(3,Float) # [nsta,dt,nt]5329 file_params = -1 * num.ones(3, num.Float) # [nsta,dt,nt] 5357 5330 5358 5331 # Convert verbose to int C flag … … 5363 5336 5364 5337 if weights is None: 5365 weights = ones(numSrc)5338 weights = num.ones(numSrc) 5366 5339 5367 5340 if permutation is None: 5368 permutation = ensure_numeric([], Float)5341 permutation = ensure_numeric([], num.Float) 5369 5342 5370 5343 # Call underlying C implementation urs2sts_ext.c … … 5373 5346 5374 5347 msg = 'File parameter values were not read in correctly from c file' 5375 assert len( compress(file_params > 0, file_params)) != 0, msg5348 assert len(num.compress(file_params > 0, file_params)) != 0, msg 5376 5349 5377 5350 msg = 'The number of stations specifed in the c array and in the file ' \ … … 5413 5386 parameters_index = data.shape[1] - OFFSET 5414 5387 5415 times = dt * arange(parameters_index)5416 latitudes = zeros(number_of_selected_stations,Float)5417 longitudes = zeros(number_of_selected_stations,Float)5418 elevation = zeros(number_of_selected_stations,Float)5419 quantity = zeros((number_of_selected_stations, parameters_index),Float)5388 times = dt * num.arange(parameters_index) 5389 latitudes = num.zeros(number_of_selected_stations, num.Float) 5390 longitudes = num.zeros(number_of_selected_stations, num.Float) 5391 elevation = num.zeros(number_of_selected_stations, num.Float) 5392 quantity = num.zeros((number_of_selected_stations, parameters_index), num.Float) 5420 5393 5421 5394 starttime = 1e16 … … 5444 5417 mux_times_start_i = 0 5445 5418 else: 5446 mux_times_start_i = searchsorted(mux_times, mint)5419 mux_times_start_i = num.searchsorted(mux_times, mint) 5447 5420 5448 5421 if maxt == None: … … 5451 5424 maxt += 0.5 # so if you specify a time where there is 5452 5425 # data that time will be included 5453 mux_times_fin_i = searchsorted(mux_times, maxt)5426 mux_times_fin_i = num.searchsorted(mux_times, maxt) 5454 5427 5455 5428 return mux_times_start_i, mux_times_fin_i … … 5518 5491 import os 5519 5492 from Scientific.IO.NetCDF import NetCDFFile 5520 from Numeric import Float, Int, Int32, searchsorted, zeros, array5521 from Numeric import allclose, around,ones,Float5522 5493 from types import ListType,StringType 5523 5494 from operator import __and__ … … 5543 5514 if weights is None: 5544 5515 # Default is equal weighting 5545 weights = ones(numSrc,Float) / numSrc5516 weights = num.ones(numSrc, num.Float) / numSrc 5546 5517 else: 5547 5518 weights = ensure_numeric(weights) … … 5622 5593 msg = '%s, %s and %s have inconsistent gauge data' \ 5623 5594 % (files_in[0], files_in[1], files_in[2]) 5624 assert allclose(times, times_old), msg5625 assert allclose(latitudes, latitudes_old), msg5626 assert allclose(longitudes, longitudes_old), msg5627 assert allclose(elevation, elevation_old), msg5628 assert allclose(starttime, starttime_old), msg5595 assert num.allclose(times, times_old), msg 5596 assert num.allclose(latitudes, latitudes_old), msg 5597 assert num.allclose(longitudes, longitudes_old), msg 5598 assert num.allclose(elevation, elevation_old), msg 5599 assert num.allclose(starttime, starttime_old), msg 5629 5600 times_old = times 5630 5601 latitudes_old = latitudes … … 5665 5636 # 0 to number_of_points-1 5666 5637 if permutation is None: 5667 permutation = arange(number_of_points, typecode=Int)5638 permutation = num.arange(number_of_points, typecode=num.Int) 5668 5639 5669 5640 # NetCDF file definition … … 5679 5650 description=description, 5680 5651 verbose=verbose, 5681 sts_precision= Float)5652 sts_precision=num.Float) 5682 5653 5683 5654 # Store 5684 5655 from anuga.coordinate_transforms.redfearn import redfearn 5685 5656 5686 x = zeros(number_of_points,Float) # Easting5687 y = zeros(number_of_points,Float) # Northing5657 x = num.zeros(number_of_points, num.Float) # Easting 5658 y = num.zeros(number_of_points, num.Float) # Northing 5688 5659 5689 5660 # Check zone boundaries … … 5715 5686 geo_ref = write_NetCDF_georeference(origin, outfile) 5716 5687 5717 elevation = resize(elevation, outfile.variables['elevation'][:].shape)5718 outfile.variables['permutation'][:] = permutation.astype( Int32) # Opteron 645688 elevation = num.resize(elevation, outfile.variables['elevation'][:].shape) 5689 outfile.variables['permutation'][:] = permutation.astype(num.Int32) # Opteron 64 5719 5690 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 5720 5691 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() … … 5782 5753 y = fid.variables['y'][:] + yllcorner 5783 5754 5784 x = reshape(x, (len(x),1))5785 y = reshape(y, (len(y),1))5786 sts_points = concatenate((x,y), axis=1)5755 x = num.reshape(x, (len(x),1)) 5756 y = num.reshape(y, (len(y),1)) 5757 sts_points = num.concatenate((x,y), axis=1) 5787 5758 5788 5759 return sts_points.tolist() … … 5832 5803 smoothing=True, 5833 5804 order=1, 5834 sww_precision= Float32,5805 sww_precision=num.Float32, 5835 5806 verbose=False): 5836 5807 """Write an SWW file header. … … 5865 5836 # This is being used to seperate one number from a list. 5866 5837 # what it is actually doing is sorting lists from numeric arrays. 5867 if type(times) is list or type(times) is ArrayType:5838 if type(times) is list or type(times) is num.ArrayType: 5868 5839 number_of_times = len(times) 5869 5840 times = ensure_numeric(times) … … 5914 5885 outfile.createVariable('z', sww_precision, ('number_of_points',)) 5915 5886 5916 outfile.createVariable('volumes', Int, ('number_of_volumes',5917 'number_of_vertices'))5887 outfile.createVariable('volumes', num.Int, ('number_of_volumes', 5888 'number_of_vertices')) 5918 5889 5919 5890 # Doing sww_precision instead of Float gives cast errors. 5920 outfile.createVariable('time', Float,5891 outfile.createVariable('time', num.Float, 5921 5892 ('number_of_timesteps',)) 5922 5893 … … 5932 5903 outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max 5933 5904 5934 if type(times) is list or type(times) is ArrayType:5905 if type(times) is list or type(times) is num.ArrayType: 5935 5906 outfile.variables['time'][:] = times #Store time relative 5936 5907 … … 5987 5958 5988 5959 number_of_points = len(points_utm) 5989 volumes = array(volumes)5990 points_utm = array(points_utm)5960 volumes = num.array(volumes) 5961 points_utm = num.array(points_utm) 5991 5962 5992 5963 # given the two geo_refs and the points, do the stuff … … 6035 6006 outfile.variables['z'][:] = elevation 6036 6007 outfile.variables['elevation'][:] = elevation #FIXME HACK 6037 outfile.variables['volumes'][:] = volumes.astype( Int32) #On Opteron 646008 outfile.variables['volumes'][:] = volumes.astype(num.Int32) #On Opteron 64 6038 6009 6039 6010 q = 'elevation' … … 6051 6022 # @param verbose True if this function is to be verbose. 6052 6023 # @param **quant 6053 def store_quantities(self, outfile, sww_precision= Float32,6024 def store_quantities(self, outfile, sww_precision=num.Float32, 6054 6025 slice_index=None, time=None, 6055 6026 verbose=False, **quant): … … 6244 6215 number_of_points, 6245 6216 description='Converted from URS mux2 format', 6246 sts_precision= Float32,6217 sts_precision=num.Float32, 6247 6218 verbose=False): 6248 6219 """ … … 6267 6238 # This is being used to seperate one number from a list. 6268 6239 # what it is actually doing is sorting lists from numeric arrays. 6269 if type(times) is list or type(times) is ArrayType:6240 if type(times) is list or type(times) is num.ArrayType: 6270 6241 number_of_times = len(times) 6271 6242 times = ensure_numeric(times) … … 6287 6258 6288 6259 # Variable definitions 6289 outfile.createVariable('permutation', Int, ('number_of_points',))6260 outfile.createVariable('permutation', num.Int, ('number_of_points',)) 6290 6261 outfile.createVariable('x', sts_precision, ('number_of_points',)) 6291 6262 outfile.createVariable('y', sts_precision, ('number_of_points',)) … … 6302 6273 6303 6274 # Doing sts_precision instead of Float gives cast errors. 6304 outfile.createVariable('time', Float, ('number_of_timesteps',))6275 outfile.createVariable('time', num.Float, ('number_of_timesteps',)) 6305 6276 6306 6277 for q in Write_sts.sts_quantities: … … 6314 6285 outfile.variables[q + Write_sts.RANGE][1] = -max_float # Max 6315 6286 6316 if type(times) is list or type(times) is ArrayType:6287 if type(times) is list or type(times) is num.ArrayType: 6317 6288 outfile.variables['time'][:] = times #Store time relative 6318 6289 … … 6365 6336 6366 6337 number_of_points = len(points_utm) 6367 points_utm = array(points_utm)6338 points_utm = num.array(points_utm) 6368 6339 6369 6340 # given the two geo_refs and the points, do the stuff … … 6423 6394 # @param verboseTrue if this function is to be verbose. 6424 6395 # @param **quant Extra keyword args. 6425 def store_quantities(self, outfile, sts_precision= Float32,6396 def store_quantities(self, outfile, sts_precision=num.Float32, 6426 6397 slice_index=None, time=None, 6427 6398 verbose=False, **quant): … … 6514 6485 lonlatdep = p_array.array('f') 6515 6486 lonlatdep.read(mux_file, columns * self.points_num) 6516 lonlatdep = array(lonlatdep, typecode=Float)6517 lonlatdep = reshape(lonlatdep, (self.points_num, columns))6487 lonlatdep = num.array(lonlatdep, typecode=num.Float) 6488 lonlatdep = num.reshape(lonlatdep, (self.points_num, columns)) 6518 6489 self.lonlatdep = lonlatdep 6519 6490 … … 6550 6521 hz_p_array = p_array.array('f') 6551 6522 hz_p_array.read(self.mux_file, self.points_num) 6552 hz_p = array(hz_p_array, typecode=Float)6523 hz_p = num.array(hz_p_array, typecode=num.Float) 6553 6524 self.iter_time_step += 1 6554 6525 … … 6695 6666 # array to store data, number in there is to allow float... 6696 6667 # i'm sure there is a better way! 6697 data = array([], typecode=Float)6698 data = resize(data, ((len(lines)-1), len(header_fields)))6668 data = num.array([], typecode=num.Float) 6669 data = num.resize(data, ((len(lines)-1), len(header_fields))) 6699 6670 6700 6671 array_number = 0 … … 6853 6824 from Scientific.IO.NetCDF import NetCDFFile 6854 6825 from shallow_water import Domain 6855 from Numeric import asarray, transpose, resize6856 6826 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 6857 6827 … … 6871 6841 6872 6842 # Mesh (nodes (Mx2), triangles (Nx3)) 6873 nodes = concatenate((x[:,NewAxis], y[:,NewAxis]), axis=1)6843 nodes = num.concatenate((x[:,num.NewAxis], y[:,num.NewAxis]), axis=1) 6874 6844 triangles = fid.variables['volumes'][:] 6875 6845 … … 7294 7264 7295 7265 # Get the relevant quantities (Convert from single precison) 7296 elevation = array(fid.variables['elevation'][:],Float)7297 stage = array(fid.variables['stage'][:],Float)7266 elevation = num.array(fid.variables['elevation'][:], num.Float) 7267 stage = num.array(fid.variables['stage'][:], num.Float) 7298 7268 7299 7269 # Here's where one could convert nodal information to centroid … … 7312 7282 # and call it here 7313 7283 7314 points = concatenate((x[:,NewAxis], y[:,NewAxis]), axis=1)7284 points = num.concatenate((x[:,num.NewAxis], y[:,num.NewAxis]), axis=1) 7315 7285 7316 7286 point_indices = inside_polygon(points, polygon) 7317 7287 7318 7288 # Restrict quantities to polygon 7319 elevation = take(elevation, point_indices)7320 stage = take(stage, point_indices, axis=1)7289 elevation = num.take(elevation, point_indices) 7290 stage = num.take(stage, point_indices, axis=1) 7321 7291 7322 7292 # Get info for location of maximal runup 7323 points_in_polygon = take(points, point_indices)7293 points_in_polygon = num.take(points, point_indices) 7324 7294 x = points_in_polygon[:,0] 7325 7295 y = points_in_polygon[:,1] 7326 7296 else: 7327 7297 # Take all points 7328 point_indices = arange(len(x))7298 point_indices = num.arange(len(x)) 7329 7299 7330 7300 # Temporal restriction 7331 7301 time = fid.variables['time'][:] 7332 all_timeindices = arange(len(time))7302 all_timeindices = num.arange(len(time)) 7333 7303 if time_interval is not None: 7334 7304 msg = 'time_interval must be a sequence of length 2.' … … 7343 7313 7344 7314 # Take time indices corresponding to interval (& is bitwise AND) 7345 timesteps = compress((time_interval[0] <= time) \7315 timesteps = num.compress((time_interval[0] <= time) \ 7346 7316 & (time <= time_interval[1]), 7347 all_timeindices)7317 all_timeindices) 7348 7318 7349 7319 msg = 'time_interval %s did not include any model timesteps.' \ 7350 7320 % time_interval 7351 assert not alltrue(timesteps == 0), msg7321 assert not num.alltrue(timesteps == 0), msg 7352 7322 else: 7353 7323 # Take them all … … 7372 7342 # Get wet nodes i.e. nodes with depth>0 within given region 7373 7343 # and timesteps 7374 wet_nodes = compress(depth > minimum_allowed_height,7375 arange(len(depth)))7376 7377 if alltrue(wet_nodes == 0):7344 wet_nodes = num.compress(depth > minimum_allowed_height, 7345 num.arange(len(depth))) 7346 7347 if num.alltrue(wet_nodes == 0): 7378 7348 runup = None 7379 7349 else: 7380 7350 # Find maximum elevation among wet nodes 7381 wet_elevation = take(elevation, wet_nodes)7382 runup_index = argmax(wet_elevation)7351 wet_elevation = num.take(elevation, wet_nodes) 7352 runup_index = num.argmax(wet_elevation) 7383 7353 runup = max(wet_elevation) 7384 7354 assert wet_elevation[runup_index] == runup # Must be True … … 7388 7358 7389 7359 # Record location 7390 wet_x = take(x, wet_nodes)7391 wet_y = take(y, wet_nodes)7360 wet_x = num.take(x, wet_nodes) 7361 wet_y = num.take(y, wet_nodes) 7392 7362 maximal_runup_location = [wet_x[runup_index],wet_y[runup_index]] 7393 7363 -
anuga_core/source/anuga/shallow_water/eq_test.py
r4436 r6157 66 66 67 67 from anuga.abstract_2d_finite_volumes.util import file_function 68 from Numeric import array, Float 68 import Numeric as num 69 69 from pylab import plot, ion, hold,savefig 70 70 … … 75 75 76 76 y = 10000 77 points= array([[0]*2]*max)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= array([[0]*2]*number_points)89 points=num.array([[0]*2]*number_points) 90 90 print points 91 91 half_profile=profile_lenght/2 -
anuga_core/source/anuga/shallow_water/eqf.py
r4320 r6157 25 25 26 26 """ 27 27 28 28 29 def earthquake_tsunami(length, width, strike, depth, \ … … 112 113 113 114 from math import sin, cos, radians, exp, cosh 114 from Numeric import zeros, Float115 115 from okada import okadatest 116 116 -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r6121 r6157 80 80 # $LastChangedBy$ 81 81 82 from Numeric import zeros, ones, Float, array, sum, size 83 from Numeric import compress, arange 82 import Numeric as num 84 83 85 84 from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints … … 343 342 344 343 # Select indices for which depth > 0 345 wet_indices = compress(depth > minimum_allowed_height,346 arange(len(depth)))344 wet_indices = num.compress(depth > minimum_allowed_height, 345 num.arange(len(depth))) 347 346 return wet_indices 348 347 … … 651 650 """ 652 651 653 from Numeric import sqrt654 652 from anuga.config import epsilon, g 655 653 … … 744 742 # Froude number in each direction 745 743 name = 'Froude (x)' 746 Vfx = Vu/( sqrt(g*Vh) + epsilon)747 Efx = Eu/( sqrt(g*Eh) + epsilon)748 Cfx = Cu/( sqrt(g*Ch) + epsilon)744 Vfx = Vu/(num.sqrt(g*Vh) + epsilon) 745 Efx = Eu/(num.sqrt(g*Eh) + epsilon) 746 Cfx = Cu/(num.sqrt(g*Ch) + epsilon) 749 747 750 748 s = ' %s: vertex_values = %.4f,\t %.4f,\t %.4f\n'\ … … 761 759 762 760 name = 'Froude (y)' 763 Vfy = Vv/( sqrt(g*Vh) + epsilon)764 Efy = Ev/( sqrt(g*Eh) + epsilon)765 Cfy = Cv/( sqrt(g*Ch) + epsilon)761 Vfy = Vv/(num.sqrt(g*Vh) + epsilon) 762 Efy = Ev/(num.sqrt(g*Eh) + epsilon) 763 Cfy = Cv/(num.sqrt(g*Ch) + epsilon) 766 764 767 765 s = ' %s: vertex_values = %.4f,\t %.4f,\t %.4f\n'\ … … 1082 1080 self.normals = domain.normals 1083 1081 1084 self.conserved_quantities = zeros(3,Float)1082 self.conserved_quantities = num.zeros(3, num.Float) 1085 1083 1086 1084 def __repr__(self): … … 1500 1498 if callable(f): 1501 1499 N = 3 1502 x = ones(3,Float)1503 y = ones(3,Float)1500 x = num.ones(3, num.Float) 1501 y = num.ones(3, num.Float) 1504 1502 try: 1505 1503 q = f(1.0, x=x, y=y) … … 1510 1508 1511 1509 try: 1512 q = array(q).astype(Float)1510 q = num.array(q).astype(num.Float) 1513 1511 except: 1514 1512 msg = 'Return value from vector function %s could ' %f … … 1578 1576 1579 1577 from anuga.config import rho_a, rho_w, eta_w 1580 from Numeric import array, Float1581 1578 1582 1579 if len(args) == 2: … … 1608 1605 1609 1606 from math import pi, cos, sin, sqrt 1610 from Numeric import Float, ones, ArrayType1611 1607 1612 1608 xmom_update = domain.quantities['xmomentum'].explicit_update … … 1623 1619 1624 1620 try: 1625 s_vec = self.speed * ones(N,Float)1621 s_vec = self.speed * num.ones(N, num.Float) 1626 1622 except: 1627 1623 msg = 'Speed must be either callable or a scalar: %s' %self.s … … 1636 1632 1637 1633 try: 1638 phi_vec = self.phi * ones(N,Float)1634 phi_vec = self.phi * num.ones(N, num.Float) 1639 1635 except: 1640 1636 msg = 'Angle must be either callable or a scalar: %s' %self.phi -
anuga_core/source/anuga/shallow_water/smf.py
r5675 r6157 46 46 Geoscience Australia, June 2005 47 47 """ 48 49 import Numeric as num 50 51 48 52 def find_min(x0, wa, kappad, dx): 49 53 """Determine eta_min to scale eta(x,y) … … 384 388 385 389 from math import sin, cos, radians, exp, cosh 386 from Numeric import zeros, Float390 # from Numeric import zeros, Float 387 391 388 392 #ensure vectors x and y have the same length … … 412 416 yr = ((x-x0) * sina + (y-y0) * cosa) + y0 413 417 414 z = zeros(N,Float)418 z = num.zeros(N, num.Float) 415 419 maxz = 0.0 416 420 minz = 0.0 -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r6120 r6157 7 7 import unittest 8 8 import copy 9 from Numeric import zeros, array, allclose, Float, Int, ones,transpose 9 import Numeric as num 10 10 11 from anuga.utilities.numerical_tools import mean 11 12 import tempfile … … 66 67 #Initial condition - with jumps 67 68 bed = domain.quantities['elevation'].vertex_values 68 stage = zeros(bed.shape,Float)69 stage = num.zeros(bed.shape, num.Float) 69 70 70 71 h = 0.3 … … 188 189 V = fid.variables['volumes'] 189 190 190 assert allclose (x[:], self.X.flat)191 assert allclose (y[:], self.Y.flat)192 assert allclose (z[:], self.F.flat)191 assert num.allclose (x[:], self.X.flat) 192 assert num.allclose (y[:], self.Y.flat) 193 assert num.allclose (z[:], self.F.flat) 193 194 194 195 P = len(self.domain) … … 252 253 range = fid.variables['stage_range'][:] 253 254 #print range 254 assert allclose(range,[-0.93519, 0.15]) or\255 allclose(range,[-0.9352743, 0.15]) or\256 allclose(range,[-0.93522203, 0.15000001]) # Old slope limiters255 assert num.allclose(range,[-0.93519, 0.15]) or\ 256 num.allclose(range,[-0.9352743, 0.15]) or\ 257 num.allclose(range,[-0.93522203, 0.15000001]) # Old slope limiters 257 258 258 259 range = fid.variables['xmomentum_range'][:] 259 260 #print range 260 assert allclose(range,[0,0.4695096]) or \261 allclose(range,[0,0.47790655]) or\262 allclose(range,[0,0.46941957]) or\263 allclose(range,[0,0.47769409])261 assert num.allclose(range,[0,0.4695096]) or \ 262 num.allclose(range,[0,0.47790655]) or\ 263 num.allclose(range,[0,0.46941957]) or\ 264 num.allclose(range,[0,0.47769409]) 264 265 265 266 266 267 range = fid.variables['ymomentum_range'][:] 267 268 #print range 268 assert allclose(range,[0,0.02174380]) or\269 allclose(range,[0,0.02174439]) or\270 allclose(range,[0,0.02283983]) or\271 allclose(range,[0,0.0217342]) or\272 allclose(range,[0,0.0227564]) # Old slope limiters269 assert num.allclose(range,[0,0.02174380]) or\ 270 num.allclose(range,[0,0.02174439]) or\ 271 num.allclose(range,[0,0.02283983]) or\ 272 num.allclose(range,[0,0.0217342]) or\ 273 num.allclose(range,[0,0.0227564]) # Old slope limiters 273 274 274 275 fid.close() … … 330 331 # Get the variables 331 332 extrema = fid.variables['stage-elevation.extrema'][:] 332 assert allclose(extrema, [0.00, 0.30])333 assert num.allclose(extrema, [0.00, 0.30]) 333 334 334 335 loc = fid.variables['stage-elevation.min_location'][:] 335 assert allclose(loc, [0.16666667, 0.33333333])336 assert num.allclose(loc, [0.16666667, 0.33333333]) 336 337 337 338 loc = fid.variables['stage-elevation.max_location'][:] 338 assert allclose(loc, [0.8333333, 0.16666667])339 assert num.allclose(loc, [0.8333333, 0.16666667]) 339 340 340 341 time = fid.variables['stage-elevation.max_time'][:] 341 assert allclose(time, 0.0)342 assert num.allclose(time, 0.0) 342 343 343 344 extrema = fid.variables['xmomentum.extrema'][:] 344 assert allclose(extrema,[-0.06062178, 0.47873023]) orallclose(extrema, [-0.06062178, 0.47847986])345 assert num.allclose(extrema,[-0.06062178, 0.47873023]) or num.allclose(extrema, [-0.06062178, 0.47847986]) 345 346 346 347 extrema = fid.variables['ymomentum.extrema'][:] 347 assert allclose(extrema,[0.00, 0.0625786]) orallclose(extrema,[0.00, 0.06062178])348 assert num.allclose(extrema,[0.00, 0.0625786]) or num.allclose(extrema,[0.00, 0.06062178]) 348 349 349 350 time_interval = fid.variables['extrema.time_interval'][:] 350 assert allclose(time_interval, [0,1])351 assert num.allclose(time_interval, [0,1]) 351 352 352 353 polygon = fid.variables['extrema.polygon'][:] 353 assert allclose(polygon, domain.get_boundary_polygon())354 assert num.allclose(polygon, domain.get_boundary_polygon()) 354 355 355 356 fid.close() … … 380 381 V = fid.variables['volumes'] 381 382 382 assert allclose([X[0], Y[0]],array([0.0, 0.0]))383 assert allclose([X[1], Y[1]],array([0.0, 0.5]))384 assert allclose([X[2], Y[2]],array([0.0, 1.0]))385 assert allclose([X[4], Y[4]],array([0.5, 0.5]))386 assert allclose([X[7], Y[7]],array([1.0, 0.5]))383 assert num.allclose([X[0], Y[0]], num.array([0.0, 0.0])) 384 assert num.allclose([X[1], Y[1]], num.array([0.0, 0.5])) 385 assert num.allclose([X[2], Y[2]], num.array([0.0, 1.0])) 386 assert num.allclose([X[4], Y[4]], num.array([0.5, 0.5])) 387 assert num.allclose([X[7], Y[7]], num.array([1.0, 0.5])) 387 388 388 389 assert Z[4] == -0.5 … … 427 428 A = stage[0,:] 428 429 #print A[0], (Q2[0,0] + Q1[1,0])/2 429 assert allclose(A[0], (Q2[0] + Q1[1])/2)430 assert allclose(A[1], (Q0[1] + Q1[3] + Q2[2])/3)431 assert allclose(A[2], Q0[3])432 assert allclose(A[3], (Q0[0] + Q1[5] + Q2[4])/3)430 assert num.allclose(A[0], (Q2[0] + Q1[1])/2) 431 assert num.allclose(A[1], (Q0[1] + Q1[3] + Q2[2])/3) 432 assert num.allclose(A[2], Q0[3]) 433 assert num.allclose(A[3], (Q0[0] + Q1[5] + Q2[4])/3) 433 434 434 435 #Center point 435 assert allclose(A[4], (Q1[0] + Q2[1] + Q0[2] +\436 Q0[5] + Q2[6] + Q1[7])/6)436 assert num.allclose(A[4], (Q1[0] + Q2[1] + Q0[2] +\ 437 Q0[5] + Q2[6] + Q1[7])/6) 437 438 438 439 fid.close() … … 446 447 447 448 import time, os 448 from Numeric import array, zeros, allclose, Float, concatenate449 449 from Scientific.IO.NetCDF import NetCDFFile 450 450 … … 481 481 482 482 A = stage[1,:] 483 assert allclose(A[0], (Q2[0] + Q1[1])/2)484 assert allclose(A[1], (Q0[1] + Q1[3] + Q2[2])/3)485 assert allclose(A[2], Q0[3])486 assert allclose(A[3], (Q0[0] + Q1[5] + Q2[4])/3)483 assert num.allclose(A[0], (Q2[0] + Q1[1])/2) 484 assert num.allclose(A[1], (Q0[1] + Q1[3] + Q2[2])/3) 485 assert num.allclose(A[2], Q0[3]) 486 assert num.allclose(A[3], (Q0[0] + Q1[5] + Q2[4])/3) 487 487 488 488 #Center point 489 assert allclose(A[4], (Q1[0] + Q2[1] + Q0[2] +\490 Q0[5] + Q2[6] + Q1[7])/6)489 assert num.allclose(A[4], (Q1[0] + Q2[1] + Q0[2] +\ 490 Q0[5] + Q2[6] + Q1[7])/6) 491 491 492 492 … … 504 504 505 505 import time, os 506 from Numeric import array, zeros, allclose, Float, concatenate507 506 from Scientific.IO.NetCDF import NetCDFFile 508 507 … … 538 537 539 538 A = stage[1,:] 540 assert allclose(A[0], min(Q2[0], Q1[1]))541 assert allclose(A[1], min(Q0[1], Q1[3], Q2[2]))542 assert allclose(A[2], Q0[3])543 assert allclose(A[3], min(Q0[0], Q1[5], Q2[4]))539 assert num.allclose(A[0], min(Q2[0], Q1[1])) 540 assert num.allclose(A[1], min(Q0[1], Q1[3], Q2[2])) 541 assert num.allclose(A[2], Q0[3]) 542 assert num.allclose(A[3], min(Q0[0], Q1[5], Q2[4])) 544 543 545 544 #Center point 546 assert allclose(A[4], min(Q1[0], Q2[1], Q0[2],\547 Q0[5], Q2[6], Q1[7]))545 assert num.allclose(A[4], min(Q1[0], Q2[1], Q0[2], 546 Q0[5], Q2[6], Q1[7])) 548 547 549 548 … … 559 558 560 559 import time, os, config 561 from Numeric import array, zeros, allclose, Float, concatenate562 560 from Scientific.IO.NetCDF import NetCDFFile 563 561 … … 590 588 591 589 if t == 0.0: 592 assert allclose(stage, self.initial_stage)593 assert allclose(stage_file[:], stage.flat)590 assert num.allclose(stage, self.initial_stage) 591 assert num.allclose(stage_file[:], stage.flat) 594 592 else: 595 assert not allclose(stage, self.initial_stage)596 assert not allclose(stage_file[:], stage.flat)593 assert not num.allclose(stage, self.initial_stage) 594 assert not num.allclose(stage_file[:], stage.flat) 597 595 598 596 fid.close() … … 607 605 608 606 import time, os 609 from Numeric import array, zeros, allclose, Float, concatenate610 607 from Scientific.IO.NetCDF import NetCDFFile 611 608 … … 646 643 647 644 A = stage[1,:] 648 assert allclose(stage[1,:], z[:])649 650 651 assert allclose(xmomentum, 0.0)652 assert allclose(ymomentum, 0.0)645 assert num.allclose(stage[1,:], z[:]) 646 647 648 assert num.allclose(xmomentum, 0.0) 649 assert num.allclose(ymomentum, 0.0) 653 650 654 651 fid.close() … … 663 660 664 661 import time, os 665 from Numeric import array, zeros, allclose, Float, concatenate666 662 from Scientific.IO.NetCDF import NetCDFFile 667 663 … … 724 720 725 721 import time, os 726 from Numeric import array, zeros, allclose, Float, concatenate, ones727 722 from Scientific.IO.NetCDF import NetCDFFile 728 723 … … 819 814 ref_points.append ([xnew,ynew]) #Relative point values 820 815 821 assert allclose(points, ref_points)822 823 assert allclose(elevation, ref_elevation)816 assert num.allclose(points, ref_points) 817 818 assert num.allclose(elevation, ref_elevation) 824 819 825 820 #Cleanup … … 838 833 839 834 import time, os 840 from Numeric import array, zeros, allclose, Float, concatenate, ones841 835 from Scientific.IO.NetCDF import NetCDFFile 842 836 … … 861 855 xvec = range(10) 862 856 #z = range(100) 863 z = zeros(100)857 z = num.zeros(100) 864 858 NODATA_value = -9999 865 859 count = -1 … … 920 914 921 915 #create new reference points 922 newz = zeros(19)916 newz = num.zeros(19) 923 917 newz[0:2] = ref_elevation[32:34] 924 918 newz[2:5] = ref_elevation[35:38] … … 950 944 951 945 952 assert allclose(points, new_ref_points)953 assert allclose(elevation, ref_elevation)946 assert num.allclose(points, new_ref_points) 947 assert num.allclose(elevation, ref_elevation) 954 948 955 949 #Cleanup … … 969 963 970 964 import time, os 971 from Numeric import array, zeros, allclose, Float, concatenate, ones972 965 from Scientific.IO.NetCDF import NetCDFFile 973 966 … … 992 985 xvec = range(10) 993 986 #z = range(100) 994 z = zeros(100)987 z = num.zeros(100) 995 988 NODATA_value = -9999 996 989 count = -1 … … 1051 1044 1052 1045 #create new reference points 1053 newz = zeros(14)1046 newz = num.zeros(14) 1054 1047 newz[0:2] = ref_elevation[32:34] 1055 1048 newz[2:5] = ref_elevation[35:38] … … 1083 1076 #print new_ref_points, len(new_ref_points) 1084 1077 1085 assert allclose(elevation, ref_elevation)1086 assert allclose(points, new_ref_points)1078 assert num.allclose(elevation, ref_elevation) 1079 assert num.allclose(points, new_ref_points) 1087 1080 1088 1081 … … 1103 1096 1104 1097 import time, os 1105 from Numeric import array, zeros, allclose, Float, concatenate1106 1098 from Scientific.IO.NetCDF import NetCDFFile 1107 1099 … … 1213 1205 #print points[:] 1214 1206 #print ref_points 1215 assert allclose(points, ref_points)1207 assert num.allclose(points, ref_points) 1216 1208 1217 1209 #print attributes[:] 1218 1210 #print ref_elevation 1219 assert allclose(elevation, ref_elevation)1211 assert num.allclose(elevation, ref_elevation) 1220 1212 1221 1213 #Cleanup … … 1235 1227 1236 1228 import time, os 1237 from Numeric import array, zeros, allclose, Float, concatenate1238 1229 from Scientific.IO.NetCDF import NetCDFFile 1239 1230 … … 1341 1332 L = lines[2].strip().split() 1342 1333 assert L[0].strip().lower() == 'xllcorner' 1343 assert allclose(float(L[1].strip().lower()), 308500)1334 assert num.allclose(float(L[1].strip().lower()), 308500) 1344 1335 1345 1336 L = lines[3].strip().split() 1346 1337 assert L[0].strip().lower() == 'yllcorner' 1347 assert allclose(float(L[1].strip().lower()), 6189000)1338 assert num.allclose(float(L[1].strip().lower()), 6189000) 1348 1339 1349 1340 L = lines[4].strip().split() 1350 1341 assert L[0].strip().lower() == 'cellsize' 1351 assert allclose(float(L[1].strip().lower()), cellsize)1342 assert num.allclose(float(L[1].strip().lower()), cellsize) 1352 1343 1353 1344 L = lines[5].strip().split() … … 1360 1351 y = (4-j) * cellsize 1361 1352 for i in range(5): 1362 assert allclose(float(L[i]), -i*cellsize - y)1353 assert num.allclose(float(L[i]), -i*cellsize - y) 1363 1354 1364 1355 #Cleanup … … 1391 1382 L = lines[2].strip().split() 1392 1383 assert L[0].strip().lower() == 'xllcorner' 1393 assert allclose(float(L[1].strip().lower()), 308500)1384 assert num.allclose(float(L[1].strip().lower()), 308500) 1394 1385 1395 1386 L = lines[3].strip().split() 1396 1387 assert L[0].strip().lower() == 'yllcorner' 1397 assert allclose(float(L[1].strip().lower()), 6189000)1388 assert num.allclose(float(L[1].strip().lower()), 6189000) 1398 1389 1399 1390 L = lines[4].strip().split() 1400 1391 assert L[0].strip().lower() == 'cellsize' 1401 assert allclose(float(L[1].strip().lower()), cellsize)1392 assert num.allclose(float(L[1].strip().lower()), cellsize) 1402 1393 1403 1394 L = lines[5].strip().split() … … 1410 1401 y = (4-j) * cellsize 1411 1402 for i in range(5): 1412 assert allclose(float(L[i]), 1 - (-i*cellsize - y))1403 assert num.allclose(float(L[i]), 1 - (-i*cellsize - y)) 1413 1404 1414 1405 … … 1427 1418 1428 1419 import time, os 1429 from Numeric import array, zeros, allclose, Float, concatenate1430 1420 from Scientific.IO.NetCDF import NetCDFFile 1431 1421 … … 1485 1475 L = lines[2].strip().split() 1486 1476 assert L[0].strip().lower() == 'xllcorner' 1487 assert allclose(float(L[1].strip().lower()), 308500)1477 assert num.allclose(float(L[1].strip().lower()), 308500) 1488 1478 1489 1479 L = lines[3].strip().split() 1490 1480 assert L[0].strip().lower() == 'yllcorner' 1491 assert allclose(float(L[1].strip().lower()), 6189000)1481 assert num.allclose(float(L[1].strip().lower()), 6189000) 1492 1482 1493 1483 #Check grid values … … 1496 1486 y = (4-j) * cellsize 1497 1487 for i in range(5): 1498 assert allclose(float(L[i]), -i*cellsize - y)1488 assert num.allclose(float(L[i]), -i*cellsize - y) 1499 1489 1500 1490 #Cleanup … … 1511 1501 1512 1502 import time, os 1513 from Numeric import array, zeros, allclose, Float, concatenate1514 1503 from Scientific.IO.NetCDF import NetCDFFile 1515 1504 … … 1591 1580 L = lines[2].strip().split() 1592 1581 assert L[0].strip().lower() == 'xllcorner' 1593 assert allclose(float(L[1].strip().lower()), 308500)1582 assert num.allclose(float(L[1].strip().lower()), 308500) 1594 1583 1595 1584 L = lines[3].strip().split() 1596 1585 assert L[0].strip().lower() == 'yllcorner' 1597 assert allclose(float(L[1].strip().lower()), 6189000)1586 assert num.allclose(float(L[1].strip().lower()), 6189000) 1598 1587 1599 1588 #print "ascfile", ascfile … … 1605 1594 #print " -i*cellsize - y", -i*cellsize - y 1606 1595 #print "float(L[i])", float(L[i]) 1607 assert allclose(float(L[i]), -i*cellsize - y)1596 assert num.allclose(float(L[i]), -i*cellsize - y) 1608 1597 1609 1598 #Cleanup … … 1620 1609 L = lines[2].strip().split() 1621 1610 assert L[0].strip().lower() == 'xllcorner' 1622 assert allclose(float(L[1].strip().lower()), 308500)1611 assert num.allclose(float(L[1].strip().lower()), 308500) 1623 1612 1624 1613 L = lines[3].strip().split() 1625 1614 assert L[0].strip().lower() == 'yllcorner' 1626 assert allclose(float(L[1].strip().lower()), 6189000)1615 assert num.allclose(float(L[1].strip().lower()), 6189000) 1627 1616 1628 1617 #Check grid values … … 1633 1622 #print " -i*cellsize - y", -i*cellsize - y 1634 1623 #print "float(L[i])", float(L[i]) 1635 assert allclose(float(L[i]), 1 - (-i*cellsize - y))1624 assert num.allclose(float(L[i]), 1 - (-i*cellsize - y)) 1636 1625 1637 1626 #Cleanup … … 1649 1638 1650 1639 import time, os 1651 from Numeric import array, zeros, allclose, Float, concatenate1652 1640 from Scientific.IO.NetCDF import NetCDFFile 1653 1641 … … 1726 1714 L = lines[2].strip().split() 1727 1715 assert L[0].strip().lower() == 'xllcorner' 1728 assert allclose(float(L[1].strip().lower()), 308500)1716 assert num.allclose(float(L[1].strip().lower()), 308500) 1729 1717 1730 1718 L = lines[3].strip().split() 1731 1719 assert L[0].strip().lower() == 'yllcorner' 1732 assert allclose(float(L[1].strip().lower()), 6189000)1720 assert num.allclose(float(L[1].strip().lower()), 6189000) 1733 1721 1734 1722 #print "ascfile", ascfile … … 1740 1728 #print " -i*cellsize - y", -i*cellsize - y 1741 1729 #print "float(L[i])", float(L[i]) 1742 assert allclose(float(L[i]), -i*cellsize - y)1730 assert num.allclose(float(L[i]), -i*cellsize - y) 1743 1731 1744 1732 #Cleanup … … 1755 1743 L = lines[2].strip().split() 1756 1744 assert L[0].strip().lower() == 'xllcorner' 1757 assert allclose(float(L[1].strip().lower()), 308500)1745 assert num.allclose(float(L[1].strip().lower()), 308500) 1758 1746 1759 1747 L = lines[3].strip().split() 1760 1748 assert L[0].strip().lower() == 'yllcorner' 1761 assert allclose(float(L[1].strip().lower()), 6189000)1749 assert num.allclose(float(L[1].strip().lower()), 6189000) 1762 1750 1763 1751 #Check grid values … … 1766 1754 y = (4-j) * cellsize 1767 1755 for i in range(5): 1768 assert allclose(float(L[i]), 1 - (-i*cellsize - y))1756 assert num.allclose(float(L[i]), 1 - (-i*cellsize - y)) 1769 1757 1770 1758 #Cleanup … … 1795 1783 1796 1784 import time, os 1797 from Numeric import array, zeros, allclose, Float, concatenate1798 1785 from Scientific.IO.NetCDF import NetCDFFile 1799 1786 … … 1861 1848 #print " -i*cellsize - y", -i*cellsize - y 1862 1849 #print "float(L[i])", float(L[i]) 1863 assert allclose(float(L[i]), -i*cellsize - y)1850 assert num.allclose(float(L[i]), -i*cellsize - y) 1864 1851 #Cleanup 1865 1852 os.remove(prjfile) … … 1879 1866 #print " -i*cellsize - y", -i*cellsize - y 1880 1867 #print "float(L[i])", float(L[i]) 1881 assert allclose(float(L[i]), -i*cellsize - y)1868 assert num.allclose(float(L[i]), -i*cellsize - y) 1882 1869 #Cleanup 1883 1870 os.remove(prjfile) … … 1896 1883 y = (4-j) * cellsize 1897 1884 for i in range(5): 1898 assert allclose(float(L[i]), 1 - (-i*cellsize - y))1885 assert num.allclose(float(L[i]), 1 - (-i*cellsize - y)) 1899 1886 #Cleanup 1900 1887 os.remove(prjfile) … … 1912 1899 y = (4-j) * cellsize 1913 1900 for i in range(5): 1914 assert allclose(float(L[i]), 1 - (-i*cellsize - y))1901 assert num.allclose(float(L[i]), 1 - (-i*cellsize - y)) 1915 1902 #Cleanup 1916 1903 os.remove(prjfile) … … 1943 1930 1944 1931 import time, os 1945 from Numeric import array, zeros, allclose, Float, concatenate1946 1932 from Scientific.IO.NetCDF import NetCDFFile 1947 1933 … … 2066 2052 L = lines[2].strip().split() 2067 2053 assert L[0].strip().lower() == 'xllcorner' 2068 assert allclose(float(L[1].strip().lower()), 308500)2054 assert num.allclose(float(L[1].strip().lower()), 308500) 2069 2055 2070 2056 L = lines[3].strip().split() 2071 2057 assert L[0].strip().lower() == 'yllcorner' 2072 assert allclose(float(L[1].strip().lower()), 6189000)2058 assert num.allclose(float(L[1].strip().lower()), 6189000) 2073 2059 2074 2060 L = lines[4].strip().split() 2075 2061 assert L[0].strip().lower() == 'cellsize' 2076 assert allclose(float(L[1].strip().lower()), cellsize)2062 assert num.allclose(float(L[1].strip().lower()), cellsize) 2077 2063 2078 2064 L = lines[5].strip().split() … … 2083 2069 for i, line in enumerate(lines[6:]): 2084 2070 for j, value in enumerate( line.split() ): 2085 assert allclose(float(value), -(10-i+j)*cellsize,2086 atol=1.0e-12, rtol=1.0e-12)2071 assert num.allclose(float(value), -(10-i+j)*cellsize, 2072 atol=1.0e-12, rtol=1.0e-12) 2087 2073 2088 2074 # Note: Equality can be obtained in this case, … … 2134 2120 2135 2121 import time, os 2136 from Numeric import array, zeros, allclose, Float, concatenate2137 2122 from Scientific.IO.NetCDF import NetCDFFile 2138 2123 … … 2263 2248 L = lines[2].strip().split() 2264 2249 assert L[0].strip().lower() == 'xllcorner' 2265 assert allclose(float(L[1].strip().lower()), 308530)2250 assert num.allclose(float(L[1].strip().lower()), 308530) 2266 2251 2267 2252 L = lines[3].strip().split() 2268 2253 assert L[0].strip().lower() == 'yllcorner' 2269 assert allclose(float(L[1].strip().lower()), 6189050)2254 assert num.allclose(float(L[1].strip().lower()), 6189050) 2270 2255 2271 2256 L = lines[4].strip().split() 2272 2257 assert L[0].strip().lower() == 'cellsize' 2273 assert allclose(float(L[1].strip().lower()), cellsize)2258 assert num.allclose(float(L[1].strip().lower()), cellsize) 2274 2259 2275 2260 L = lines[5].strip().split() … … 2300 2285 2301 2286 import time, os 2302 from Numeric import array, zeros, allclose, Float, concatenate2303 2287 from Scientific.IO.NetCDF import NetCDFFile 2304 2288 … … 2365 2349 L = lines[2].strip().split() 2366 2350 assert L[0].strip().lower() == 'xllcorner' 2367 assert allclose(float(L[1].strip().lower()), 308500)2351 assert num.allclose(float(L[1].strip().lower()), 308500) 2368 2352 2369 2353 L = lines[3].strip().split() 2370 2354 assert L[0].strip().lower() == 'yllcorner' 2371 assert allclose(float(L[1].strip().lower()), 6189000)2355 assert num.allclose(float(L[1].strip().lower()), 6189000) 2372 2356 2373 2357 L = lines[4].strip().split() 2374 2358 assert L[0].strip().lower() == 'cellsize' 2375 assert allclose(float(L[1].strip().lower()), cellsize)2359 assert num.allclose(float(L[1].strip().lower()), cellsize) 2376 2360 2377 2361 L = lines[5].strip().split() … … 2392 2376 2393 2377 #print i, j, index, ':', L[i], val0, val1 2394 assert allclose(float(L[i]), min(val0, val1))2378 assert num.allclose(float(L[i]), min(val0, val1)) 2395 2379 2396 2380 … … 2412 2396 2413 2397 import time, os 2414 from Numeric import array, zeros, allclose, Float, concatenate2415 2398 from Scientific.IO.NetCDF import NetCDFFile 2416 2399 … … 2479 2462 L = lines[2].strip().split() 2480 2463 assert L[0].strip().lower() == 'xllcorner' 2481 assert allclose(float(L[1].strip().lower()), 308500)2464 assert num.allclose(float(L[1].strip().lower()), 308500) 2482 2465 2483 2466 L = lines[3].strip().split() 2484 2467 assert L[0].strip().lower() == 'yllcorner' 2485 assert allclose(float(L[1].strip().lower()), 6189000)2468 assert num.allclose(float(L[1].strip().lower()), 6189000) 2486 2469 2487 2470 L = lines[4].strip().split() 2488 2471 assert L[0].strip().lower() == 'cellsize' 2489 assert allclose(float(L[1].strip().lower()), cellsize)2472 assert num.allclose(float(L[1].strip().lower()), cellsize) 2490 2473 2491 2474 L = lines[5].strip().split() … … 2506 2489 2507 2490 #print i, j, index, ':', L[i], val0, val1 2508 assert allclose(float(L[i]), min(val0, val1))2491 assert num.allclose(float(L[i]), min(val0, val1)) 2509 2492 2510 2493 … … 2528 2511 2529 2512 import time, os 2530 from Numeric import array, zeros, allclose, Float, concatenate2531 2513 from Scientific.IO.NetCDF import NetCDFFile 2532 2514 … … 2561 2543 2562 2544 bed = domain.quantities['elevation'].vertex_values 2563 stage = zeros(bed.shape,Float)2545 stage = num.zeros(bed.shape, num.Float) 2564 2546 2565 2547 h = 0.3 … … 2630 2612 L = lines[2].strip().split() 2631 2613 assert L[0].strip().lower() == 'xllcorner' 2632 assert allclose(float(L[1].strip().lower()), 308500)2614 assert num.allclose(float(L[1].strip().lower()), 308500) 2633 2615 2634 2616 L = lines[3].strip().split() 2635 2617 assert L[0].strip().lower() == 'yllcorner' 2636 assert allclose(float(L[1].strip().lower()), 6189000)2618 assert num.allclose(float(L[1].strip().lower()), 6189000) 2637 2619 2638 2620 L = lines[4].strip().split() 2639 2621 assert L[0].strip().lower() == 'cellsize' 2640 assert allclose(float(L[1].strip().lower()), cellsize)2622 assert num.allclose(float(L[1].strip().lower()), cellsize) 2641 2623 2642 2624 L = lines[5].strip().split() … … 2653 2635 #print i 2654 2636 if i+j >= 4: 2655 assert allclose(float(L[i]), -i*cellsize - y)2637 assert num.allclose(float(L[i]), -i*cellsize - y) 2656 2638 else: 2657 2639 #Missing values 2658 assert allclose(float(L[i]), -9999)2640 assert num.allclose(float(L[i]), -9999) 2659 2641 2660 2642 … … 2673 2655 2674 2656 import time, os 2675 from Numeric import array, zeros, allclose, Float, concatenate2676 2657 from Scientific.IO.NetCDF import NetCDFFile 2677 2658 … … 2754 2735 2755 2736 #print grid 2756 assert allclose(grid, ref_grid)2737 assert num.allclose(grid, ref_grid) 2757 2738 2758 2739 fid.close() … … 2773 2754 2774 2755 import time, os 2775 from Numeric import array, zeros, allclose, Float, concatenate, NewAxis2776 2756 from Scientific.IO.NetCDF import NetCDFFile 2777 2757 # Used for points that lie outside mesh … … 2813 2793 2814 2794 # Invoke interpolation for vertex points 2815 points = concatenate( (x[:,NewAxis],y[:,NewAxis]), axis=1 )2795 points = num.concatenate( (x[:,num.NewAxis],y[:,num.NewAxis]), axis=1 ) 2816 2796 sww2pts(self.domain.get_name(), 2817 2797 quantity = 'elevation', … … 2823 2803 #print 'P', point_values 2824 2804 #print 'Ref', ref_point_values 2825 assert allclose(point_values, ref_point_values)2805 assert num.allclose(point_values, ref_point_values) 2826 2806 2827 2807 … … 2841 2821 #print 'P', point_values 2842 2822 #print 'Ref', ref_point_values 2843 assert allclose(point_values, ref_point_values)2823 assert num.allclose(point_values, ref_point_values) 2844 2824 2845 2825 … … 2898 2878 2899 2879 #Check that first coordinate is correctly represented 2900 assert allclose(x[0], e)2901 assert allclose(y[0], n)2880 assert num.allclose(x[0], e) 2881 assert num.allclose(y[0], n) 2902 2882 2903 2883 #Check first value … … 2908 2888 #print ymomentum 2909 2889 2910 assert allclose(stage[0,0], first_value/100) #Meters2890 assert num.allclose(stage[0,0], first_value/100) #Meters 2911 2891 2912 2892 #Check fourth value 2913 assert allclose(stage[0,3], fourth_value/100) #Meters2893 assert num.allclose(stage[0,3], fourth_value/100) #Meters 2914 2894 2915 2895 fid.close() … … 2955 2935 ymomentum_1 = fid.variables['ymomentum'][:] 2956 2936 2957 assert allclose(stage_1[0,0], first_value/100) #Meters2958 assert allclose(stage_1[0,3], fourth_value/100) #Meters2937 assert num.allclose(stage_1[0,0], first_value/100) #Meters 2938 assert num.allclose(stage_1[0,3], fourth_value/100) #Meters 2959 2939 2960 2940 fid.close() … … 2975 2955 elevation = fid.variables['elevation'][:] 2976 2956 2977 assert allclose(stage_5[0,0], 5*first_value/100) #Meters2978 assert allclose(stage_5[0,3], 5*fourth_value/100) #Meters2979 2980 assert allclose(5*stage_1, stage_5)2957 assert num.allclose(stage_5[0,0], 5*first_value/100) #Meters 2958 assert num.allclose(stage_5[0,3], 5*fourth_value/100) #Meters 2959 2960 assert num.allclose(5*stage_1, stage_5) 2981 2961 2982 2962 # Momentum will also be changed due to new depth … … 2996 2976 #print i, scale, xmomentum_1[i,j], xmomentum_5[i,j] 2997 2977 2998 assert allclose(xmomentum_5[i,j], ref_xmomentum)2999 assert allclose(ymomentum_5[i,j], ref_ymomentum)2978 assert num.allclose(xmomentum_5[i,j], ref_xmomentum) 2979 assert num.allclose(ymomentum_5[i,j], ref_ymomentum) 3000 2980 3001 2981 … … 3058 3038 3059 3039 #Check that test coordinate is correctly represented 3060 assert allclose(x[linear_point_index], e)3061 assert allclose(y[linear_point_index], n)3040 assert num.allclose(x[linear_point_index], e) 3041 assert num.allclose(y[linear_point_index], n) 3062 3042 3063 3043 #Check test value 3064 3044 stage = fid.variables['stage'][:] 3065 3045 3066 assert allclose(stage[time_index, linear_point_index], test_value/100)3046 assert num.allclose(stage[time_index, linear_point_index], test_value/100) 3067 3047 3068 3048 fid.close() … … 3303 3283 third_momentum=third_speed*third_height/100 3304 3284 3305 assert allclose(ymomentum[0][0],first_momentum) #Meters3306 assert allclose(ymomentum[0][2],third_momentum) #Meters3285 assert num.allclose(ymomentum[0][0],first_momentum) #Meters 3286 assert num.allclose(ymomentum[0][2],third_momentum) #Meters 3307 3287 3308 3288 fid.close() … … 3467 3447 third_momentum=third_speed*third_height/100 3468 3448 3469 assert allclose(ymomentum[0][0],first_momentum) #Meters3470 assert allclose(ymomentum[0][2],third_momentum) #Meters3449 assert num.allclose(ymomentum[0][0],first_momentum) #Meters 3450 assert num.allclose(ymomentum[0][2],third_momentum) #Meters 3471 3451 3472 3452 fid.close() … … 3498 3478 3499 3479 #Check that first coordinate is correctly represented 3500 assert allclose(x[0], e-100000)3501 assert allclose(y[0], n-200000)3480 assert num.allclose(x[0], e-100000) 3481 assert num.allclose(y[0], n-200000) 3502 3482 3503 3483 fid.close() … … 3538 3518 3539 3519 import time, os 3540 from Numeric import array, zeros, allclose, Float, concatenate3541 3520 from Scientific.IO.NetCDF import NetCDFFile 3542 3521 … … 3565 3544 extent_sww(file_and_extension_name ) 3566 3545 3567 assert allclose(xmin, 0.0)3568 assert allclose(xmax, 1.0)3569 assert allclose(ymin, 0.0)3570 assert allclose(ymax, 1.0)3546 assert num.allclose(xmin, 0.0) 3547 assert num.allclose(xmax, 1.0) 3548 assert num.allclose(ymin, 0.0) 3549 assert num.allclose(ymax, 1.0) 3571 3550 3572 3551 # FIXME (Ole): Revisit these numbers 3573 #assert allclose(stagemin, -0.85), 'stagemin=%.4f' %stagemin3574 #assert allclose(stagemax, 0.15), 'stagemax=%.4f' %stagemax3552 #assert num.allclose(stagemin, -0.85), 'stagemin=%.4f' %stagemin 3553 #assert num.allclose(stagemax, 0.15), 'stagemax=%.4f' %stagemax 3575 3554 3576 3555 … … 3585 3564 ################################################ 3586 3565 from mesh_factory import rectangular 3587 from Numeric import array3588 3566 3589 3567 #Create basic mesh … … 3630 3608 ########################################## 3631 3609 from data_manager import sww2domain 3632 from Numeric import allclose3633 3610 import os 3634 3611 … … 3652 3629 #print bit 3653 3630 #print 'done' 3654 assert allclose(eval('domain.'+bit),eval('domain2.'+bit))3631 assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit)) 3655 3632 3656 3633 ###################################### … … 3711 3688 #print eval('domain.'+bit+'-domain2.'+bit) 3712 3689 msg = 'Values in the two domains are different for ' + bit 3713 assert allclose(eval('domain.'+bit),eval('domain2.'+bit),3714 rtol=1.e-5, atol=3.e-8), msg3690 assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit), 3691 rtol=1.e-5, atol=3.e-8), msg 3715 3692 3716 3693 … … 3722 3699 3723 3700 from mesh_factory import rectangular 3724 from Numeric import array3725 3701 3726 3702 #Create basic mesh … … 3764 3740 ################################## 3765 3741 from data_manager import sww2domain 3766 from Numeric import allclose3767 3742 import os 3768 3743 … … 3791 3766 for bit in bits: 3792 3767 # print 'testing that domain.'+bit+' has been restored' 3793 assert allclose(eval('domain.'+bit),eval('domain2.'+bit))3768 assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit)) 3794 3769 3795 3770 #print filler … … 3831 3806 ################################################ 3832 3807 from mesh_factory import rectangular 3833 from Numeric import array3834 3808 #Create basic mesh 3835 3809 … … 3875 3849 ########################################## 3876 3850 from data_manager import sww2domain 3877 from Numeric import allclose3878 3851 import os 3879 3852 … … 3902 3875 #print ('domain.'+bit), eval('domain.'+bit) 3903 3876 #print ('domain2.'+bit), eval('domain2.'+bit) 3904 assert allclose(eval('domain.'+bit),eval('domain2.'+bit),rtol=1.0e-1,atol=1.e-3)3877 assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit),rtol=1.0e-1,atol=1.e-3) 3905 3878 pass 3906 3879 … … 3954 3927 for bit in bits: 3955 3928 print bit 3956 assert allclose(eval('domain.'+bit),eval('domain2.'+bit))3929 assert num.allclose(eval('domain.'+bit),eval('domain2.'+bit)) 3957 3930 3958 3931 … … 3962 3935 3963 3936 import os 3964 from Numeric import ones, allclose, Float, arange3965 3937 from Scientific.IO.NetCDF import NetCDFFile 3966 3938 … … 3994 3966 fid.createDimension('number_of_points', nrows*ncols) 3995 3967 3996 fid.createVariable('elevation', Float, ('number_of_points',))3968 fid.createVariable('elevation', num.Float, ('number_of_points',)) 3997 3969 3998 3970 elevation = fid.variables['elevation'] 3999 3971 4000 elevation[:] = ( arange(nrows*ncols))3972 elevation[:] = (num.arange(nrows*ncols)) 4001 3973 4002 3974 fid.close() … … 4021 3993 4022 3994 #generate a stencil for computing the decimated values 4023 stencil = ones((3,3),Float) / 9.03995 stencil = num.ones((3,3), num.Float) / 9.0 4024 3996 4025 3997 decimate_dem(root, stencil=stencil, cellsize_new=100) … … 4032 4004 4033 4005 #Check values 4034 assert allclose(elevation, ref_elevation)4006 assert num.allclose(elevation, ref_elevation) 4035 4007 4036 4008 #Cleanup … … 4045 4017 4046 4018 import os 4047 from Numeric import ones, allclose, Float, arange, reshape4048 4019 from Scientific.IO.NetCDF import NetCDFFile 4049 4020 … … 4078 4049 fid.createDimension('number_of_points', nrows*ncols) 4079 4050 4080 fid.createVariable('elevation', Float, ('number_of_points',))4051 fid.createVariable('elevation', num.Float, ('number_of_points',)) 4081 4052 4082 4053 elevation = fid.variables['elevation'] 4083 4054 4084 4055 #generate initial elevation values 4085 elevation_tmp = ( arange(nrows*ncols))4056 elevation_tmp = (num.arange(nrows*ncols)) 4086 4057 #add some NODATA values 4087 4058 elevation_tmp[0] = NODATA_value … … 4116 4087 4117 4088 #generate a stencil for computing the decimated values 4118 stencil = ones((3,3),Float) / 9.04089 stencil = num.ones((3,3), num.Float) / 9.0 4119 4090 4120 4091 decimate_dem(root, stencil=stencil, cellsize_new=100) … … 4127 4098 4128 4099 #Check values 4129 assert allclose(elevation, ref_elevation)4100 assert num.allclose(elevation, ref_elevation) 4130 4101 4131 4102 #Cleanup … … 4141 4112 4142 4113 import time, os 4143 from Numeric import array, zeros, allclose, Float, concatenate4144 4114 from Scientific.IO.NetCDF import NetCDFFile 4145 4115 … … 4167 4137 4168 4138 import time, os 4169 from Numeric import array, zeros, allclose, Float, concatenate4170 4139 from Scientific.IO.NetCDF import NetCDFFile 4171 4140 … … 4315 4284 y_ref = geo_ref.get_yllcorner() 4316 4285 self.failUnless(geo_ref.get_zone() == 55, 'Failed') 4317 assert allclose(x_ref, 587798.418) # (-38, 148)4318 assert allclose(y_ref, 5793123.477)# (-38, 148.5)4286 assert num.allclose(x_ref, 587798.418) # (-38, 148) 4287 assert num.allclose(y_ref, 5793123.477)# (-38, 148.5) 4319 4288 4320 4289 #Zone: 55 4321 4290 #Easting: 588095.674 Northing: 5821451.722 4322 4291 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 0 ' 0.00000 '' 4323 assert allclose((x[0],y[0]), (588095.674 - x_ref, 5821451.722 - y_ref))4292 assert num.allclose((x[0],y[0]), (588095.674 - x_ref, 5821451.722 - y_ref)) 4324 4293 4325 4294 #Zone: 55 4326 4295 #Easting: 632145.632 Northing: 5820863.269 4327 4296 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 4328 assert allclose((x[2],y[2]), (632145.632 - x_ref, 5820863.269 - y_ref))4297 assert num.allclose((x[2],y[2]), (632145.632 - x_ref, 5820863.269 - y_ref)) 4329 4298 4330 4299 #Zone: 55 4331 4300 #Easting: 609748.788 Northing: 5793447.860 4332 4301 #Latitude: -38 0 ' 0.00000 '' Longitude: 148 15 ' 0.00000 '' 4333 assert allclose((x[4],y[4]), (609748.788 - x_ref, 5793447.86 - y_ref))4334 4335 assert allclose(z[0],9000.0 )4336 assert allclose(stage[0][1],0.0 )4302 assert num.allclose((x[4],y[4]), (609748.788 - x_ref, 5793447.86 - y_ref)) 4303 4304 assert num.allclose(z[0],9000.0 ) 4305 assert num.allclose(stage[0][1],0.0 ) 4337 4306 4338 4307 #(4000+1000)*60 4339 assert allclose(xmomentum[1][1],300000.0 )4308 assert num.allclose(xmomentum[1][1],300000.0 ) 4340 4309 4341 4310 … … 4625 4594 y_ref = geo_ref.get_yllcorner() 4626 4595 self.failUnless(geo_ref.get_zone() == 55, 'Failed') 4627 assert allclose(x_ref, 587798.418) # (-38, 148)4628 assert allclose(y_ref, 5793123.477)# (-38, 148.5)4596 assert num.allclose(x_ref, 587798.418) # (-38, 148) 4597 assert num.allclose(y_ref, 5793123.477)# (-38, 148.5) 4629 4598 4630 4599 #Zone: 55 4631 4600 #Easting: 588095.674 Northing: 5821451.722 4632 4601 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 0 ' 0.00000 '' 4633 assert allclose((x[0],y[0]), (588095.674 - x_ref, 5821451.722 - y_ref))4602 assert num.allclose((x[0],y[0]), (588095.674 - x_ref, 5821451.722 - y_ref)) 4634 4603 4635 4604 #Zone: 55 4636 4605 #Easting: 632145.632 Northing: 5820863.269 4637 4606 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 4638 assert allclose((x[2],y[2]), (632145.632 - x_ref, 5820863.269 - y_ref))4607 assert num.allclose((x[2],y[2]), (632145.632 - x_ref, 5820863.269 - y_ref)) 4639 4608 4640 4609 #Zone: 55 4641 4610 #Easting: 609748.788 Northing: 5793447.860 4642 4611 #Latitude: -38 0 ' 0.00000 '' Longitude: 148 15 ' 0.00000 '' 4643 assert allclose((x[4],y[4]), (609748.788 - x_ref, 5793447.86 - y_ref))4644 4645 assert allclose(z[0],9000.0 )4646 assert allclose(stage[0][4],100.0 )4647 assert allclose(stage[0][5],100.0 )4612 assert num.allclose((x[4],y[4]), (609748.788 - x_ref, 5793447.86 - y_ref)) 4613 4614 assert num.allclose(z[0],9000.0 ) 4615 assert num.allclose(stage[0][4],100.0 ) 4616 assert num.allclose(stage[0][5],100.0 ) 4648 4617 4649 4618 #(100.0 - 9000)*10 4650 assert allclose(xmomentum[0][4], -89000.0 )4619 assert num.allclose(xmomentum[0][4], -89000.0 ) 4651 4620 4652 4621 #(100.0 - -1000.000)*10 4653 assert allclose(xmomentum[0][5], 11000.0 )4622 assert num.allclose(xmomentum[0][5], 11000.0 ) 4654 4623 4655 4624 fid.close() … … 4821 4790 self.failUnless(geo_ref.get_zone() == 55, 'Failed') 4822 4791 4823 assert allclose(fid.starttime, 0.0) # (-37.45, 148.25)4824 assert allclose(x_ref, 610120.388) # (-37.45, 148.25)4825 assert allclose(y_ref, 5820863.269 )# (-37.45, 148.5)4792 assert num.allclose(fid.starttime, 0.0) # (-37.45, 148.25) 4793 assert num.allclose(x_ref, 610120.388) # (-37.45, 148.25) 4794 assert num.allclose(y_ref, 5820863.269 )# (-37.45, 148.5) 4826 4795 4827 4796 #Easting: 632145.632 Northing: 5820863.269 … … 4837 4806 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 4838 4807 # magic number - y is close enough for me. 4839 assert allclose(x[3], 632145.63 - x_ref)4840 assert allclose(y[3], 5820863.269 - y_ref + 5.22155314684e-005)4841 4842 assert allclose(z[0],9000.0 ) #z is elevation info4808 assert num.allclose(x[3], 632145.63 - x_ref) 4809 assert num.allclose(y[3], 5820863.269 - y_ref + 5.22155314684e-005) 4810 4811 assert num.allclose(z[0],9000.0 ) #z is elevation info 4843 4812 #print "z",z 4844 4813 # 2 time steps, 4 points … … 4847 4816 4848 4817 #(100.0 - -1000.000)*10 4849 #assert allclose(xmomentum[0][5], 11000.0 )4818 #assert num.allclose(xmomentum[0][5], 11000.0 ) 4850 4819 4851 4820 fid.close() … … 4981 4950 4982 4951 ## 7th test 4983 m2d = array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]])4952 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) 4984 4953 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( 4985 4954 latitudes,longitudes, … … 5041 5010 longitudes = [148,149,150,151] 5042 5011 5043 m2d = array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]])5012 m2d = num.array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) 5044 5013 5045 5014 # k - lat … … 5327 5296 points = gsd.get_data_points(absolute=True) 5328 5297 5329 assert allclose(points[0][0], 308728.009)5330 assert allclose(points[0][1], 6180432.601)5331 assert allclose(points[1][0], 222908.705)5332 assert allclose(points[1][1], 6233785.284)5298 assert num.allclose(points[0][0], 308728.009) 5299 assert num.allclose(points[0][1], 6180432.601) 5300 assert num.allclose(points[1][0], 222908.705) 5301 assert num.allclose(points[1][1], 6233785.284) 5333 5302 self.failUnless(gsd.get_geo_reference().get_zone() == 56, 5334 5303 'Bad zone error!') … … 5433 5402 points = gsd.get_data_points(absolute=True) 5434 5403 5435 assert allclose(points[0][0], 115)5436 assert allclose(points[0][1], 7)5437 assert allclose(points[1][0], 114)5438 assert allclose(points[1][1], 8)5439 assert allclose(points[2][0], 114.5)5440 assert allclose(points[2][1], 9)5404 assert num.allclose(points[0][0], 115) 5405 assert num.allclose(points[0][1], 7) 5406 assert num.allclose(points[1][0], 114) 5407 assert num.allclose(points[1][1], 8) 5408 assert num.allclose(points[2][0], 114.5) 5409 assert num.allclose(points[2][1], 9) 5441 5410 self.failUnless(gsd.get_geo_reference().get_zone() == -1, 5442 5411 'Bad zone error!') … … 5460 5429 5461 5430 points = gsd.get_data_points(absolute=True) 5462 assert allclose(points[0][0], 5.5)5463 assert allclose(points[0][1], 0.5)5464 assert allclose(points[1][0], 4.5)5465 assert allclose(points[1][1], 1.0)5466 assert allclose(points[2][0], 4.5)5467 assert allclose(points[2][1], 1.5)5431 assert num.allclose(points[0][0], 5.5) 5432 assert num.allclose(points[0][1], 0.5) 5433 assert num.allclose(points[1][0], 4.5) 5434 assert num.allclose(points[1][1], 1.0) 5435 assert num.allclose(points[2][0], 4.5) 5436 assert num.allclose(points[2][1], 1.5) 5468 5437 self.failUnless(gsd.get_geo_reference().get_zone() == -1, 5469 5438 'Bad zone error!') … … 5508 5477 quantities_init[i] = ensure_numeric(quantities_init[i]) 5509 5478 #print "HA_init", HA_init 5510 q_time = zeros((time_step_count, points_num),Float)5479 q_time = num.zeros((time_step_count, points_num), num.Float) 5511 5480 for time in range(time_step_count): 5512 5481 q_time[time,:] = quantities_init[i] #* time * 4 … … 5592 5561 quantities_init[i] = ensure_numeric(quantities_init[i]) 5593 5562 #print "HA_init", HA_init 5594 q_time = zeros((time_step_count, points_num),Float)5563 q_time = num.zeros((time_step_count, points_num), num.Float) 5595 5564 for time in range(time_step_count): 5596 5565 q_time[time,:] = quantities_init[i] #* time * 4 … … 5698 5667 zone, e, n = redfearn(-34.5, 150.66667) 5699 5668 5700 assert allclose(geo_reference.get_absolute([[x[0],y[0]]]), [e,n])5669 assert num.allclose(geo_reference.get_absolute([[x[0],y[0]]]), [e,n]) 5701 5670 5702 5671 # Make x and y absolute … … 5711 5680 ymomentum = fid.variables['ymomentum'][:] 5712 5681 elevation = fid.variables['elevation'][:] 5713 assert allclose(stage[0,0], e +tide) #Meters5682 assert num.allclose(stage[0,0], e +tide) #Meters 5714 5683 5715 5684 #Check the momentums - ua … … 5723 5692 #print "answer_x",answer_x 5724 5693 #print "actual_x",actual_x 5725 assert allclose(answer_x, actual_x) #Meters5694 assert num.allclose(answer_x, actual_x) #Meters 5726 5695 5727 5696 #Check the momentums - va … … 5734 5703 #print "answer_y",answer_y 5735 5704 #print "actual_y",actual_y 5736 assert allclose(answer_y, actual_y) #Meters5737 5738 assert allclose(answer_x, actual_x) #Meters5705 assert num.allclose(answer_y, actual_y) #Meters 5706 5707 assert num.allclose(answer_x, actual_x) #Meters 5739 5708 5740 5709 # check the stage values, first time step. 5741 5710 # These arrays are equal since the Easting values were used as 5742 5711 # the stage 5743 assert allclose(stage[0], x +tide) #Meters5712 assert num.allclose(stage[0], x +tide) #Meters 5744 5713 5745 5714 # check the elevation values. … … 5747 5716 # these arrays are equal since the northing values were used as 5748 5717 # the elevation 5749 assert allclose(-elevation, y) #Meters5718 assert num.allclose(-elevation, y) #Meters 5750 5719 5751 5720 fid.close() … … 5806 5775 answer = 115 5807 5776 actual = xmomentum[0,0] 5808 assert allclose(answer, actual) #Meters^2/ sec5777 assert num.allclose(answer, actual) #Meters^2/ sec 5809 5778 answer = 230 5810 5779 actual = ymomentum[0,0] 5811 5780 #print "answer",answer 5812 5781 #print "actual",actual 5813 assert allclose(answer, actual) #Meters^2/ sec5782 assert num.allclose(answer, actual) #Meters^2/ sec 5814 5783 5815 5784 # check the stage values, first time step. … … 5853 5822 time = fid.variables['time'][:] 5854 5823 #print "time", time 5855 assert allclose([0.,0.5,1.], time)5824 assert num.allclose([0.,0.5,1.], time) 5856 5825 assert fid.starttime == 0.0 5857 5826 #Check that first coordinate is correctly represented … … 5859 5828 zone, e, n = redfearn(-34.5, 150.66667) 5860 5829 5861 assert allclose([x[0],y[0]], [e,n])5830 assert num.allclose([x[0],y[0]], [e,n]) 5862 5831 5863 5832 … … 5867 5836 ymomentum = fid.variables['ymomentum'][:] 5868 5837 elevation = fid.variables['elevation'][:] 5869 assert allclose(stage[0,0], e +tide) #Meters5838 assert num.allclose(stage[0,0], e +tide) #Meters 5870 5839 5871 5840 #Check the momentums - ua … … 5876 5845 answer = n*(e+tide+n) 5877 5846 actual = xmomentum[0,0] 5878 assert allclose(answer, actual) #Meters5847 assert num.allclose(answer, actual) #Meters 5879 5848 5880 5849 # check the stage values, first time step. 5881 5850 # These arrays are equal since the Easting values were used as 5882 5851 # the stage 5883 assert allclose(stage[0], x +tide) #Meters5852 assert num.allclose(stage[0], x +tide) #Meters 5884 5853 5885 5854 # check the elevation values. … … 5887 5856 # these arrays are equal since the northing values were used as 5888 5857 # the elevation 5889 assert allclose(-elevation, y) #Meters5858 assert num.allclose(-elevation, y) #Meters 5890 5859 5891 5860 fid.close() … … 5928 5897 #Work out the UTM coordinates for first point 5929 5898 zone, e, n = redfearn(-34.5, 150.66667) 5930 assert allclose([x[0],y[0]], [e,n])5899 assert num.allclose([x[0],y[0]], [e,n]) 5931 5900 5932 5901 … … 5936 5905 ymomentum = fid.variables['ymomentum'][:] 5937 5906 elevation = fid.variables['elevation'][:] 5938 assert allclose(stage[0,0], e +tide) #Meters5907 assert num.allclose(stage[0,0], e +tide) #Meters 5939 5908 5940 5909 #Check the momentums - ua … … 5945 5914 answer = n*(e+tide+n) 5946 5915 actual = xmomentum[0,0] 5947 assert allclose(answer, actual) #Meters5916 assert num.allclose(answer, actual) #Meters 5948 5917 5949 5918 # check the stage values, first time step. 5950 5919 # These arrays are equal since the Easting values were used as 5951 5920 # the stage 5952 assert allclose(stage[0], x +tide) #Meters5921 assert num.allclose(stage[0], x +tide) #Meters 5953 5922 5954 5923 # check the elevation values. … … 5956 5925 # these arrays are equal since the northing values were used as 5957 5926 # the elevation 5958 assert allclose(-elevation, y) #Meters5927 assert num.allclose(-elevation, y) #Meters 5959 5928 5960 5929 fid.close() … … 5984 5953 5985 5954 time = fid.variables['time'][:] 5986 assert allclose(time, [0.0]) # the time is relative5955 assert num.allclose(time, [0.0]) # the time is relative 5987 5956 assert fid.starttime == 0.5 5988 5957 … … 6048 6017 if ha is None: 6049 6018 this_ha = e 6050 quantities_init[0].append( ones(time_step_count,Float)*this_ha) # HA6019 quantities_init[0].append(num.ones(time_step_count,num.Float)*this_ha) # HA 6051 6020 else: 6052 6021 quantities_init[0].append(ha[i]) 6053 6022 if ua is None: 6054 6023 this_ua = n 6055 quantities_init[1].append( ones(time_step_count,Float)*this_ua) # UA6024 quantities_init[1].append(num.ones(time_step_count,num.Float)*this_ua) # UA 6056 6025 else: 6057 6026 quantities_init[1].append(ua[i]) 6058 6027 if va is None: 6059 6028 this_va = e 6060 quantities_init[2].append( ones(time_step_count,Float)*this_va) #6029 quantities_init[2].append(num.ones(time_step_count,num.Float)*this_va) # 6061 6030 else: 6062 6031 quantities_init[2].append(va[i]) … … 6068 6037 files = [] 6069 6038 for i, q in enumerate(quantities): 6070 q_time = zeros((time_step_count, points_num),Float)6039 q_time = num.zeros((time_step_count, points_num), num.Float) 6071 6040 quantities_init[i] = ensure_numeric(quantities_init[i]) 6072 6041 for time in range(time_step_count): … … 6137 6106 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6138 6107 n=len(lat_long_points) 6139 first_tstep= ones(n,Int)6140 last_tstep=time_step_count* ones(n,Int)6141 depth=20* ones(n,Float)6142 ha=2* ones((n,time_step_count),Float)6143 ua=5* ones((n,time_step_count),Float)6144 va=-10* ones((n,time_step_count),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) 6145 6114 #-ve added to take into account mux file format where south is positive. 6146 6115 base_name, files = self.write_mux2(lat_long_points, … … 6152 6121 va=va) 6153 6122 6154 weights= ones(1,Float)6123 weights=num.ones(1, num.Float) 6155 6124 #ensure that files are indeed mux2 files 6156 6125 times, latitudes, longitudes, elevation, stage, starttime = read_mux2_py([files[0]],weights) 6157 6126 ua_times, ua_latitudes, ua_longitudes, ua_elevation, xvelocity,starttime_ua=read_mux2_py([files[1]],weights) 6158 6127 msg='ha and ua have different gauge meta data' 6159 assert allclose(times,ua_times) and allclose(latitudes,ua_latitudes) and allclose(longitudes,ua_longitudes) and allclose(elevation,ua_elevation) andallclose(starttime,starttime_ua), msg6128 assert num.allclose(times,ua_times) and num.allclose(latitudes,ua_latitudes) and num.allclose(longitudes,ua_longitudes) and num.allclose(elevation,ua_elevation) and num.allclose(starttime,starttime_ua), msg 6160 6129 va_times, va_latitudes, va_longitudes, va_elevation, yvelocity, starttime_va=read_mux2_py([files[2]],weights) 6161 6130 msg='ha and va have different gauge meta data' 6162 assert allclose(times,va_times) and allclose(latitudes,va_latitudes) and allclose(longitudes,va_longitudes) and allclose(elevation,va_elevation) andallclose(starttime,starttime_va), msg6131 assert num.allclose(times,va_times) and num.allclose(latitudes,va_latitudes) and num.allclose(longitudes,va_longitudes) and num.allclose(elevation,va_elevation) and num.allclose(starttime,starttime_va), msg 6163 6132 6164 6133 self.delete_mux(files) … … 6168 6137 6169 6138 msg = 'time array is incorrect' 6170 #assert allclose(times,time_step* arange(1,time_step_count+1)),msg6171 assert allclose(times,time_step*arange(time_step_count)), msg6139 #assert allclose(times,time_step*num.arange(1,time_step_count+1)),msg 6140 assert num.allclose(times,time_step*num.arange(time_step_count)), msg 6172 6141 6173 6142 msg='Incorrect gauge positions returned' 6174 6143 for i,point in enumerate(lat_long_points): 6175 assert allclose(latitudes[i],point[0]) andallclose(longitudes[i],point[1]),msg6144 assert num.allclose(latitudes[i],point[0]) and num.allclose(longitudes[i],point[1]),msg 6176 6145 6177 6146 msg='Incorrect gauge depths returned' 6178 assert allclose(elevation,-depth),msg6147 assert num.allclose(elevation,-depth),msg 6179 6148 msg='incorrect gauge height time series returned' 6180 assert allclose(stage,ha)6149 assert num.allclose(stage,ha) 6181 6150 msg='incorrect gauge ua time series returned' 6182 assert allclose(xvelocity,ua)6151 assert num.allclose(xvelocity,ua) 6183 6152 msg='incorrect gauge va time series returned' 6184 assert allclose(yvelocity,va)6153 assert num.allclose(yvelocity,va) 6185 6154 6186 6155 def test_urs2sts_read_mux2_pyII(self): … … 6192 6161 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6193 6162 n=len(lat_long_points) 6194 first_tstep= ones(n,Int)6195 last_tstep=(time_step_count)* ones(n,Int)6196 depth=20* ones(n,Float)6197 ha=2* ones((n,time_step_count),Float)6198 ha[0]= arange(0,time_step_count)+16199 ha[1]=time_step_count- arange(1,time_step_count+1)6200 ha[1]= arange(time_step_count,2*time_step_count)6201 ha[2]= arange(2*time_step_count,3*time_step_count)6202 ha[3]= arange(3*time_step_count,4*time_step_count)6203 ua=5* ones((n,time_step_count),Float)6204 va=-10* ones((n,time_step_count),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 ha[0]=num.arange(0,time_step_count)+1 6168 ha[1]=time_step_count-num.arange(1,time_step_count+1) 6169 ha[1]=num.arange(time_step_count,2*time_step_count) 6170 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6205 6174 #-ve added to take into account mux file format where south is positive. 6206 6175 base_name, files = self.write_mux2(lat_long_points, … … 6212 6181 va=va) 6213 6182 6214 weights= ones(1,Float)6183 weights=num.ones(1, num.Float) 6215 6184 #ensure that files are indeed mux2 files 6216 6185 times, latitudes, longitudes, elevation, stage,starttime=read_mux2_py([files[0]],weights) 6217 6186 ua_times, ua_latitudes, ua_longitudes, ua_elevation, xvelocity,starttime_ua=read_mux2_py([files[1]],weights) 6218 6187 msg='ha and ua have different gauge meta data' 6219 assert allclose(times,ua_times) and allclose(latitudes,ua_latitudes) and allclose(longitudes,ua_longitudes) and allclose(elevation,ua_elevation) andallclose(starttime,starttime_ua), msg6188 assert num.allclose(times,ua_times) and num.allclose(latitudes,ua_latitudes) and num.allclose(longitudes,ua_longitudes) and num.allclose(elevation,ua_elevation) and num.allclose(starttime,starttime_ua), msg 6220 6189 va_times, va_latitudes, va_longitudes, va_elevation, yvelocity,starttime_va=read_mux2_py([files[2]],weights) 6221 6190 msg='ha and va have different gauge meta data' 6222 assert allclose(times,va_times) and allclose(latitudes,va_latitudes) and allclose(longitudes,va_longitudes) and allclose(elevation,va_elevation) andallclose(starttime,starttime_va), msg6191 assert num.allclose(times,va_times) and num.allclose(latitudes,va_latitudes) and num.allclose(longitudes,va_longitudes) and num.allclose(elevation,va_elevation) and num.allclose(starttime,starttime_va), msg 6223 6192 6224 6193 … … 6228 6197 #assert times.shape[0]==time_step_count,msg 6229 6198 msg = 'time array is incorrect' 6230 #assert allclose(times,time_step* arange(1,time_step_count+1)),msg6199 #assert allclose(times,time_step*num.arange(1,time_step_count+1)),msg 6231 6200 msg='Incorrect gauge positions returned' 6232 6201 for i,point in enumerate(lat_long_points): 6233 assert allclose(latitudes[i],point[0]) andallclose(longitudes[i],point[1]),msg6202 assert num.allclose(latitudes[i],point[0]) and num.allclose(longitudes[i],point[1]),msg 6234 6203 6235 6204 msg='Incorrect gauge depths returned' 6236 assert allclose(elevation,-depth),msg6205 assert num.allclose(elevation,-depth),msg 6237 6206 msg='incorrect gauge height time series returned' 6238 assert allclose(stage,ha)6207 assert num.allclose(stage,ha) 6239 6208 msg='incorrect gauge ua time series returned' 6240 assert allclose(xvelocity,ua)6209 assert num.allclose(xvelocity,ua) 6241 6210 msg='incorrect gauge va time series returned' 6242 assert allclose(yvelocity,va)6211 assert num.allclose(yvelocity,va) 6243 6212 6244 6213 def test_urs2sts_read_mux2_pyIII(self): … … 6250 6219 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6251 6220 n=len(lat_long_points) 6252 first_tstep= ones(n,Int)6221 first_tstep=num.ones(n,num.Int) 6253 6222 first_tstep[0]+=1 6254 6223 first_tstep[2]+=1 6255 last_tstep=(time_step_count)* ones(n,Int)6224 last_tstep=(time_step_count)*num.ones(n,num.Int) 6256 6225 last_tstep[0]-=1 6257 6226 6258 depth=20* ones(n,Float)6259 ha=2* ones((n,time_step_count),Float)6260 ha[0]= arange(0,time_step_count)6261 ha[1]= arange(time_step_count,2*time_step_count)6262 ha[2]= arange(2*time_step_count,3*time_step_count)6263 ha[3]= arange(3*time_step_count,4*time_step_count)6264 ua=5* ones((n,time_step_count),Float)6265 va=-10* ones((n,time_step_count),Float)6227 depth=20*num.ones(n,num.Float) 6228 ha=2*num.ones((n,time_step_count),num.Float) 6229 ha[0]=num.arange(0,time_step_count) 6230 ha[1]=num.arange(time_step_count,2*time_step_count) 6231 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6266 6235 #-ve added to take into account mux file format where south is positive. 6267 6236 base_name, files = self.write_mux2(lat_long_points, … … 6273 6242 va=va) 6274 6243 6275 weights= ones(1,Float)6244 weights=num.ones(1, num.Float) 6276 6245 #ensure that files are indeed mux2 files 6277 6246 times, latitudes, longitudes, elevation, stage, starttime=read_mux2_py([files[0]],weights) 6278 6247 ua_times, ua_latitudes, ua_longitudes, ua_elevation, xvelocity, starttime_ua=read_mux2_py([files[1]],weights) 6279 6248 msg='ha and ua have different gauge meta data' 6280 assert allclose(times,ua_times) and allclose(latitudes,ua_latitudes) and allclose(longitudes,ua_longitudes) and allclose(elevation,ua_elevation) andallclose(starttime,starttime_ua), msg6249 assert num.allclose(times,ua_times) and num.allclose(latitudes,ua_latitudes) and num.allclose(longitudes,ua_longitudes) and num.allclose(elevation,ua_elevation) and num.allclose(starttime,starttime_ua), msg 6281 6250 va_times, va_latitudes, va_longitudes, va_elevation, yvelocity,starttime_va=read_mux2_py([files[2]],weights) 6282 6251 msg='ha and va have different gauge meta data' 6283 assert allclose(times,va_times) and allclose(latitudes,va_latitudes) and allclose(longitudes,va_longitudes) and allclose(elevation,va_elevation) andallclose(starttime,starttime_va), msg6252 assert num.allclose(times,va_times) and num.allclose(latitudes,va_latitudes) and num.allclose(longitudes,va_longitudes) and num.allclose(elevation,va_elevation) and num.allclose(starttime,starttime_va), msg 6284 6253 6285 6254 self.delete_mux(files) … … 6288 6257 #assert times.shape[0]==time_step_count,msg 6289 6258 msg = 'time array is incorrect' 6290 #assert allclose(times,time_step* arange(1,time_step_count+1)),msg6259 #assert allclose(times,time_step*num.arange(1,time_step_count+1)),msg 6291 6260 msg='Incorrect gauge positions returned' 6292 6261 for i,point in enumerate(lat_long_points): 6293 assert allclose(latitudes[i],point[0]) andallclose(longitudes[i],point[1]),msg6262 assert num.allclose(latitudes[i],point[0]) and num.allclose(longitudes[i],point[1]),msg 6294 6263 6295 6264 … … 6306 6275 va[2][0]=0.0; 6307 6276 msg='Incorrect gauge depths returned' 6308 assert allclose(elevation,-depth),msg6277 assert num.allclose(elevation,-depth),msg 6309 6278 msg='incorrect gauge height time series returned' 6310 assert allclose(stage,ha)6279 assert num.allclose(stage,ha) 6311 6280 msg='incorrect gauge ua time series returned' 6312 assert allclose(xvelocity,ua)6281 assert num.allclose(xvelocity,ua) 6313 6282 msg='incorrect gauge va time series returned' 6314 assert allclose(yvelocity,va)6283 assert num.allclose(yvelocity,va) 6315 6284 6316 6285 … … 6326 6295 """ 6327 6296 6328 from Numeric import sin, cos6329 6297 from urs_ext import read_mux2 6330 6298 … … 6334 6302 time_step_count = 10 6335 6303 time_step = 0.2 6336 times_ref = arange(0, time_step_count*time_step, time_step)6304 times_ref = num.arange(0, time_step_count*time_step, time_step) 6337 6305 6338 6306 lat_long_points = [(-21.5,114.5), (-21,114.5), (-21.5,115), (-21.,115.), (-22., 117.)] … … 6340 6308 6341 6309 # Create different timeseries starting and ending at different times 6342 first_tstep= ones(n,Int)6310 first_tstep=num.ones(n, num.Int) 6343 6311 first_tstep[0]+=2 # Point 0 starts at 2 6344 6312 first_tstep[1]+=4 # Point 1 starts at 4 6345 6313 first_tstep[2]+=3 # Point 2 starts at 3 6346 6314 6347 last_tstep=(time_step_count)* ones(n,Int)6315 last_tstep=(time_step_count)*num.ones(n,num.Int) 6348 6316 last_tstep[0]-=1 # Point 0 ends 1 step early 6349 6317 last_tstep[1]-=2 # Point 1 ends 2 steps early … … 6351 6319 6352 6320 # Create varying elevation data (positive values for seafloor) 6353 gauge_depth=20* ones(n,Float)6321 gauge_depth=20*num.ones(n,num.Float) 6354 6322 for i in range(n): 6355 6323 gauge_depth[i] += i**2 6356 6324 6357 6325 # Create data to be written to first mux file 6358 ha0=2* ones((n,time_step_count),Float)6359 ha0[0]= arange(0,time_step_count)6360 ha0[1]= arange(time_step_count,2*time_step_count)6361 ha0[2]= arange(2*time_step_count,3*time_step_count)6362 ha0[3]= arange(3*time_step_count,4*time_step_count)6363 ua0=5* ones((n,time_step_count),Float)6364 va0=-10* ones((n,time_step_count),Float)6326 ha0=2*num.ones((n,time_step_count),num.Float) 6327 ha0[0]=num.arange(0,time_step_count) 6328 ha0[1]=num.arange(time_step_count,2*time_step_count) 6329 ha0[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6365 6333 6366 6334 # Ensure data used to write mux file to be zero when gauges are … … 6401 6369 # For each quantity read the associated list of source mux2 file with 6402 6370 # extention associated with that quantity 6403 file_params=-1* ones(3,Float) #[nsta,dt,nt]6371 file_params=-1*num.ones(3,num.Float) #[nsta,dt,nt] 6404 6372 OFFSET = 5 6405 6373 … … 6413 6381 6414 6382 for i in range(number_of_selected_stations): 6415 if j == 0: assert allclose(data[i][:parameters_index], ha0[permutation[i], :])6416 if j == 1: assert allclose(data[i][:parameters_index], ua0[permutation[i], :])6417 if j == 2: assert allclose(data[i][:parameters_index], va0[permutation[i], :])6383 if j == 0: assert num.allclose(data[i][:parameters_index], ha0[permutation[i], :]) 6384 if j == 1: assert num.allclose(data[i][:parameters_index], ua0[permutation[i], :]) 6385 if j == 2: assert num.allclose(data[i][:parameters_index], va0[permutation[i], :]) 6418 6386 6419 6387 … … 6430 6398 """ 6431 6399 6432 from Numeric import sin, cos6433 6400 from urs_ext import read_mux2 6434 6401 … … 6441 6408 time_step = 0.2 6442 6409 6443 times_ref = arange(0, time_step_count*time_step, time_step)6410 times_ref = num.arange(0, time_step_count*time_step, time_step) 6444 6411 6445 6412 lat_long_points = [(-21.5,114.5), (-21,114.5), (-21.5,115), (-21.,115.), (-22., 117.)] … … 6447 6414 6448 6415 # Create different timeseries starting and ending at different times 6449 first_tstep= ones(n,Int)6416 first_tstep=num.ones(n,num.Int) 6450 6417 first_tstep[0]+=2 # Point 0 starts at 2 6451 6418 first_tstep[1]+=4 # Point 1 starts at 4 6452 6419 first_tstep[2]+=3 # Point 2 starts at 3 6453 6420 6454 last_tstep=(time_step_count)* ones(n,Int)6421 last_tstep=(time_step_count)*num.ones(n,num.Int) 6455 6422 last_tstep[0]-=1 # Point 0 ends 1 step early 6456 6423 last_tstep[1]-=2 # Point 1 ends 2 steps early … … 6458 6425 6459 6426 # Create varying elevation data (positive values for seafloor) 6460 gauge_depth=20* ones(n,Float)6427 gauge_depth=20*num.ones(n,num.Float) 6461 6428 for i in range(n): 6462 6429 gauge_depth[i] += i**2 6463 6430 6464 6431 # Create data to be written to second mux file 6465 ha1= ones((n,time_step_count),Float)6466 ha1[0]= sin(times_ref)6467 ha1[1]=2* sin(times_ref - 3)6468 ha1[2]=5* sin(4*times_ref)6469 ha1[3]= sin(times_ref)6470 ha1[4]= sin(2*times_ref-0.7)6432 ha1=num.ones((n,time_step_count),num.Float) 6433 ha1[0]=num.sin(times_ref) 6434 ha1[1]=2*num.sin(times_ref - 3) 6435 ha1[2]=5*num.sin(4*times_ref) 6436 ha1[3]=num.sin(times_ref) 6437 ha1[4]=num.sin(2*times_ref-0.7) 6471 6438 6472 ua1= zeros((n,time_step_count),Float)6473 ua1[0]=3* cos(times_ref)6474 ua1[1]=2* sin(times_ref-0.7)6475 ua1[2]= arange(3*time_step_count,4*time_step_count)6476 ua1[4]=2* ones(time_step_count)6477 6478 va1= zeros((n,time_step_count),Float)6479 va1[0]=2* cos(times_ref-0.87)6480 va1[1]=3* ones(time_step_count)6481 va1[3]=2* sin(times_ref-0.71)6439 ua1=num.zeros((n,time_step_count),num.Float) 6440 ua1[0]=3*num.cos(times_ref) 6441 ua1[1]=2*num.sin(times_ref-0.7) 6442 ua1[2]=num.arange(3*time_step_count,4*time_step_count) 6443 ua1[4]=2*num.ones(time_step_count) 6444 6445 va1=num.zeros((n,time_step_count),num.Float) 6446 va1[0]=2*num.cos(times_ref-0.87) 6447 va1[1]=3*num.ones(time_step_count) 6448 va1[3]=2*num.sin(times_ref-0.71) 6482 6449 6483 6450 # Ensure data used to write mux file to be zero when gauges are … … 6549 6516 if ha is None: 6550 6517 this_ha = e 6551 quantities_init[0].append( ones(time_step_count,Float)*this_ha) # HA6518 quantities_init[0].append(num.ones(time_step_count,num.Float)*this_ha) # HA 6552 6519 else: 6553 6520 quantities_init[0].append(ha[i]) 6554 6521 if ua is None: 6555 6522 this_ua = n 6556 quantities_init[1].append( ones(time_step_count,Float)*this_ua) # UA6523 quantities_init[1].append(num.ones(time_step_count,num.Float)*this_ua) # UA 6557 6524 else: 6558 6525 quantities_init[1].append(ua[i]) 6559 6526 if va is None: 6560 6527 this_va = e 6561 quantities_init[2].append( ones(time_step_count,Float)*this_va) #6528 quantities_init[2].append(num.ones(time_step_count,num.Float)*this_va) # 6562 6529 else: 6563 6530 quantities_init[2].append(va[i]) … … 6567 6534 #print i, q 6568 6535 6569 q_time = zeros((time_step_count, points_num),Float)6536 q_time = num.zeros((time_step_count, points_num), num.Float) 6570 6537 quantities_init[i] = ensure_numeric(quantities_init[i]) 6571 6538 for time in range(time_step_count): … … 6653 6620 # For each quantity read the associated list of source mux2 file with 6654 6621 # extention associated with that quantity 6655 file_params=-1* ones(3,Float) # [nsta,dt,nt]6622 file_params=-1*num.ones(3,num.Float) # [nsta,dt,nt] 6656 6623 OFFSET = 5 6657 6624 … … 6672 6639 parameters_index = data.shape[1]-OFFSET 6673 6640 6674 quantity= zeros((number_of_selected_stations, parameters_index),Float)6641 quantity=num.zeros((number_of_selected_stations, parameters_index), num.Float) 6675 6642 6676 6643 … … 6681 6648 6682 6649 6683 if j == 0: assert allclose(data[i][:parameters_index], ha1[permutation[i], :])6684 if j == 1: assert allclose(data[i][:parameters_index], ua1[permutation[i], :])6650 if j == 0: assert num.allclose(data[i][:parameters_index], ha1[permutation[i], :]) 6651 if j == 1: assert num.allclose(data[i][:parameters_index], ua1[permutation[i], :]) 6685 6652 if j == 2: 6686 6653 # FIXME (Ole): This is where the output is wrong on Win32 … … 6695 6662 #print 'v ', data[i][:parameters_index][8] 6696 6663 6697 assert allclose(data[i][:parameters_index], va1[permutation[i], :])6664 assert num.allclose(data[i][:parameters_index], va1[permutation[i], :]) 6698 6665 6699 6666 … … 6707 6674 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6708 6675 n=len(lat_long_points) 6709 first_tstep= ones(n,Int)6676 first_tstep=num.ones(n,num.Int) 6710 6677 first_tstep[0]+=1 6711 6678 first_tstep[2]+=1 6712 last_tstep=(time_step_count)* ones(n,Int)6679 last_tstep=(time_step_count)*num.ones(n,num.Int) 6713 6680 last_tstep[0]-=1 6714 6681 6715 gauge_depth=20* ones(n,Float)6716 ha=2* ones((n,time_step_count),Float)6717 ha[0]= arange(0,time_step_count)6718 ha[1]= arange(time_step_count,2*time_step_count)6719 ha[2]= arange(2*time_step_count,3*time_step_count)6720 ha[3]= arange(3*time_step_count,4*time_step_count)6721 ua=5* ones((n,time_step_count),Float)6722 va=-10* ones((n,time_step_count),Float)6682 gauge_depth=20*num.ones(n,num.Float) 6683 ha=2*num.ones((n,time_step_count),num.Float) 6684 ha[0]=num.arange(0,time_step_count) 6685 ha[1]=num.arange(time_step_count,2*time_step_count) 6686 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6723 6690 6724 6691 base_name, files = self.write_mux2(lat_long_points, … … 6756 6723 for i in range(4): 6757 6724 zone, e, n = redfearn(lat_long_points[i][0], lat_long_points[i][1]) 6758 assert allclose([x[i],y[i]], [e,n])6725 assert num.allclose([x[i],y[i]], [e,n]) 6759 6726 6760 6727 #Check the time vector … … 6765 6732 times_actual.append(time_step * i) 6766 6733 6767 assert allclose(ensure_numeric(times),6768 ensure_numeric(times_actual))6734 assert num.allclose(ensure_numeric(times), 6735 ensure_numeric(times_actual)) 6769 6736 6770 6737 #Check first value … … 6786 6753 va[2][0]=0.0; 6787 6754 6788 assert allclose(transpose(ha),stage) #Meters6755 assert num.allclose(num.transpose(ha),stage) #Meters 6789 6756 6790 6757 #Check the momentums - ua … … 6793 6760 #momentum = velocity_ua *(stage+depth) 6794 6761 6795 depth= zeros((len(lat_long_points),time_step_count),Float)6762 depth=num.zeros((len(lat_long_points),time_step_count),num.Float) 6796 6763 for i in range(len(lat_long_points)): 6797 6764 depth[i]=gauge_depth[i]+tide+ha[i] 6798 assert allclose(transpose(ua*depth),xmomentum)6765 assert num.allclose(num.transpose(ua*depth),xmomentum) 6799 6766 6800 6767 #Check the momentums - va … … 6803 6770 #momentum = velocity_va *(stage+depth) 6804 6771 6805 assert allclose(transpose(va*depth),ymomentum)6772 assert num.allclose(num.transpose(va*depth),ymomentum) 6806 6773 6807 6774 # check the elevation values. 6808 6775 # -ve since urs measures depth, sww meshers height, 6809 assert allclose(-elevation, gauge_depth) #Meters6776 assert num.allclose(-elevation, gauge_depth) #Meters 6810 6777 6811 6778 fid.close() … … 6822 6789 lat_long_points =[(-21.,114.5),(-21.,113.5),(-21.,114.), (-21.,115.)] 6823 6790 n=len(lat_long_points) 6824 first_tstep= ones(n,Int)6791 first_tstep=num.ones(n,num.Int) 6825 6792 first_tstep[0]+=1 6826 6793 first_tstep[2]+=1 6827 last_tstep=(time_step_count)* ones(n,Int)6794 last_tstep=(time_step_count)*num.ones(n,num.Int) 6828 6795 last_tstep[0]-=1 6829 6796 6830 gauge_depth=20* ones(n,Float)6831 ha=2* ones((n,time_step_count),Float)6832 ha[0]= arange(0,time_step_count)6833 ha[1]= arange(time_step_count,2*time_step_count)6834 ha[2]= arange(2*time_step_count,3*time_step_count)6835 ha[3]= arange(3*time_step_count,4*time_step_count)6836 ua=5* ones((n,time_step_count),Float)6837 va=-10* ones((n,time_step_count),Float)6797 gauge_depth=20*num.ones(n,num.Float) 6798 ha=2*num.ones((n,time_step_count),num.Float) 6799 ha[0]=num.arange(0,time_step_count) 6800 ha[1]=num.arange(time_step_count,2*time_step_count) 6801 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6838 6805 6839 6806 base_name, files = self.write_mux2(lat_long_points, … … 6872 6839 for i in range(4): 6873 6840 zone, e, n = redfearn(lat_long_points[i][0], lat_long_points[i][1], zone=50) 6874 assert allclose([x[i],y[i]], [e,n])6841 assert num.allclose([x[i],y[i]], [e,n]) 6875 6842 assert zone==geo_reference.zone 6876 6843 … … 6884 6851 lat_long_points =[(-21.,113.5),(-21.,114.5),(-21.,114.), (-21.,115.)] 6885 6852 n=len(lat_long_points) 6886 first_tstep= ones(n,Int)6853 first_tstep=num.ones(n,num.Int) 6887 6854 first_tstep[0]+=1 6888 6855 first_tstep[2]+=1 6889 last_tstep=(time_step_count)* ones(n,Int)6856 last_tstep=(time_step_count)*num.ones(n,num.Int) 6890 6857 last_tstep[0]-=1 6891 6858 6892 gauge_depth=20* ones(n,Float)6893 ha=2* ones((n,time_step_count),Float)6894 ha[0]= arange(0,time_step_count)6895 ha[1]= arange(time_step_count,2*time_step_count)6896 ha[2]= arange(2*time_step_count,3*time_step_count)6897 ha[3]= arange(3*time_step_count,4*time_step_count)6898 ua=5* ones((n,time_step_count),Float)6899 va=-10* ones((n,time_step_count),Float)6859 gauge_depth=20*num.ones(n,num.Float) 6860 ha=2*num.ones((n,time_step_count),num.Float) 6861 ha[0]=num.arange(0,time_step_count) 6862 ha[1]=num.arange(time_step_count,2*time_step_count) 6863 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6900 6867 6901 6868 base_name, files = self.write_mux2(lat_long_points, … … 6934 6901 for i in range(4): 6935 6902 zone, e, n = redfearn(lat_long_points[i][0], lat_long_points[i][1], zone=50) 6936 assert allclose([x[i],y[i]], [e,n])6903 assert num.allclose([x[i],y[i]], [e,n]) 6937 6904 assert zone==geo_reference.zone 6938 6905 … … 6947 6914 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 6948 6915 n=len(lat_long_points) 6949 first_tstep= ones(n,Int)6916 first_tstep=num.ones(n,num.Int) 6950 6917 first_tstep[0]+=1 6951 6918 first_tstep[2]+=1 6952 last_tstep=(time_step_count)* ones(n,Int)6919 last_tstep=(time_step_count)*num.ones(n,num.Int) 6953 6920 last_tstep[0]-=1 6954 6921 6955 gauge_depth=20* ones(n,Float)6956 ha=2* ones((n,time_step_count),Float)6957 ha[0]= arange(0,time_step_count)6958 ha[1]= arange(time_step_count,2*time_step_count)6959 ha[2]= arange(2*time_step_count,3*time_step_count)6960 ha[3]= arange(3*time_step_count,4*time_step_count)6961 ua=5* ones((n,time_step_count),Float)6962 va=-10* ones((n,time_step_count),Float)6922 gauge_depth=20*num.ones(n,num.Float) 6923 ha=2*num.ones((n,time_step_count),num.Float) 6924 ha[0]=num.arange(0,time_step_count) 6925 ha[1]=num.arange(time_step_count,2*time_step_count) 6926 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 6963 6930 6964 6931 # Create two identical mux files to be combined by urs2sts … … 7007 6974 #Work out the UTM coordinates for first point 7008 6975 zone, e, n = redfearn(lat_long_points[0][0], lat_long_points[0][1]) 7009 assert allclose([x[0],y[0]], [e,n])6976 assert num.allclose([x[0],y[0]], [e,n]) 7010 6977 7011 6978 #Check the time vector … … 7016 6983 times_actual.append(time_step * i) 7017 6984 7018 assert allclose(ensure_numeric(times),7019 ensure_numeric(times_actual))6985 assert num.allclose(ensure_numeric(times), 6986 ensure_numeric(times_actual)) 7020 6987 7021 6988 #Check first value … … 7041 7008 # in the two mux2 files because both have weights = 1. In this case 7042 7009 # the mux2 files are the same so stage == 2.0 * ha 7043 #print 2.0* transpose(ha) - stage7044 assert allclose(2.0*transpose(ha), stage) #Meters7010 #print 2.0*num.transpose(ha) - stage 7011 assert num.allclose(2.0*num.transpose(ha), stage) #Meters 7045 7012 7046 7013 #Check the momentums - ua … … 7049 7016 #momentum = velocity_ua *(stage+depth) 7050 7017 7051 depth= zeros((len(lat_long_points),time_step_count),Float)7018 depth=num.zeros((len(lat_long_points),time_step_count),num.Float) 7052 7019 for i in range(len(lat_long_points)): 7053 7020 depth[i]=gauge_depth[i]+tide+2.0*ha[i] … … 7056 7023 # The xmomentum stored in the .sts file should be the sum of the ua 7057 7024 # in the two mux2 files multiplied by the depth. 7058 assert allclose(2.0*transpose(ua*depth), xmomentum)7025 assert num.allclose(2.0*num.transpose(ua*depth), xmomentum) 7059 7026 7060 7027 #Check the momentums - va … … 7065 7032 # The ymomentum stored in the .sts file should be the sum of the va 7066 7033 # in the two mux2 files multiplied by the depth. 7067 assert allclose(2.0*transpose(va*depth), ymomentum)7034 assert num.allclose(2.0*num.transpose(va*depth), ymomentum) 7068 7035 7069 7036 # check the elevation values. 7070 7037 # -ve since urs measures depth, sww meshers height, 7071 assert allclose(-elevation, gauge_depth) #Meters7038 assert num.allclose(-elevation, gauge_depth) #Meters 7072 7039 7073 7040 fid.close() … … 7081 7048 over waveheight, easting and northing velocity 7082 7049 """ 7083 from Numeric import asarray,transpose,sqrt,argmax,argmin,arange,Float,\7084 compress,zeros,fabs,take,size7085 7050 7086 7051 # Get path where this test is run … … 7093 7058 7094 7059 # Start times by source and station taken manually from urs header files 7095 time_start_z = array([[10.0,11.5,13,14.5,17.7],7096 [9.8,11.2,12.7,14.2,17.4],7097 [9.5,10.9,12.4,13.9,17.1]])7060 time_start_z = num.array([[10.0,11.5,13,14.5,17.7], 7061 [9.8,11.2,12.7,14.2,17.4], 7062 [9.5,10.9,12.4,13.9,17.1]]) 7098 7063 7099 7064 time_start_e = time_start_n = time_start_z … … 7137 7102 msg = 'sts starttime for source %d was %f. Should have been %f'\ 7138 7103 %(source_number, sts_starttime, starttime) 7139 assert allclose(sts_starttime, starttime), msg7104 assert num.allclose(sts_starttime, starttime), msg 7140 7105 7141 7106 # For each station, compare urs2sts output to known urs output … … 7183 7148 msg = 'stage start time from urs file is not the same as the ' 7184 7149 msg += 'header file for source %i and station %i' %(source_number,j) 7185 assert allclose(index_start_urs_z,start_times_z[j]/delta_t), msg7150 assert num.allclose(index_start_urs_z,start_times_z[j]/delta_t), msg 7186 7151 7187 7152 msg = 'e velocity start time from urs file is not the same as the ' 7188 7153 msg += 'header file for source %i and station %i' %(source_number,j) 7189 assert allclose(index_start_urs_e,start_times_e[j]/delta_t), msg7154 assert num.allclose(index_start_urs_e,start_times_e[j]/delta_t), msg 7190 7155 7191 7156 msg = 'n velocity start time from urs file is not the same as the ' 7192 7157 msg += 'header file for source %i and station %i' %(source_number,j) 7193 assert allclose(index_start_urs_n,start_times_n[j]/delta_t), msg7158 assert num.allclose(index_start_urs_n,start_times_n[j]/delta_t), msg 7194 7159 7195 7160 # get index for start and end time for sts quantities … … 7218 7183 # check that urs stage and sts stage are the same 7219 7184 msg = 'urs stage is not equal to sts stage for for source %i and station %i' %(source_number,j) 7220 assert allclose(urs_stage[index_start_urs_z:index_end_urs_z],7185 assert num.allclose(urs_stage[index_start_urs_z:index_end_urs_z], 7221 7186 sts_stage[index_start_stage:index_end_stage], 7222 7187 rtol=1.0e-6, atol=1.0e-5 ), msg … … 7224 7189 # check that urs e velocity and sts xmomentum are the same 7225 7190 msg = 'urs e velocity is not equivalent to sts x momentum for for source %i and station %i' %(source_number,j) 7226 assert allclose(urs_e[index_start_urs_e:index_end_urs_e]*(urs_stage[index_start_urs_e:index_end_urs_e]-elevation[j]),7191 assert num.allclose(urs_e[index_start_urs_e:index_end_urs_e]*(urs_stage[index_start_urs_e:index_end_urs_e]-elevation[j]), 7227 7192 sts_xmom[index_start_x:index_end_x], 7228 7193 rtol=1.0e-5, atol=1.0e-4 ), msg … … 7232 7197 #print 'sts momentum', sts_ymom[index_start_y:index_end_y] 7233 7198 msg = 'urs n velocity is not equivalent to sts y momentum for source %i and station %i' %(source_number,j) 7234 assert allclose(urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j]),7199 assert num.allclose(urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j]), 7235 7200 sts_ymom[index_start_y:index_end_y], 7236 7201 rtol=1.0e-5, atol=1.0e-4 ), msg … … 7246 7211 over waveheight, easting and northing velocity 7247 7212 """ 7248 from Numeric import asarray,transpose,sqrt,argmax,argmin,arange,Float,\7249 compress,zeros,fabs,take,size7250 7213 7251 7214 # combined 7252 time_start_z = array([9.5,10.9,12.4,13.9,17.1])7215 time_start_z = num.array([9.5,10.9,12.4,13.9,17.1]) 7253 7216 time_start_e = time_start_n = time_start_z 7254 7217 … … 7286 7249 msg = 'Permutation was not stored correctly. I got ' 7287 7250 msg += str(stored_permutation) 7288 assert allclose(stored_permutation, permutation), msg7251 assert num.allclose(stored_permutation, permutation), msg 7289 7252 7290 7253 # get quantity data from sts file … … 7303 7266 msg = 'sts starttime was %f. Should have been %f'\ 7304 7267 %(sts_starttime, starttime) 7305 assert allclose(sts_starttime, starttime), msg7268 assert num.allclose(sts_starttime, starttime), msg 7306 7269 7307 7270 #stations = [1,2,3] … … 7348 7311 msg = 'stage start time from urs file is not the same as the ' 7349 7312 msg += 'header file at station %i' %(j) 7350 assert allclose(index_start_urs_z,start_times_z/delta_t), msg7313 assert num.allclose(index_start_urs_z,start_times_z/delta_t), msg 7351 7314 7352 7315 msg = 'e velocity start time from urs file is not the same as the ' 7353 7316 msg += 'header file at station %i' %(j) 7354 assert allclose(index_start_urs_e,start_times_e/delta_t), msg7317 assert num.allclose(index_start_urs_e,start_times_e/delta_t), msg 7355 7318 7356 7319 msg = 'n velocity start time from urs file is not the same as the ' 7357 7320 msg += 'header file at station %i' %(j) 7358 assert allclose(index_start_urs_n,start_times_n/delta_t), msg7321 assert num.allclose(index_start_urs_n,start_times_n/delta_t), msg 7359 7322 7360 7323 # get index for start and end time for sts quantities … … 7392 7355 #print 'diff', max(urs_stage[index_start_urs_z:index_end_urs_z]-sts_stage[index_start_stage:index_end_stage]) 7393 7356 #print 'index', index_start_stage, index_end_stage, len(sts_stage) 7394 assert allclose(urs_stage[index_start_urs_z:index_end_urs_z],7357 assert num.allclose(urs_stage[index_start_urs_z:index_end_urs_z], 7395 7358 sts_stage[index_start_stage:index_end_stage], 7396 7359 rtol=1.0e-5, atol=1.0e-4 ), msg … … 7398 7361 # check that urs e velocity and sts xmomentum are the same 7399 7362 msg = 'urs e velocity is not equivalent to sts xmomentum for station %i' %j 7400 assert allclose(urs_e[index_start_urs_e:index_end_urs_e]*(urs_stage[index_start_urs_e:index_end_urs_e]-elevation[j]),7363 assert num.allclose(urs_e[index_start_urs_e:index_end_urs_e]*(urs_stage[index_start_urs_e:index_end_urs_e]-elevation[j]), 7401 7364 sts_xmom[index_start_x:index_end_x], 7402 7365 rtol=1.0e-5, atol=1.0e-4 ), msg … … 7404 7367 # check that urs n velocity and sts ymomentum are the same 7405 7368 msg = 'urs n velocity is not equivalent to sts ymomentum for station %i' %j 7406 assert allclose(urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j]),7369 assert num.allclose(urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j]), 7407 7370 sts_ymom[index_start_y:index_end_y], 7408 7371 rtol=1.0e-5, atol=1.0e-4 ), msg … … 7423 7386 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 7424 7387 n=len(lat_long_points) 7425 first_tstep= ones(n,Int)7388 first_tstep=num.ones(n,num.Int) 7426 7389 first_tstep[0]+=1 7427 7390 first_tstep[2]+=1 7428 last_tstep=(time_step_count)* ones(n,Int)7391 last_tstep=(time_step_count)*num.ones(n,num.Int) 7429 7392 last_tstep[0]-=1 7430 7393 7431 gauge_depth=20* ones(n,Float)7432 ha=2* ones((n,time_step_count),Float)7433 ha[0]= arange(0,time_step_count)7434 ha[1]= arange(time_step_count,2*time_step_count)7435 ha[2]= arange(2*time_step_count,3*time_step_count)7436 ha[3]= arange(3*time_step_count,4*time_step_count)7437 ua=5* ones((n,time_step_count),Float)7438 va=-10* ones((n,time_step_count),Float)7394 gauge_depth=20*num.ones(n,num.Float) 7395 ha=2*num.ones((n,time_step_count),num.Float) 7396 ha[0]=num.arange(0,time_step_count) 7397 ha[1]=num.arange(time_step_count,2*time_step_count) 7398 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 7439 7402 7440 7403 # Create two identical mux files to be combined by urs2sts … … 7490 7453 msg = 'Permutation was not stored correctly. I got ' 7491 7454 msg += str(stored_permutation) 7492 assert allclose(stored_permutation, permutation), msg7455 assert num.allclose(stored_permutation, permutation), msg 7493 7456 7494 7457 … … 7515 7478 7516 7479 #print i, [x[i],y[i]], [e,n] 7517 assert allclose([x[i],y[i]], [e,n])7480 assert num.allclose([x[i],y[i]], [e,n]) 7518 7481 7519 7482 … … 7525 7488 times_actual.append(time_step * i) 7526 7489 7527 assert allclose(ensure_numeric(times),7528 ensure_numeric(times_actual))7490 assert num.allclose(ensure_numeric(times), 7491 ensure_numeric(times_actual)) 7529 7492 7530 7493 … … 7552 7515 # in the two mux2 files because both have weights = 1. In this case 7553 7516 # the mux2 files are the same so stage == 2.0 * ha 7554 #print 2.0* transpose(ha) - stage7555 7556 ha_permutation = take(ha, permutation)7557 ua_permutation = take(ua, permutation)7558 va_permutation = take(va, permutation)7559 gauge_depth_permutation = take(gauge_depth, permutation)7560 7561 7562 assert allclose(2.0*transpose(ha_permutation)+tide, stage) # Meters7517 #print 2.0*num.transpose(ha) - stage 7518 7519 ha_permutation = num.take(ha, permutation) 7520 ua_permutation = num.take(ua, permutation) 7521 va_permutation = num.take(va, permutation) 7522 gauge_depth_permutation = num.take(gauge_depth, permutation) 7523 7524 7525 assert num.allclose(2.0*num.transpose(ha_permutation)+tide, stage) # Meters 7563 7526 7564 7527 #Check the momentums - ua … … 7567 7530 #momentum = velocity_ua *(stage+depth) 7568 7531 7569 depth= zeros((len(lat_long_points),time_step_count),Float)7532 depth=num.zeros((len(lat_long_points),time_step_count),num.Float) 7570 7533 for i in range(len(lat_long_points)): 7571 7534 depth[i]=gauge_depth[i]+tide+2.0*ha[i] 7572 7535 #2.0*ha necessary because using two files with weights=1 are used 7573 7536 7574 depth_permutation = take(depth, permutation)7537 depth_permutation = num.take(depth, permutation) 7575 7538 7576 7539 7577 7540 # The xmomentum stored in the .sts file should be the sum of the ua 7578 7541 # in the two mux2 files multiplied by the depth. 7579 assert allclose(2.0*transpose(ua_permutation*depth_permutation), xmomentum)7542 assert num.allclose(2.0*num.transpose(ua_permutation*depth_permutation), xmomentum) 7580 7543 7581 7544 #Check the momentums - va … … 7586 7549 # The ymomentum stored in the .sts file should be the sum of the va 7587 7550 # in the two mux2 files multiplied by the depth. 7588 assert allclose(2.0*transpose(va_permutation*depth_permutation), ymomentum)7551 assert num.allclose(2.0*num.transpose(va_permutation*depth_permutation), ymomentum) 7589 7552 7590 7553 # check the elevation values. 7591 7554 # -ve since urs measures depth, sww meshers height, 7592 assert allclose(-gauge_depth_permutation, elevation) #Meters7555 assert num.allclose(-gauge_depth_permutation, elevation) #Meters 7593 7556 7594 7557 fid.close() … … 7610 7573 lat_long_points =[(-21.5,114.5),(-21,114.5),(-21.5,115), (-21.,115.)] 7611 7574 n=len(lat_long_points) 7612 first_tstep= ones(n,Int)7575 first_tstep=num.ones(n,num.Int) 7613 7576 first_tstep[0]+=1 7614 7577 first_tstep[2]+=1 7615 last_tstep=(time_step_count)* ones(n,Int)7578 last_tstep=(time_step_count)*num.ones(n,num.Int) 7616 7579 last_tstep[0]-=1 7617 7580 7618 gauge_depth=20* ones(n,Float)7619 ha=2* ones((n,time_step_count),Float)7620 ha[0]= arange(0,time_step_count)7621 ha[1]= arange(time_step_count,2*time_step_count)7622 ha[2]= arange(2*time_step_count,3*time_step_count)7623 ha[3]= arange(3*time_step_count,4*time_step_count)7624 ua=5* ones((n,time_step_count),Float)7625 va=-10* ones((n,time_step_count),Float)7581 gauge_depth=20*num.ones(n,num.Float) 7582 ha=2*num.ones((n,time_step_count),num.Float) 7583 ha[0]=num.arange(0,time_step_count) 7584 ha[1]=num.arange(time_step_count,2*time_step_count) 7585 ha[2]=num.arange(2*time_step_count,3*time_step_count) 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) 7626 7589 7627 7590 # Create two identical mux files to be combined by urs2sts … … 7679 7642 """ 7680 7643 7681 from Numeric import sin, cos7682 7683 7644 tide = 1.5 7684 7645 time_step_count = 10 7685 7646 time_step = 0.2 7686 7647 7687 times_ref = arange(0, time_step_count*time_step, time_step)7648 times_ref = num.arange(0, time_step_count*time_step, time_step) 7688 7649 #print 'time vector', times_ref 7689 7650 … … 7708 7669 7709 7670 # Create different timeseries starting and ending at different times 7710 first_tstep= ones(n,Int)7671 first_tstep=num.ones(n,num.Int) 7711 7672 first_tstep[0]+=2 # Point 0 starts at 2 7712 7673 first_tstep[1]+=4 # Point 1 starts at 4 7713 7674 first_tstep[2]+=3 # Point 2 starts at 3 7714 7675 7715 last_tstep=(time_step_count)* ones(n,Int)7676 last_tstep=(time_step_count)*num.ones(n,num.Int) 7716 7677 last_tstep[0]-=1 # Point 0 ends 1 step early 7717 7678 last_tstep[1]-=2 # Point 1 ends 2 steps early … … 7726 7687 7727 7688 # Create varying elevation data (positive values for seafloor) 7728 gauge_depth=20* ones(n,Float)7689 gauge_depth=20*num.ones(n,num.Float) 7729 7690 for i in range(n): 7730 7691 gauge_depth[i] += i**2 … … 7733 7694 7734 7695 # Create data to be written to first mux file 7735 ha0=2* ones((n,time_step_count),Float)7736 ha0[0]= arange(0,time_step_count)7737 ha0[1]= arange(time_step_count,2*time_step_count)7738 ha0[2]= arange(2*time_step_count,3*time_step_count)7739 ha0[3]= arange(3*time_step_count,4*time_step_count)7740 ua0=5* ones((n,time_step_count),Float)7741 va0=-10* ones((n,time_step_count),Float)7696 ha0=2*num.ones((n,time_step_count),num.Float) 7697 ha0[0]=num.arange(0,time_step_count) 7698 ha0[1]=num.arange(time_step_count,2*time_step_count) 7699 ha0[2]=num.arange(2*time_step_count,3*time_step_count) 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) 7742 7703 7743 7704 # Ensure data used to write mux file to be zero when gauges are … … 7770 7731 7771 7732 # Create data to be written to second mux file 7772 ha1= ones((n,time_step_count),Float)7773 ha1[0]= sin(times_ref)7774 ha1[1]=2* sin(times_ref - 3)7775 ha1[2]=5* sin(4*times_ref)7776 ha1[3]= sin(times_ref)7777 ha1[4]= sin(2*times_ref-0.7)7733 ha1=num.ones((n,time_step_count),num.Float) 7734 ha1[0]=num.sin(times_ref) 7735 ha1[1]=2*num.sin(times_ref - 3) 7736 ha1[2]=5*num.sin(4*times_ref) 7737 ha1[3]=num.sin(times_ref) 7738 ha1[4]=num.sin(2*times_ref-0.7) 7778 7739 7779 ua1= zeros((n,time_step_count),Float)7780 ua1[0]=3* cos(times_ref)7781 ua1[1]=2* sin(times_ref-0.7)7782 ua1[2]= arange(3*time_step_count,4*time_step_count)7783 ua1[4]=2* ones(time_step_count)7784 7785 va1= zeros((n,time_step_count),Float)7786 va1[0]=2* cos(times_ref-0.87)7787 va1[1]=3* ones(time_step_count)7788 va1[3]=2* sin(times_ref-0.71)7740 ua1=num.zeros((n,time_step_count),num.Float) 7741 ua1[0]=3*num.cos(times_ref) 7742 ua1[1]=2*num.sin(times_ref-0.7) 7743 ua1[2]=num.arange(3*time_step_count,4*time_step_count) 7744 ua1[4]=2*num.ones(time_step_count) 7745 7746 va1=num.zeros((n,time_step_count),num.Float) 7747 va1[0]=2*num.cos(times_ref-0.87) 7748 va1[1]=3*num.ones(time_step_count) 7749 va1[3]=2*num.sin(times_ref-0.71) 7789 7750 7790 7751 … … 7849 7810 msg = 'Permutation was not stored correctly. I got ' 7850 7811 msg += str(stored_permutation) 7851 assert allclose(stored_permutation, permutation), msg7812 assert num.allclose(stored_permutation, permutation), msg 7852 7813 7853 7814 … … 7873 7834 7874 7835 #print i, [x[i],y[i]], [e,n] 7875 assert allclose([x[i],y[i]], [e,n])7836 assert num.allclose([x[i],y[i]], [e,n]) 7876 7837 7877 7838 7878 7839 # Check the time vector 7879 7840 times = fid.variables['time'][:] 7880 assert allclose(ensure_numeric(times),7881 ensure_numeric(times_ref))7841 assert num.allclose(ensure_numeric(times), 7842 ensure_numeric(times_ref)) 7882 7843 7883 7844 … … 7897 7858 # quantities written to the mux2 files subject to the permutation vector. 7898 7859 7899 ha_ref = take(ha0, permutation)7900 ua_ref = take(ua0, permutation)7901 va_ref = take(va0, permutation)7902 7903 gauge_depth_ref = take(gauge_depth, permutation)7904 7905 assert allclose(transpose(ha_ref)+tide, stage0) # Meters7860 ha_ref = num.take(ha0, permutation) 7861 ua_ref = num.take(ua0, permutation) 7862 va_ref = num.take(va0, permutation) 7863 7864 gauge_depth_ref = num.take(gauge_depth, permutation) 7865 7866 assert num.allclose(num.transpose(ha_ref)+tide, stage0) # Meters 7906 7867 7907 7868 … … 7912 7873 #momentum = velocity_ua *(stage+depth) 7913 7874 7914 depth_ref = zeros((len(permutation), time_step_count),Float)7875 depth_ref = num.zeros((len(permutation), time_step_count), num.Float) 7915 7876 for i in range(len(permutation)): 7916 7877 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 7919 7880 # The xmomentum stored in the .sts file should be the sum of the ua 7920 7881 # in the two mux2 files multiplied by the depth. 7921 assert allclose(transpose(ua_ref*depth_ref), xmomentum0)7882 assert num.allclose(num.transpose(ua_ref*depth_ref), xmomentum0) 7922 7883 7923 7884 #Check the momentums - va … … 7932 7893 #print transpose(va_ref*depth_ref) 7933 7894 #print ymomentum 7934 assert allclose(transpose(va_ref*depth_ref), ymomentum0)7895 assert num.allclose(num.transpose(va_ref*depth_ref), ymomentum0) 7935 7896 7936 7897 # check the elevation values. 7937 7898 # -ve since urs measures depth, sww meshers height, 7938 assert allclose(-gauge_depth_ref, elevation0)7899 assert num.allclose(-gauge_depth_ref, elevation0) 7939 7900 7940 7901 fid.close() … … 7960 7921 msg = 'Permutation was not stored correctly. I got ' 7961 7922 msg += str(stored_permutation) 7962 assert allclose(stored_permutation, permutation), msg7923 assert num.allclose(stored_permutation, permutation), msg 7963 7924 7964 7925 # Make x and y absolute … … 7981 7942 7982 7943 #print i, [x[i],y[i]], [e,n] 7983 assert allclose([x[i],y[i]], [e,n])7944 assert num.allclose([x[i],y[i]], [e,n]) 7984 7945 7985 7946 7986 7947 # Check the time vector 7987 7948 times = fid.variables['time'][:] 7988 assert allclose(ensure_numeric(times),7989 ensure_numeric(times_ref))7949 assert num.allclose(ensure_numeric(times), 7950 ensure_numeric(times_ref)) 7990 7951 7991 7952 … … 8005 7966 # quantities written to the mux2 files subject to the permutation vector. 8006 7967 8007 ha_ref = take(ha1, permutation)8008 ua_ref = take(ua1, permutation)8009 va_ref = take(va1, permutation)8010 8011 gauge_depth_ref = take(gauge_depth, permutation)7968 ha_ref = num.take(ha1, permutation) 7969 ua_ref = num.take(ua1, permutation) 7970 va_ref = num.take(va1, permutation) 7971 7972 gauge_depth_ref = num.take(gauge_depth, permutation) 8012 7973 8013 7974 … … 8017 7978 8018 7979 8019 assert allclose(transpose(ha_ref)+tide, stage1) # Meters7980 assert num.allclose(num.transpose(ha_ref)+tide, stage1) # Meters 8020 7981 #import sys; sys.exit() 8021 7982 … … 8025 7986 #momentum = velocity_ua *(stage+depth) 8026 7987 8027 depth_ref = zeros((len(permutation), time_step_count),Float)7988 depth_ref = num.zeros((len(permutation), time_step_count), num.Float) 8028 7989 for i in range(len(permutation)): 8029 7990 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 8032 7993 # The xmomentum stored in the .sts file should be the sum of the ua 8033 7994 # in the two mux2 files multiplied by the depth. 8034 assert allclose(transpose(ua_ref*depth_ref), xmomentum1)7995 assert num.allclose(num.transpose(ua_ref*depth_ref), xmomentum1) 8035 7996 8036 7997 #Check the momentums - va … … 8045 8006 #print transpose(va_ref*depth_ref) 8046 8007 #print ymomentum 8047 assert allclose(transpose(va_ref*depth_ref), ymomentum1)8008 assert num.allclose(num.transpose(va_ref*depth_ref), ymomentum1) 8048 8009 8049 8010 # check the elevation values. 8050 8011 # -ve since urs measures depth, sww meshers height, 8051 assert allclose(-gauge_depth_ref, elevation1)8012 assert num.allclose(-gauge_depth_ref, elevation1) 8052 8013 8053 8014 fid.close() … … 8091 8052 8092 8053 #print i, [x[i],y[i]], [e,n] 8093 assert allclose([x[i],y[i]], [e,n])8054 assert num.allclose([x[i],y[i]], [e,n]) 8094 8055 8095 8056 8096 8057 # Check the time vector 8097 8058 times = fid.variables['time'][:] 8098 assert allclose(ensure_numeric(times),8099 ensure_numeric(times_ref))8059 assert num.allclose(ensure_numeric(times), 8060 ensure_numeric(times_ref)) 8100 8061 8101 8062 … … 8113 8074 # quantities written to the mux2 files subject to the permutation vector. 8114 8075 8115 ha_ref = weights[0]* take(ha0, permutation) + weights[1]*take(ha1, permutation)8116 ua_ref = weights[0]* take(ua0, permutation) + weights[1]*take(ua1, permutation)8117 va_ref = weights[0]* take(va0, permutation) + weights[1]*take(va1, permutation)8118 8119 gauge_depth_ref = take(gauge_depth, permutation)8076 ha_ref = weights[0]*num.take(ha0, permutation) + weights[1]*num.take(ha1, permutation) 8077 ua_ref = weights[0]*num.take(ua0, permutation) + weights[1]*num.take(ua1, permutation) 8078 va_ref = weights[0]*num.take(va0, permutation) + weights[1]*num.take(va1, permutation) 8079 8080 gauge_depth_ref = num.take(gauge_depth, permutation) 8120 8081 8121 8082 … … 8124 8085 #print transpose(ha_ref)+tide - stage 8125 8086 8126 assert allclose(transpose(ha_ref)+tide, stage) # Meters8087 assert num.allclose(num.transpose(ha_ref)+tide, stage) # Meters 8127 8088 8128 8089 #Check the momentums - ua … … 8131 8092 #momentum = velocity_ua *(stage+depth) 8132 8093 8133 depth_ref = zeros((len(permutation), time_step_count),Float)8094 depth_ref = num.zeros((len(permutation), time_step_count), num.Float) 8134 8095 for i in range(len(permutation)): 8135 8096 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 8140 8101 # The xmomentum stored in the .sts file should be the sum of the ua 8141 8102 # in the two mux2 files multiplied by the depth. 8142 assert allclose(transpose(ua_ref*depth_ref), xmomentum)8103 assert num.allclose(num.transpose(ua_ref*depth_ref), xmomentum) 8143 8104 8144 8105 #Check the momentums - va … … 8154 8115 #print ymomentum 8155 8116 8156 assert allclose(transpose(va_ref*depth_ref), ymomentum)8117 assert num.allclose(num.transpose(va_ref*depth_ref), ymomentum) 8157 8118 8158 8119 # check the elevation values. 8159 8120 # -ve since urs measures depth, sww meshers height, 8160 assert allclose(-gauge_depth_ref, elevation) #Meters8121 assert num.allclose(-gauge_depth_ref, elevation) #Meters 8161 8122 8162 8123 fid.close() … … 8173 8134 8174 8135 stage_man = weights[0]*(stage0-tide) + weights[1]*(stage1-tide) + tide 8175 assert allclose(stage_man, stage)8136 assert num.allclose(stage_man, stage) 8176 8137 8177 8138 … … 8200 8161 lat_long_points =bounding_polygon[0:3] 8201 8162 n=len(lat_long_points) 8202 first_tstep= ones(n,Int)8203 last_tstep=(time_step_count)* ones(n,Int)8163 first_tstep=num.ones(n,num.Int) 8164 last_tstep=(time_step_count)*num.ones(n,num.Int) 8204 8165 8205 8166 h = 20 … … 8207 8168 u = 10 8208 8169 v = -10 8209 gauge_depth=h* ones(n,Float)8210 ha=w* ones((n,time_step_count),Float)8211 ua=u* ones((n,time_step_count),Float)8212 va=v* ones((n,time_step_count),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) 8213 8174 base_name, files = self.write_mux2(lat_long_points, 8214 8175 time_step_count, time_step, … … 8257 8218 qd = Bd.evaluate(vol_id, edge_id) # Dirichlet boundary 8258 8219 8259 assert allclose(qf, qd)8220 assert num.allclose(qf, qd) 8260 8221 8261 8222 … … 8263 8224 finaltime=time_step*(time_step_count-1) 8264 8225 yieldstep=time_step 8265 temp_fbound= zeros(int(finaltime/yieldstep)+1,Float)8226 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8266 8227 8267 8228 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8280 8241 if isinstance(B, File_boundary): 8281 8242 #print j, val 8282 assert allclose(val, w + tide)8243 assert num.allclose(val, w + tide) 8283 8244 8284 8245 … … 8295 8256 8296 8257 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8297 temp_drchlt= zeros(int(finaltime/yieldstep)+1,Float)8258 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8298 8259 8299 8260 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8305 8266 #print domain_drchlt.quantities['stage'].vertex_values 8306 8267 8307 assert allclose(temp_fbound,temp_drchlt)8308 8309 assert allclose(domain_fbound.quantities['stage'].vertex_values,8310 domain_drchlt.quantities['stage'].vertex_values)8268 assert num.allclose(temp_fbound,temp_drchlt) 8269 8270 assert num.allclose(domain_fbound.quantities['stage'].vertex_values, 8271 domain_drchlt.quantities['stage'].vertex_values) 8311 8272 8312 assert allclose(domain_fbound.quantities['xmomentum'].vertex_values,8313 domain_drchlt.quantities['xmomentum'].vertex_values)8273 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 8274 domain_drchlt.quantities['xmomentum'].vertex_values) 8314 8275 8315 assert allclose(domain_fbound.quantities['ymomentum'].vertex_values,8316 domain_drchlt.quantities['ymomentum'].vertex_values)8276 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 8277 domain_drchlt.quantities['ymomentum'].vertex_values) 8317 8278 8318 8279 … … 8350 8311 lat_long_points = bounding_polygon[0:3] 8351 8312 n=len(lat_long_points) 8352 first_tstep= ones(n,Int)8353 last_tstep=(time_step_count)* ones(n,Int)8313 first_tstep=num.ones(n,num.Int) 8314 last_tstep=(time_step_count)*num.ones(n,num.Int) 8354 8315 8355 8316 h = 20 … … 8357 8318 u = 10 8358 8319 v = -10 8359 gauge_depth=h* ones(n,Float)8360 ha=w* ones((n,time_step_count),Float)8361 ua=u* ones((n,time_step_count),Float)8362 va=v* ones((n,time_step_count),Float)8320 gauge_depth=h*num.ones(n,num.Float) 8321 ha=w*num.ones((n,time_step_count),num.Float) 8322 ua=u*num.ones((n,time_step_count),num.Float) 8323 va=v*num.ones((n,time_step_count),num.Float) 8363 8324 base_name, files = self.write_mux2(lat_long_points, 8364 8325 time_step_count, time_step, … … 8415 8376 qd = Bd.evaluate(vol_id, edge_id) # Dirichlet boundary 8416 8377 8417 assert allclose(qf, qd)8378 assert num.allclose(qf, qd) 8418 8379 8419 8380 … … 8422 8383 finaltime = data_finaltime + 10 # Let model time exceed available data 8423 8384 yieldstep = time_step 8424 temp_fbound= zeros(int(finaltime/yieldstep)+1,Float)8385 temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.Float) 8425 8386 8426 8387 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8439 8400 if isinstance(B, File_boundary): 8440 8401 #print j, val 8441 assert allclose(val, w + tide)8402 assert num.allclose(val, w + tide) 8442 8403 8443 8404 … … 8454 8415 8455 8416 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8456 temp_drchlt= zeros(int(finaltime/yieldstep)+1,Float)8417 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8457 8418 8458 8419 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8464 8425 #print domain_drchlt.quantities['stage'].vertex_values 8465 8426 8466 assert allclose(temp_fbound,temp_drchlt)8467 8468 assert allclose(domain_fbound.quantities['stage'].vertex_values,8469 domain_drchlt.quantities['stage'].vertex_values)8427 assert num.allclose(temp_fbound,temp_drchlt) 8428 8429 assert num.allclose(domain_fbound.quantities['stage'].vertex_values, 8430 domain_drchlt.quantities['stage'].vertex_values) 8470 8431 8471 assert allclose(domain_fbound.quantities['xmomentum'].vertex_values,8472 domain_drchlt.quantities['xmomentum'].vertex_values)8432 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 8433 domain_drchlt.quantities['xmomentum'].vertex_values) 8473 8434 8474 assert allclose(domain_fbound.quantities['ymomentum'].vertex_values,8475 domain_drchlt.quantities['ymomentum'].vertex_values)8435 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 8436 domain_drchlt.quantities['ymomentum'].vertex_values) 8476 8437 8477 8438 … … 8508 8469 lat_long_points = bounding_polygon[0:3] 8509 8470 n=len(lat_long_points) 8510 first_tstep= ones(n,Int)8511 last_tstep=(time_step_count)* ones(n,Int)8471 first_tstep=num.ones(n,num.Int) 8472 last_tstep=(time_step_count)*num.ones(n,num.Int) 8512 8473 8513 8474 h = 20 … … 8515 8476 u = 10 8516 8477 v = -10 8517 gauge_depth=h* ones(n,Float)8518 ha=w* ones((n,time_step_count),Float)8519 ua=u* ones((n,time_step_count),Float)8520 va=v* ones((n,time_step_count),Float)8478 gauge_depth=h*num.ones(n,num.Float) 8479 ha=w*num.ones((n,time_step_count),num.Float) 8480 ua=u*num.ones((n,time_step_count),num.Float) 8481 va=v*num.ones((n,time_step_count),num.Float) 8521 8482 base_name, files = self.write_mux2(lat_long_points, 8522 8483 time_step_count, time_step, … … 8577 8538 8578 8539 msg = 'Got %s, should have been %s' %(qf, qd) 8579 assert allclose(qf, qd), msg8540 assert num.allclose(qf, qd), msg 8580 8541 8581 8542 # Evolve … … 8583 8544 finaltime = data_finaltime + 10 # Let model time exceed available data 8584 8545 yieldstep = time_step 8585 temp_fbound= zeros(int(finaltime/yieldstep)+1,Float)8546 temp_fbound=num.zeros(int(finaltime/yieldstep)+1, num.Float) 8586 8547 8587 8548 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8600 8561 if isinstance(B, Field_boundary): 8601 8562 msg = 'Got %f should have been %f' %(val, w+tide) 8602 assert allclose(val, w + tide), msg8563 assert num.allclose(val, w + tide), msg 8603 8564 8604 8565 … … 8627 8588 lat_long_points.insert(0,[6.0,97.01]) 8628 8589 n=len(lat_long_points) 8629 first_tstep= ones(n,Int)8630 last_tstep=(time_step_count)* ones(n,Int)8631 gauge_depth=20* ones(n,Float)8632 ha=2* ones((n,time_step_count),Float)8633 ua=10* ones((n,time_step_count),Float)8634 va=-10* ones((n,time_step_count),Float)8590 first_tstep=num.ones(n,num.Int) 8591 last_tstep=(time_step_count)*num.ones(n,num.Int) 8592 gauge_depth=20*num.ones(n,num.Float) 8593 ha=2*num.ones((n,time_step_count),num.Float) 8594 ua=10*num.ones((n,time_step_count),num.Float) 8595 va=-10*num.ones((n,time_step_count),num.Float) 8635 8596 base_name, files = self.write_mux2(lat_long_points, 8636 8597 time_step_count, … … 8674 8635 finaltime=time_step*(time_step_count-1) 8675 8636 yieldstep=time_step 8676 temp_fbound= zeros(int(finaltime/yieldstep)+1,Float)8637 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8677 8638 8678 8639 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8686 8647 Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) 8687 8648 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8688 temp_drchlt= zeros(int(finaltime/yieldstep)+1,Float)8649 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8689 8650 8690 8651 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8694 8655 8695 8656 8696 assert allclose(temp_fbound,temp_drchlt)8657 assert num.allclose(temp_fbound,temp_drchlt) 8697 8658 8698 8659 #print domain_fbound.quantities['stage'].vertex_values … … 8700 8661 8701 8662 8702 assert allclose(domain_fbound.quantities['stage'].vertex_values,8703 domain_drchlt.quantities['stage'].vertex_values)8663 assert num.allclose(domain_fbound.quantities['stage'].vertex_values, 8664 domain_drchlt.quantities['stage'].vertex_values) 8704 8665 8705 assert allclose(domain_fbound.quantities['xmomentum'].vertex_values,8706 domain_drchlt.quantities['xmomentum'].vertex_values)8666 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 8667 domain_drchlt.quantities['xmomentum'].vertex_values) 8707 8668 8708 assert allclose(domain_fbound.quantities['ymomentum'].vertex_values,8709 domain_drchlt.quantities['ymomentum'].vertex_values)8669 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 8670 domain_drchlt.quantities['ymomentum'].vertex_values) 8710 8671 8711 8672 … … 8733 8694 time_step = 2 8734 8695 n=len(lat_long_points) 8735 first_tstep= ones(n,Int)8736 last_tstep=(time_step_count)* ones(n,Int)8737 gauge_depth=20* ones(n,Float)8738 ha=2* ones((n,time_step_count),Float)8739 ua=10* ones((n,time_step_count),Float)8740 va=-10* ones((n,time_step_count),Float)8696 first_tstep=num.ones(n,num.Int) 8697 last_tstep=(time_step_count)*num.ones(n,num.Int) 8698 gauge_depth=20*num.ones(n,num.Float) 8699 ha=2*num.ones((n,time_step_count),num.Float) 8700 ua=10*num.ones((n,time_step_count),num.Float) 8701 va=-10*num.ones((n,time_step_count),num.Float) 8741 8702 base_name, files = self.write_mux2(lat_long_points, 8742 8703 time_step_count, … … 8800 8761 show() 8801 8762 8802 assert allclose(bounding_polygon_utm,boundary_polygon)8763 assert num.allclose(bounding_polygon_utm,boundary_polygon) 8803 8764 8804 8765 … … 8824 8785 finaltime=time_step*(time_step_count-1) 8825 8786 yieldstep=time_step 8826 temp_fbound= zeros(int(finaltime/yieldstep)+1,Float)8787 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8827 8788 8828 8789 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8837 8798 Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) 8838 8799 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8839 temp_drchlt= zeros(int(finaltime/yieldstep)+1,Float)8800 temp_drchlt=num.zeros(int(finaltime/yieldstep)+1,num.Float) 8840 8801 8841 8802 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8848 8809 #print domain_drchlt.quantities['stage'].vertex_values 8849 8810 8850 assert allclose(temp_fbound,temp_drchlt)8851 8852 8853 assert allclose(domain_fbound.quantities['stage'].vertex_values,8854 domain_drchlt.quantities['stage'].vertex_values)8811 assert num.allclose(temp_fbound,temp_drchlt) 8812 8813 8814 assert num.allclose(domain_fbound.quantities['stage'].vertex_values, 8815 domain_drchlt.quantities['stage'].vertex_values) 8855 8816 8856 assert allclose(domain_fbound.quantities['xmomentum'].vertex_values,8857 domain_drchlt.quantities['xmomentum'].vertex_values)8817 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 8818 domain_drchlt.quantities['xmomentum'].vertex_values) 8858 8819 8859 assert allclose(domain_fbound.quantities['ymomentum'].vertex_values,8860 domain_drchlt.quantities['ymomentum'].vertex_values)8820 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 8821 domain_drchlt.quantities['ymomentum'].vertex_values) 8861 8822 8862 8823 # Use known Dirichlet condition (if sufficient timesteps have been taken) … … 8892 8853 from anuga.pmesh.mesh_interface import create_mesh_from_regions 8893 8854 8894 from Numeric import sin, cos8895 8896 8855 lat_long_points=[[6.01,97.0],[6.02,97.0],[6.05,96.9],[6.0,97.0]] 8897 8856 bounding_polygon=[[6.0,97.0],[6.01,97.0],[6.02,97.0],[6.02,97.02],[6.00,97.02]] … … 8899 8858 time_step_count = 50 8900 8859 time_step = 0.1 8901 times_ref = arange(0, time_step_count*time_step, time_step)8860 times_ref = num.arange(0, time_step_count*time_step, time_step) 8902 8861 8903 8862 n=len(lat_long_points) 8904 first_tstep= ones(n,Int)8905 last_tstep=(time_step_count)* ones(n,Int)8906 8907 gauge_depth=20* ones(n,Float)8908 8909 ha1= ones((n,time_step_count),Float)8910 ua1=3.* ones((n,time_step_count),Float)8911 va1=2.* ones((n,time_step_count),Float)8863 first_tstep=num.ones(n,num.Int) 8864 last_tstep=(time_step_count)*num.ones(n,num.Int) 8865 8866 gauge_depth=20*num.ones(n,num.Float) 8867 8868 ha1=num.ones((n,time_step_count),num.Float) 8869 ua1=3.*num.ones((n,time_step_count),num.Float) 8870 va1=2.*num.ones((n,time_step_count),num.Float) 8912 8871 for i in range(n): 8913 ha1[i]= sin(times_ref)8872 ha1[i]=num.sin(times_ref) 8914 8873 8915 8874 … … 8997 8956 show() 8998 8957 8999 assert allclose(bounding_polygon_utm,boundary_polygon)8958 assert num.allclose(bounding_polygon_utm,boundary_polygon) 9000 8959 9001 8960 … … 9024 8983 finaltime=time_step*(time_step_count-1) 9025 8984 yieldstep=time_step 9026 temp_fbound= zeros(int(finaltime/yieldstep)+1,Float)8985 temp_fbound=num.zeros(int(finaltime/yieldstep)+1,num.Float) 9027 8986 9028 8987 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 9036 8995 Br = Reflective_boundary(domain_time) 9037 8996 Bw=Time_boundary(domain=domain_time, 9038 f=lambda t: [ sin(t)+tide,3.*(20.+sin(t)+tide),2.*(20.+sin(t)+tide)])8997 f=lambda t: [num.sin(t)+tide,3.*(20.+num.sin(t)+tide),2.*(20.+num.sin(t)+tide)]) 9039 8998 domain_time.set_boundary({'ocean': Bw,'otherocean': Br}) 9040 8999 9041 temp_time= zeros(int(finaltime/yieldstep)+1,Float)9000 temp_time=num.zeros(int(finaltime/yieldstep)+1,num.Float) 9042 9001 for i, t in enumerate(domain_time.evolve(yieldstep=yieldstep, 9043 9002 finaltime=finaltime, … … 9053 9012 #print domain_time.quantities['stage'].vertex_values 9054 9013 9055 assert allclose(temp_fbound, temp_time)9056 assert allclose(domain_fbound.quantities['stage'].vertex_values,9057 domain_time.quantities['stage'].vertex_values)9014 assert num.allclose(temp_fbound, temp_time) 9015 assert num.allclose(domain_fbound.quantities['stage'].vertex_values, 9016 domain_time.quantities['stage'].vertex_values) 9058 9017 9059 assert allclose(domain_fbound.quantities['xmomentum'].vertex_values,9060 domain_time.quantities['xmomentum'].vertex_values)9018 assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values, 9019 domain_time.quantities['xmomentum'].vertex_values) 9061 9020 9062 assert allclose(domain_fbound.quantities['ymomentum'].vertex_values,9063 domain_time.quantities['ymomentum'].vertex_values)9021 assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values, 9022 domain_time.quantities['ymomentum'].vertex_values) 9064 9023 9065 9024 … … 9186 9145 found = False 9187 9146 for result in results: 9188 if allclose(point, result):9147 if num.allclose(point, result): 9189 9148 found = True 9190 9149 break … … 9278 9237 found = False 9279 9238 for result in results: 9280 if allclose(point, result):9239 if num.allclose(point, result): 9281 9240 found = True 9282 9241 break … … 9354 9313 for lat_lon, dep in map(None, lat_long_points, urs.lonlatdep): 9355 9314 _ , e, n = redfearn(lat_lon[0], lat_lon[1]) 9356 assert allclose(n, dep[2])9315 assert num.allclose(n, dep[2]) 9357 9316 9358 9317 count = 0 … … 9367 9326 if file[-5:] == WAVEHEIGHT_MUX_LABEL[-5:] or \ 9368 9327 file[-5:] == NORTH_VELOCITY_LABEL[-5:] : 9369 assert allclose(e, quantity)9328 assert num.allclose(e, quantity) 9370 9329 if file[-5:] == EAST_VELOCITY_LABEL[-5:]: 9371 assert allclose(n, quantity)9330 assert num.allclose(n, quantity) 9372 9331 assert count == time_step_count 9373 9332 … … 9407 9366 #Work out the UTM coordinates for first point 9408 9367 zone, e, n = redfearn(lat_long[0][0], lat_long[0][1]) 9409 assert allclose([x[0],y[0]], [e,n])9368 assert num.allclose([x[0],y[0]], [e,n]) 9410 9369 9411 9370 #Check the time vector … … 9416 9375 times_actual.append(time_step * i) 9417 9376 9418 assert allclose(ensure_numeric(times),9419 ensure_numeric(times_actual))9377 assert num.allclose(ensure_numeric(times), 9378 ensure_numeric(times_actual)) 9420 9379 9421 9380 #Check first value … … 9424 9383 ymomentum = fid.variables['ymomentum'][:] 9425 9384 elevation = fid.variables['elevation'][:] 9426 assert allclose(stage[0,0], e +tide) #Meters9385 assert num.allclose(stage[0,0], e +tide) #Meters 9427 9386 9428 9387 … … 9437 9396 #print "answer_x",answer_x 9438 9397 #print "actual_x",actual_x 9439 assert allclose(answer_x, actual_x) #Meters9398 assert num.allclose(answer_x, actual_x) #Meters 9440 9399 9441 9400 #Check the momentums - va … … 9449 9408 #print "answer_y",answer_y 9450 9409 #print "actual_y",actual_y 9451 assert allclose(answer_y, actual_y) #Meters9410 assert num.allclose(answer_y, actual_y) #Meters 9452 9411 9453 9412 # check the stage values, first time step. 9454 9413 # These arrays are equal since the Easting values were used as 9455 9414 # the stage 9456 assert allclose(stage[0], x +tide) #Meters9415 assert num.allclose(stage[0], x +tide) #Meters 9457 9416 # check the elevation values. 9458 9417 # -ve since urs measures depth, sww meshers height, 9459 9418 # these arrays are equal since the northing values were used as 9460 9419 # the elevation 9461 assert allclose(-elevation, y) #Meters9420 assert num.allclose(-elevation, y) #Meters 9462 9421 9463 9422 fid.close() … … 9499 9458 #Work out the UTM coordinates for first point 9500 9459 zone, e, n = redfearn(lat_long[0][0], lat_long[0][1]) 9501 assert allclose([x[0],y[0]], [e,n])9460 assert num.allclose([x[0],y[0]], [e,n]) 9502 9461 9503 9462 #Check the time vector … … 9508 9467 times_actual.append(time_step * i) 9509 9468 9510 assert allclose(ensure_numeric(times),9511 ensure_numeric(times_actual))9469 assert num.allclose(ensure_numeric(times), 9470 ensure_numeric(times_actual)) 9512 9471 9513 9472 #Check first value … … 9516 9475 ymomentum = fid.variables['ymomentum'][:] 9517 9476 elevation = fid.variables['elevation'][:] 9518 assert allclose(stage[0,0], e +tide) #Meters9477 assert num.allclose(stage[0,0], e +tide) #Meters 9519 9478 9520 9479 #Check the momentums - ua … … 9528 9487 #print "answer_x",answer_x 9529 9488 #print "actual_x",actual_x 9530 assert allclose(answer_x, actual_x) #Meters9489 assert num.allclose(answer_x, actual_x) #Meters 9531 9490 9532 9491 #Check the momentums - va … … 9540 9499 #print "answer_y",answer_y 9541 9500 #print "actual_y",actual_y 9542 assert allclose(answer_y, actual_y) #Meters9501 assert num.allclose(answer_y, actual_y) #Meters 9543 9502 9544 9503 # check the stage values, first time step. 9545 9504 # These arrays are equal since the Easting values were used as 9546 9505 # the stage 9547 assert allclose(stage[0], x +tide) #Meters9506 assert num.allclose(stage[0], x +tide) #Meters 9548 9507 # check the elevation values. 9549 9508 # -ve since urs measures depth, sww meshers height, 9550 9509 # these arrays are equal since the northing values were used as 9551 9510 # the elevation 9552 assert allclose(-elevation, y) #Meters9511 assert num.allclose(-elevation, y) #Meters 9553 9512 9554 9513 fid.close() … … 9589 9548 #Work out the UTM coordinates for first point 9590 9549 zone, e, n = redfearn(lat_long[0][0], lat_long[0][1]) 9591 assert allclose([x[0],y[0]], [e,n])9550 assert num.allclose([x[0],y[0]], [e,n]) 9592 9551 9593 9552 #Check the time vector … … 9598 9557 times_actual.append(time_step * i) 9599 9558 9600 assert allclose(ensure_numeric(times),9601 ensure_numeric(times_actual))9559 assert num.allclose(ensure_numeric(times), 9560 ensure_numeric(times_actual)) 9602 9561 9603 9562 #Check first value … … 9606 9565 ymomentum = fid.variables['ymomentum'][:] 9607 9566 elevation = fid.variables['elevation'][:] 9608 assert allclose(stage[0,0], e +tide) #Meters9567 assert num.allclose(stage[0,0], e +tide) #Meters 9609 9568 9610 9569 #Check the momentums - ua … … 9618 9577 #print "answer_x",answer_x 9619 9578 #print "actual_x",actual_x 9620 assert allclose(answer_x, actual_x) #Meters9579 assert num.allclose(answer_x, actual_x) #Meters 9621 9580 9622 9581 #Check the momentums - va … … 9630 9589 #print "answer_y",answer_y 9631 9590 #print "actual_y",actual_y 9632 assert allclose(answer_y, actual_y) #Meters9591 assert num.allclose(answer_y, actual_y) #Meters 9633 9592 9634 9593 # check the stage values, first time step. 9635 9594 # These arrays are equal since the Easting values were used as 9636 9595 # the stage 9637 assert allclose(stage[0], x +tide) #Meters9596 assert num.allclose(stage[0], x +tide) #Meters 9638 9597 # check the elevation values. 9639 9598 # -ve since urs measures depth, sww meshers height, 9640 9599 # these arrays are equal since the northing values were used as 9641 9600 # the elevation 9642 assert allclose(-elevation, y) #Meters9601 assert num.allclose(-elevation, y) #Meters 9643 9602 9644 9603 fid.close() … … 9692 9651 number_of_volumes = fid.variables['volumes'] 9693 9652 #print "number_of_volumes",len(number_of_volumes) 9694 assert allclose(16, len(number_of_volumes))9653 assert num.allclose(16, len(number_of_volumes)) 9695 9654 9696 9655 fid.close() … … 9745 9704 volumes_again = fid.variables['volumes'] 9746 9705 #print "number_of_volumes",len(volumes_again) 9747 assert allclose(len(volumes_again),9748 len(volumes))9706 assert num.allclose(len(volumes_again), 9707 len(volumes)) 9749 9708 fid.close() 9750 9709 os.remove(sww_file) … … 9785 9744 #Work out the UTM coordinates for first point 9786 9745 zone, e, n = redfearn(lat_long[0][0], lat_long[0][1]) 9787 assert allclose([x[0],y[0]], [e,n])9746 assert num.allclose([x[0],y[0]], [e,n]) 9788 9747 9789 9748 #Check the time vector … … 9792 9751 times_actual = [0,100,200,300] 9793 9752 9794 assert allclose(ensure_numeric(times),9795 ensure_numeric(times_actual))9753 assert num.allclose(ensure_numeric(times), 9754 ensure_numeric(times_actual)) 9796 9755 9797 9756 #Check first value … … 9800 9759 ymomentum = fid.variables['ymomentum'][:] 9801 9760 elevation = fid.variables['elevation'][:] 9802 assert allclose(stage[0,0], e +tide) #Meters9761 assert num.allclose(stage[0,0], e +tide) #Meters 9803 9762 9804 9763 #Check the momentums - ua … … 9812 9771 #print "answer_x",answer_x 9813 9772 #print "actual_x",actual_x 9814 assert allclose(answer_x, actual_x) #Meters9773 assert num.allclose(answer_x, actual_x) #Meters 9815 9774 9816 9775 #Check the momentums - va … … 9824 9783 #print "answer_y",answer_y 9825 9784 #print "actual_y",actual_y 9826 assert allclose(answer_y, actual_y) #Meters9785 assert num.allclose(answer_y, actual_y) #Meters 9827 9786 9828 9787 # check the stage values, first time step. 9829 9788 # These arrays are equal since the Easting values were used as 9830 9789 # the stage 9831 assert allclose(stage[0], x +tide) #Meters9790 assert num.allclose(stage[0], x +tide) #Meters 9832 9791 # check the elevation values. 9833 9792 # -ve since urs measures depth, sww meshers height, 9834 9793 # these arrays are equal since the northing values were used as 9835 9794 # the elevation 9836 assert allclose(-elevation, y) #Meters9795 assert num.allclose(-elevation, y) #Meters 9837 9796 9838 9797 fid.close() … … 9873 9832 9874 9833 times_actual = [0,100,200,300,400,500] 9875 assert allclose(ensure_numeric(times),9876 ensure_numeric(times_actual))9834 assert num.allclose(ensure_numeric(times), 9835 ensure_numeric(times_actual)) 9877 9836 9878 9837 #Check first value 9879 9838 stage = fid.variables['stage'][:] 9880 assert allclose(stage[0], x +tide)9839 assert num.allclose(stage[0], x +tide) 9881 9840 9882 9841 fid.close() … … 10008 9967 filename = tempfile.mktemp("_data_manager.sww") 10009 9968 outfile = NetCDFFile(filename, netcdf_mode_w) 10010 points_utm = array([[0.,0.],[1.,1.], [0.,1.]])9969 points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]]) 10011 9970 volumes = (0,1,2) 10012 9971 elevation = [0,1,2] … … 10019 9978 sww.store_header(outfile, times, number_of_volumes, 10020 9979 number_of_points, description='fully sick testing', 10021 verbose=self.verbose,sww_precision= Float)9980 verbose=self.verbose,sww_precision=num.Float) 10022 9981 sww.store_triangulation(outfile, points_utm, volumes, 10023 9982 elevation, new_origin=new_origin, … … 10030 9989 fid.close() 10031 9990 10032 assert allclose(array(map(None, x,y)), points_utm)9991 assert num.allclose(num.array(map(None, x,y)), points_utm) 10033 9992 os.remove(filename) 10034 9993 … … 10040 9999 filename = tempfile.mktemp("_data_manager.sww") 10041 10000 outfile = NetCDFFile(filename, netcdf_mode_w) 10042 points_utm = array([[0.,0.],[1.,1.], [0.,1.]])10001 points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]]) 10043 10002 volumes = (0,1,2) 10044 10003 elevation = [0,1,2] … … 10051 10010 sww.store_header(outfile, times, number_of_volumes, 10052 10011 number_of_points, description='fully sick testing', 10053 verbose=self.verbose,sww_precision= Float)10012 verbose=self.verbose,sww_precision=num.Float) 10054 10013 sww.store_triangulation(outfile, points_utm, volumes, 10055 10014 elevation, new_origin=new_origin, … … 10065 10024 fid.close() 10066 10025 10067 assert allclose(array(map(None, x,y)), points_utm)10026 assert num.allclose(num.array(map(None, x,y)), points_utm) 10068 10027 os.remove(filename) 10069 10028 … … 10075 10034 filename = tempfile.mktemp("_data_manager.sww") 10076 10035 outfile = NetCDFFile(filename, netcdf_mode_w) 10077 points_utm = array([[0.,0.],[1.,1.], [0.,1.]])10036 points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]]) 10078 10037 volumes = (0,1,2) 10079 10038 elevation = [0,1,2] … … 10087 10046 sww.store_header(outfile, times, number_of_volumes, 10088 10047 number_of_points, description='fully sick testing', 10089 verbose=self.verbose,sww_precision= Float)10048 verbose=self.verbose,sww_precision=num.Float) 10090 10049 sww.store_triangulation(outfile, points_utm, volumes, 10091 10050 elevation, new_origin=new_origin, … … 10102 10061 10103 10062 absolute = Geo_reference(56, 0,0) 10104 assert allclose(array( \10063 assert num.allclose(num.array( 10105 10064 absolute.change_points_geo_ref(map(None, x,y), 10106 10065 new_origin)),points_utm) … … 10114 10073 filename = tempfile.mktemp("_data_manager.sww") 10115 10074 outfile = NetCDFFile(filename, netcdf_mode_w) 10116 points_utm = array([[0.,0.],[1.,1.], [0.,1.]])10075 points_utm = num.array([[0.,0.],[1.,1.], [0.,1.]]) 10117 10076 volumes = (0,1,2) 10118 10077 elevation = [0,1,2] … … 10126 10085 sww.store_header(outfile, times, number_of_volumes, 10127 10086 number_of_points, description='fully sick testing', 10128 verbose=self.verbose,sww_precision= Float)