Changeset 5951 for anuga_core/source_numpy_conversion/anuga/shallow_water
- Timestamp:
- Nov 12, 2008, 3:16:51 PM (16 years ago)
- Location:
- anuga_core/source_numpy_conversion/anuga/shallow_water
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/shallow_water/data_manager.py
r5947 r5951 602 602 from Scientific.IO.NetCDF import NetCDFFile 603 603 604 self.precision = numpy.float #Use full precision604 self.precision = Float #Use full precision 605 605 606 606 Data_format.__init__(self, domain, 'sww', mode) … … 1080 1080 1081 1081 M = size #Number of lines 1082 xx = numpy.zeros((M,3), numpy.float)1083 yy = numpy.zeros((M,3), numpy.float)1084 zz = numpy.zeros((M,3), numpy.float)1082 xx = numpy.zeros((M,3), Float) 1083 yy = numpy.zeros((M,3), Float) 1084 zz = numpy.zeros((M,3), Float) 1085 1085 1086 1086 for i in range(M): … … 1126 1126 1127 1127 M = len(lines) #Number of lines 1128 x = numpy.zeros((M,3), numpy.float)1129 y = numpy.zeros((M,3), numpy.float)1130 z = numpy.zeros((M,3), numpy.float)1128 x = numpy.zeros((M,3), Float) 1129 y = numpy.zeros((M,3), Float) 1130 z = numpy.zeros((M,3), Float) 1131 1131 1132 1132 ##i = 0 … … 1443 1443 newcols = lenv # ncols_in_bounding_box 1444 1444 1445 telev = numpy.zeros(newcols, numpy.float)1446 tpoints = numpy.zeros((newcols, 2), numpy.float)1445 telev = numpy.zeros(newcols, Float) 1446 tpoints = numpy.zeros((newcols, 2), Float) 1447 1447 1448 1448 local_index = 0 … … 1993 1993 #the temporal dimension 1994 1994 if verbose: print 'Reducing quantity %s' %quantity 1995 q_reduced = numpy.zeros( number_of_points, numpy.float )1995 q_reduced = numpy.zeros( number_of_points, Float ) 1996 1996 1997 1997 if timestep is not None: … … 2059 2059 assert len(vertex_points.shape) == 2 2060 2060 2061 grid_points = numpy.zeros ( (ncols*nrows, 2), numpy.float )2061 grid_points = numpy.zeros ( (ncols*nrows, 2), Float ) 2062 2062 2063 2063 … … 2358 2358 # the temporal dimension 2359 2359 if verbose: print 'Reducing quantity %s' %quantity 2360 q_reduced = numpy.zeros( number_of_points, numpy.float )2360 q_reduced = numpy.zeros( number_of_points, Float ) 2361 2361 2362 2362 for k in range(number_of_points): … … 2667 2667 from Scientific.IO.NetCDF import NetCDFFile 2668 2668 2669 precision = numpy.float2669 precision = Float 2670 2670 2671 2671 msg = 'Must use latitudes and longitudes for minlat, maxlon etc' … … 2821 2821 #Cleanup 2822 2822 missing = (amplitudes == nan_ha) 2823 if sometrue(missing):2823 if numpy.sometrue(missing): 2824 2824 if fail_on_NaN: 2825 2825 msg = 'NetCDFFile %s contains missing values'\ … … 2925 2925 sww.store_header(outfile, times, number_of_volumes, 2926 2926 number_of_points, description=description, 2927 verbose=verbose,sww_precision= numpy.float)2927 verbose=verbose,sww_precision=Float) 2928 2928 2929 2929 # Store 2930 2930 from anuga.coordinate_transforms.redfearn import redfearn 2931 x = numpy.zeros(number_of_points, numpy.float) #Easting2932 y = numpy.zeros(number_of_points, numpy.float) #Northing2931 x = numpy.zeros(number_of_points, Float) #Easting 2932 y = numpy.zeros(number_of_points, Float) #Northing 2933 2933 2934 2934 … … 2987 2987 outfile.variables['z'][:] = z #FIXME HACK for bacwards compat. 2988 2988 outfile.variables['elevation'][:] = z 2989 outfile.variables['volumes'][:] = volumes.astype( numpy.int32) #For Opteron 642989 outfile.variables['volumes'][:] = volumes.astype(Int) #For Opteron 64 2990 2990 2991 2991 … … 3123 3123 d = len(q) 3124 3124 3125 T = numpy.zeros(N, numpy.float) #Time3126 Q = numpy.zeros((N, d), numpy.float) #Values3125 T = numpy.zeros(N, Float) #Time 3126 Q = numpy.zeros((N, d), Float) #Values 3127 3127 3128 3128 for i, line in enumerate(lines): … … 3570 3570 if verbose: print 'Processing row %d of %d' %(i, nrows_new) 3571 3571 lower_index = global_index 3572 telev = numpy.zeros(ncols_new, numpy.float)3572 telev = numpy.zeros(ncols_new, Float) 3573 3573 local_index = 0 3574 3574 trow = i * cellsize_ratio … … 3668 3668 from anuga.coordinate_transforms.redfearn import redfearn 3669 3669 3670 precision = numpy.float # So if we want to change the precision its done here3670 precision = Float # So if we want to change the precision its done here 3671 3671 3672 3672 # go in to the bath dir and load the only file, … … 3795 3795 #Store 3796 3796 from anuga.coordinate_transforms.redfearn import redfearn 3797 x = numpy.zeros(number_of_points, numpy.float) #Easting3798 y = numpy.zeros(number_of_points, numpy.float) #Northing3797 x = numpy.zeros(number_of_points, Float) #Easting 3798 y = numpy.zeros(number_of_points, Float) #Northing 3799 3799 3800 3800 if verbose: print 'Making triangular grid' … … 3859 3859 outfile.variables['z'][:] = z # FIXME (Ole): Remove once viewer has been recompiled and changed to use elevation instead of z 3860 3860 outfile.variables['elevation'][:] = z 3861 outfile.variables['volumes'][:] = volumes.astype( numpy.int32) # On Opteron 643861 outfile.variables['volumes'][:] = volumes.astype(Int) # On Opteron 64 3862 3862 3863 3863 stage = outfile.variables['stage'] … … 4035 4035 lat_name = 'LAT' 4036 4036 time_name = 'TIME' 4037 precision = numpy.float # So if we want to change the precision its done here4037 precision = Float # So if we want to change the precision its done here 4038 4038 class Write_nc: 4039 4039 """ … … 4260 4260 lonlatdep = p_array.array('f') ###NumPy? 4261 4261 lonlatdep.read(mux_file, columns * points_num) 4262 lonlatdep = numpy.array(lonlatdep, typecode=numpy.float)4262 lonlatdep = numpy.array(lonlatdep, dtype=Float) 4263 4263 lonlatdep = numpy.reshape(lonlatdep, (points_num, columns)) 4264 4264 … … 4267 4267 lon_sorted.sort() 4268 4268 4269 if not lon == lon_sorted:4269 if not numpy.alltrue(lon == lon_sorted): 4270 4270 msg = "Longitudes in mux file are not in ascending order" 4271 4271 raise IOError, msg … … 4273 4273 lat_sorted.sort() 4274 4274 4275 if not lat == lat_sorted:4275 if not numpy.alltrue(lat == lat_sorted): 4276 4276 msg = "Latitudes in mux file are not in ascending order" 4277 4277 … … 4287 4287 hz_p_array = p_array.array('f') 4288 4288 hz_p_array.read(mux_file, points_num) 4289 hz_p = numpy.array(hz_p_array, typecode=numpy.float)4289 hz_p = numpy.array(hz_p_array, dtype=Float) 4290 4290 hz_p = numpy.reshape(hz_p, (len(lon), len(lat))) 4291 4291 hz_p = numpy.transpose(hz_p) #mux has lat varying fastest, nc has long v.f. … … 4365 4365 QUANTITY = 2 4366 4366 4367 long_lat_dep = ensure_numeric(long_lat_dep, numpy.float)4367 long_lat_dep = ensure_numeric(long_lat_dep, Float) 4368 4368 4369 4369 num_points = long_lat_dep.shape[0] … … 4413 4413 # use numeric transpose, after reshaping the quantity vector 4414 4414 # quantity = zeros(len(long_lat_dep), Float) 4415 quantity = numpy.zeros(num_points, numpy.float)4415 quantity = numpy.zeros(num_points, Float) 4416 4416 4417 4417 # print 'num',num_points … … 4795 4795 4796 4796 points_utm=ensure_numeric(points_utm) 4797 assert ensure_numeric(mesh_dic['generatedpointlist']) == \4798 ensure_numeric(points_utm)4797 assert numpy.alltrue(ensure_numeric(mesh_dic['generatedpointlist']) == 4798 ensure_numeric(points_utm)) 4799 4799 4800 4800 volumes = mesh_dic['generatedtrianglelist'] … … 4812 4812 sww = Write_sww() 4813 4813 sww.store_header(outfile, times, len(volumes), len(points_utm), 4814 verbose=verbose,sww_precision= numpy.float)4814 verbose=verbose,sww_precision=Float) 4815 4815 outfile.mean_stage = mean_stage 4816 4816 outfile.zscale = zscale … … 4835 4835 xmomentum=xmomentum, 4836 4836 ymomentum=ymomentum, 4837 sww_precision= numpy.float)4837 sww_precision=Float) 4838 4838 j += 1 4839 4839 if verbose: sww.verbose_quantities(outfile) … … 4871 4871 numSrc=len(filenames) 4872 4872 4873 file_params=-1*numpy.ones(3, numpy.float) #[nsta,dt,nt]4873 file_params=-1*numpy.ones(3,Float) #[nsta,dt,nt] 4874 4874 4875 4875 # Convert verbose to int C flag … … 4880 4880 4881 4881 if permutation is None: 4882 permutation = ensure_numeric([], numpy.float)4882 permutation = ensure_numeric([], Float) 4883 4883 4884 4884 # Call underlying C implementation urs2sts_ext.c … … 4930 4930 4931 4931 times=dt*numpy.arange(parameters_index) 4932 latitudes=numpy.zeros(number_of_selected_stations, numpy.float)4933 longitudes=numpy.zeros(number_of_selected_stations, numpy.float)4934 elevation=numpy.zeros(number_of_selected_stations, numpy.float)4935 quantity=numpy.zeros((number_of_selected_stations, parameters_index), numpy.float)4932 latitudes=numpy.zeros(number_of_selected_stations, Float) 4933 longitudes=numpy.zeros(number_of_selected_stations, Float) 4934 elevation=numpy.zeros(number_of_selected_stations, Float) 4935 quantity=numpy.zeros((number_of_selected_stations, parameters_index), Float) 4936 4936 4937 4937 … … 5040 5040 if weights is None: 5041 5041 # Default is equal weighting 5042 weights=numpy.ones(numSrc, numpy.float)/numSrc5042 weights=numpy.ones(numSrc,Float)/numSrc 5043 5043 else: 5044 5044 weights = ensure_numeric(weights) … … 5174 5174 # 0 to number_of_points-1 5175 5175 if permutation is None: 5176 permutation = numpy.arange(number_of_points, typecode=numpy.int)5176 permutation = numpy.arange(number_of_points, dtype=Int) 5177 5177 5178 5178 … … 5191 5191 description=description, 5192 5192 verbose=verbose, 5193 sts_precision= numpy.float)5193 sts_precision=Float) 5194 5194 5195 5195 # Store 5196 5196 from anuga.coordinate_transforms.redfearn import redfearn 5197 x = numpy.zeros(number_of_points, numpy.float) # Easting5198 y = numpy.zeros(number_of_points, numpy.float) # Northing5197 x = numpy.zeros(number_of_points, Float) # Easting 5198 y = numpy.zeros(number_of_points, Float) # Northing 5199 5199 5200 5200 # Check zone boundaries … … 5229 5229 5230 5230 elevation = numpy.resize(elevation,outfile.variables['elevation'][:].shape) 5231 outfile.variables['permutation'][:] = permutation.astype( numpy.int32) # On Opteron 645231 outfile.variables['permutation'][:] = permutation.astype(Int) # On Opteron 64 5232 5232 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 5233 5233 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() … … 5531 5531 outfile.variables['z'][:] = elevation 5532 5532 outfile.variables['elevation'][:] = elevation #FIXME HACK 5533 outfile.variables['volumes'][:] = volumes.astype( numpy.int32) #On Opteron 645533 outfile.variables['volumes'][:] = volumes.astype(Int) #On Opteron 64 5534 5534 5535 5535 q = 'elevation' … … 5539 5539 5540 5540 5541 def store_quantities(self, outfile, sww_precision= numpy.float32,5541 def store_quantities(self, outfile, sww_precision=Float32, 5542 5542 slice_index=None, time=None, 5543 5543 verbose=False, **quant): … … 5706 5706 number_of_points, 5707 5707 description='Converted from URS mux2 format', 5708 sts_precision= numpy.float32,5708 sts_precision=Float32, 5709 5709 verbose=False): 5710 5710 """ … … 5765 5765 5766 5766 # Doing sts_precision instead of Float gives cast errors. 5767 outfile.createVariable('time', Float r, ('number_of_timesteps',))5767 outfile.createVariable('time', Float, ('number_of_timesteps',)) 5768 5768 5769 5769 for q in Write_sts.sts_quantities: … … 5874 5874 outfile.variables[q+Write_sts.RANGE][1] = max(elevation) 5875 5875 5876 def store_quantities(self, outfile, sts_precision= numpy.float32,5876 def store_quantities(self, outfile, sts_precision=Float32, 5877 5877 slice_index=None, time=None, 5878 5878 verbose=False, **quant): … … 5964 5964 lonlatdep = p_array.array('f') 5965 5965 lonlatdep.read(mux_file, columns * self.points_num) 5966 lonlatdep = numpy.array(lonlatdep, typecode=numpy.float)5966 lonlatdep = numpy.array(lonlatdep, dtype=Float) 5967 5967 lonlatdep = numpy.reshape(lonlatdep, (self.points_num, columns)) 5968 5968 #print 'lonlatdep',lonlatdep … … 5993 5993 hz_p_array = p_array.array('f') 5994 5994 hz_p_array.read(self.mux_file, self.points_num) 5995 hz_p = numpy.array(hz_p_array, typecode=numpy.float)5995 hz_p = numpy.array(hz_p_array, dtype=Float) 5996 5996 self.iter_time_step += 1 5997 5997 … … 6108 6108 #array to store data, number in there is to allow float... 6109 6109 #i'm sure there is a better way! 6110 data=numpy.array([], typecode=numpy.float)6110 data=numpy.array([],dtype=Float) 6111 6111 data=numpy.resize(data,((len(lines)-1),len(header_fields))) 6112 6112 # print 'number of fields',range(len(header_fields)) … … 6685 6685 6686 6686 # Get the relevant quantities (Convert from single precison) 6687 elevation = numpy.array(fid.variables['elevation'][:], numpy.float)6688 stage = numpy.array(fid.variables['stage'][:], numpy.float)6687 elevation = numpy.array(fid.variables['elevation'][:], Float) 6688 stage = numpy.array(fid.variables['stage'][:], Float) 6689 6689 6690 6690 -
anuga_core/source_numpy_conversion/anuga/shallow_water/test_data_manager.py
r5947 r5951 4964 4964 'failed') 4965 4965 4966 self.failUnless( m2d == [[5,6],[9,10]],4967 4966 self.failUnless(numpy.alltrue(m2d == [[5,6],[9,10]]), 4967 'failed') 4968 4968 4969 4969 def test_get_min_max_indexes_lat_ascending(self): … … 5030 5030 self.failUnless(latitudes_new == [-30, -35, -40] and \ 5031 5031 longitudes_new == [148, 149,150], 5032 5033 self.failUnless( m2d == [[0,1,2],[4,5,6],[8,9,10]],5034 5032 'failed') 5033 self.failUnless(numpy.alltrue(m2d == [[0,1,2],[4,5,6],[8,9,10]]), 5034 'failed') 5035 5035 5036 5036 def test_get_min_max_indexes3(self): -
anuga_core/source_numpy_conversion/anuga/shallow_water/tsunami_okada.py
r5901 r5951 31 31 32 32 import numpy 33 from anuga.config import Float 34 33 35 34 36 def earthquake_tsunami(ns,NSMAX,length, width, strike, depth,\ … … 44 46 zrec=zrec0.get_vertex_values(xy=True) 45 47 46 x0= numpy.zeros(ns, numpy.float)47 y0= numpy.zeros(ns, numpy.float)48 x0= numpy.zeros(ns,Float) 49 y0= numpy.zeros(ns,Float) 48 50 if ns ==1: 49 51 x0[0]=xi … … 150 152 zrec=self.zrec 151 153 #initialization 152 disp0=numpy.zeros(3, numpy.float)153 strain0=numpy.zeros(6, numpy.float)154 tilt0 = numpy.zeros(2, numpy.float)155 dislocations=numpy.zeros(ns, numpy.float)156 depths=numpy.zeros(ns, numpy.float)157 strikes= numpy.zeros(ns, numpy.float)158 lengths= numpy.zeros(ns, numpy.float)159 slips= numpy.zeros(ns, numpy.float)160 rakes= numpy.zeros(ns, numpy.float)161 widths= numpy.zeros(ns, numpy.float)162 dips= numpy.zeros(ns, numpy.float)163 strikes= numpy.zeros(ns, numpy.float)164 strikes= numpy.zeros(ns, numpy.float)165 strain = numpy.zeros((N,6), numpy.float)166 disp = numpy.zeros((N,3), numpy.float)167 tilt = numpy.zeros((N,2), numpy.float)168 xs =numpy.zeros(ns, numpy.float)169 ys =numpy.zeros(ns, numpy.float)154 disp0=numpy.zeros(3,Float) 155 strain0=numpy.zeros(6,Float) 156 tilt0 = numpy.zeros(2,Float) 157 dislocations=numpy.zeros(ns,Float) 158 depths=numpy.zeros(ns,Float) 159 strikes= numpy.zeros(ns,Float) 160 lengths= numpy.zeros(ns,Float) 161 slips= numpy.zeros(ns,Float) 162 rakes= numpy.zeros(ns,Float) 163 widths= numpy.zeros(ns,Float) 164 dips= numpy.zeros(ns,Float) 165 strikes= numpy.zeros(ns,Float) 166 strikes= numpy.zeros(ns,Float) 167 strain = numpy.zeros((N,6),Float) 168 disp = numpy.zeros((N,3),Float) 169 tilt = numpy.zeros((N,2),Float) 170 xs =numpy.zeros(ns,Float) 171 ys =numpy.zeros(ns,Float) 170 172 z=[] 171 173 if ns==1: … … 213 215 xrec=y 214 216 yrec=x 217 ## print 'xrec=%s' % str(xrec) 218 ## print 'yrec=%s' % str(yrec) 219 ## print 'zrec=%s' % str(zrec) 215 220 for i in range(0,len(zrec[0])): 216 if zrec[0][i]==yrec and zrec[1][i]==xrec: 221 if numpy.alltrue(zrec[0][i]==yrec) and \ 222 numpy.alltrue(zrec[1][i]==xrec): 223 ## print 'Setting Z!' 217 224 Z=zrec[2][i] 218 225 Z=0.001*Z … … 377 384 378 385 F0=0.0 379 U=numpy.zeros((12,1), numpy.float)380 DUA=numpy.zeros((12,1), numpy.float)381 DUB=numpy.zeros((12,1), numpy.float)382 DUC=numpy.zeros((12,1), numpy.float)386 U=numpy.zeros((12,1),Float) 387 DUA=numpy.zeros((12,1),Float) 388 DUB=numpy.zeros((12,1),Float) 389 DUC=numpy.zeros((12,1),Float) 383 390 384 391 … … 523 530 WZ=self.WZ 524 531 525 DUA=numpy.zeros((12,1), numpy.float)526 DU=numpy.zeros((12,1), numpy.float)527 U=numpy.zeros((12,1), numpy.float)532 DUA=numpy.zeros((12,1),Float) 533 DU=numpy.zeros((12,1),Float) 534 U=numpy.zeros((12,1),Float) 528 535 #----- 529 536 for I in range(0,12): … … 633 640 # DATA PI2/6.283185307179586D0/ 634 641 635 DUB=numpy.zeros((12,1), numpy.float)636 DU=numpy.zeros((12,1), numpy.float)637 U=numpy.zeros((12,1), numpy.float)642 DUB=numpy.zeros((12,1),Float) 643 DU=numpy.zeros((12,1),Float) 644 U=numpy.zeros((12,1),Float) 638 645 639 646 F0=0.0 … … 807 814 # DATA PI2/6.283185307179586D0/ 808 815 809 DUC=numpy.zeros((12,1), numpy.float)810 DU=numpy.zeros((12,1), numpy.float)811 U=numpy.zeros((12,1), numpy.float)816 DUC=numpy.zeros((12,1),Float) 817 DU=numpy.zeros((12,1),Float) 818 U=numpy.zeros((12,1),Float) 812 819 813 820 F0=0.0 … … 1001 1008 EPS=0.000001 1002 1009 1003 XI=numpy.zeros(2, numpy.float)1004 ET=numpy.zeros(2, numpy.float)1005 KXI=numpy.zeros(2, numpy.float)1006 KET=numpy.zeros(2, numpy.float)1007 U=numpy.zeros(12, numpy.float)1008 DU=numpy.zeros(12, numpy.float)1009 DUA=numpy.zeros(12, numpy.float)1010 DUB=numpy.zeros(12, numpy.float)1011 DUC=numpy.zeros(12, numpy.float)1010 XI=numpy.zeros(2,Float) 1011 ET=numpy.zeros(2,Float) 1012 KXI=numpy.zeros(2,Float) 1013 KET=numpy.zeros(2,Float) 1014 U=numpy.zeros(12,Float) 1015 DU=numpy.zeros(12,Float) 1016 DUA=numpy.zeros(12,Float) 1017 DUB=numpy.zeros(12,Float) 1018 DUC=numpy.zeros(12,Float) 1012 1019 1013 1020 #----- … … 1206 1213 # DATA F0,F2,PI2/0.D0,2.D0,6.283185307179586D0/ 1207 1214 1208 U=numpy.zeros(12, numpy.float)1209 DU=numpy.zeros(12, numpy.float)1210 DUA=numpy.zeros(12, numpy.float)1215 U=numpy.zeros(12,Float) 1216 DU=numpy.zeros(12,Float) 1217 DUA=numpy.zeros(12,Float) 1211 1218 F0 =0.0 1212 1219 F2=2.0 … … 1337 1344 # DATA F0,F1,F2,PI2/0.D0,1.D0,2.D0,6.283185307179586D0/ 1338 1345 1339 DUB=numpy.zeros(12, numpy.float)1340 DU=numpy.zeros(12, numpy.float)1341 U=numpy.zeros(12, numpy.float)1346 DUB=numpy.zeros(12,Float) 1347 DU=numpy.zeros(12,Float) 1348 U=numpy.zeros(12,Float) 1342 1349 1343 1350 F0=0.0 … … 1502 1509 # DATA F0,F1,F2,F3,PI2/0.D0,1.D0,2.D0,3.D0,6.283185307179586D0/ 1503 1510 1504 DUC=numpy.zeros(12, numpy.float)1505 DU=numpy.zeros(12, numpy.float)1506 U=numpy.zeros(12, numpy.float)1511 DUC=numpy.zeros(12,Float) 1512 DU=numpy.zeros(12,Float) 1513 U=numpy.zeros(12,Float) 1507 1514 1508 1515 F0=0.0
Note: See TracChangeset
for help on using the changeset viewer.