Changeset 5947
- Timestamp:
- Nov 12, 2008, 12:09:05 PM (16 years ago)
- Location:
- anuga_core/source_numpy_conversion/anuga/shallow_water
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/shallow_water/data_manager.py
r5901 r5947 79 79 from os import getcwd 80 80 81 81 from anuga.config import Int, Float, Float32 82 82 from anuga.coordinate_transforms.redfearn import redfearn, \ 83 83 convert_from_latlon_to_utm … … 314 314 from Scientific.IO.NetCDF import NetCDFFile 315 315 316 self.precision = numpy.float32 #Use single precision for quantities316 self.precision = Float32 #Use single precision for quantities 317 317 if hasattr(domain, 'max_size'): 318 318 self.max_size = domain.max_size #file size max is 2Gig … … 407 407 z = fid.variables['elevation'] 408 408 409 volumes = fid.variables['volumes']409 volumes = numpy.array(fid.variables['volumes']) 410 410 411 411 # Get X, Y and bed elevation Z … … 632 632 633 633 634 fid.createVariable('volumes', numpy.int, ('number_of_volumes',634 fid.createVariable('volumes', Int, ('number_of_volumes', 635 635 'number_of_vertices')) 636 636 … … 1418 1418 1419 1419 # Variable definitions 1420 outfile.createVariable('points', numpy.float, ('number_of_points',1420 outfile.createVariable('points', Float, ('number_of_points', 1421 1421 'number_of_dimensions')) 1422 outfile.createVariable('elevation', numpy.float, ('number_of_points',))1422 outfile.createVariable('elevation', Float, ('number_of_points',)) 1423 1423 1424 1424 # Get handles to the variables … … 2600 2600 2601 2601 # variable definitions 2602 fid.createVariable('elevation', numpy.float, ('number_of_rows',2602 fid.createVariable('elevation', Float, ('number_of_rows', 2603 2603 'number_of_columns')) 2604 2604 … … 3163 3163 fid.createDimension('number_of_timesteps', len(T)) 3164 3164 3165 fid.createVariable('time', numpy.float, ('number_of_timesteps',))3165 fid.createVariable('time', Float, ('number_of_timesteps',)) 3166 3166 3167 3167 fid.variables['time'][:] = T … … 3173 3173 name = 'Attribute%d'%i 3174 3174 3175 fid.createVariable(name, numpy.float, ('number_of_timesteps',))3175 fid.createVariable(name, Float, ('number_of_timesteps',)) 3176 3176 fid.variables[name][:] = Q[:,i] 3177 3177 … … 3558 3558 3559 3559 # variable definition 3560 outfile.createVariable('elevation', numpy.float, ('number_of_points',))3560 outfile.createVariable('elevation', Float, ('number_of_points',)) 3561 3561 3562 3562 # Get handle to the variable … … 3775 3775 ################################# 3776 3776 3777 outfile.createVariable('volumes', numpy.int, ('number_of_volumes',3777 outfile.createVariable('volumes', Int, ('number_of_volumes', 3778 3778 'number_of_vertices')) 3779 3779 … … 5321 5321 smoothing=True, 5322 5322 order=1, 5323 sww_precision= numpy.float32,5323 sww_precision=None, 5324 5324 verbose=False): 5325 5325 """ … … 5332 5332 outfile.institution = 'Geoscience Australia' 5333 5333 outfile.description = description 5334 5335 # ensure sww_precision is a character data type 5336 if sww_precision is None: 5337 sww_precision = Float32 5338 elif isinstance(sww_precision, type): 5339 sww_precision = numpy.dtype(sww_precision).char 5334 5340 5335 5341 # For sww compatibility … … 5406 5412 ################################# 5407 5413 5408 outfile.createVariable('volumes', numpy.int, ('number_of_volumes',5414 outfile.createVariable('volumes', Int, ('number_of_volumes', 5409 5415 'number_of_vertices')) 5410 5416 # Doing sww_precision instead of Float gives cast errors. 5411 outfile.createVariable('time', numpy.float,5417 outfile.createVariable('time', Float, 5412 5418 ('number_of_timesteps',)) 5413 5419 … … 5744 5750 5745 5751 # Variable definitions 5746 outfile.createVariable('permutation', numpy.int, ('number_of_points',))5752 outfile.createVariable('permutation', Int, ('number_of_points',)) 5747 5753 outfile.createVariable('x', sts_precision, ('number_of_points',)) 5748 5754 outfile.createVariable('y', sts_precision, ('number_of_points',)) … … 5759 5765 5760 5766 # Doing sts_precision instead of Float gives cast errors. 5761 outfile.createVariable('time', numpy.float, ('number_of_timesteps',))5767 outfile.createVariable('time', Floatr, ('number_of_timesteps',)) 5762 5768 5763 5769 for q in Write_sts.sts_quantities: -
anuga_core/source_numpy_conversion/anuga/shallow_water/shallow_water_domain.py
r5901 r5947 1457 1457 # FIXME: Reconsider this semantics 1458 1458 raise msg 1459 1460 1459 try: 1461 1460 q = numpy.array(q).astype(numpy.float) … … 1467 1466 1468 1467 # Is this really what we want? 1469 msg = 'Return vector from function %s ' % f1468 msg = 'Return vector from function %s ' % f 1470 1469 msg += 'must have same lenght as input vectors' 1471 assert len(q) == N, msg 1470 try: 1471 assert len(q) == N, msg 1472 except: 1473 raise AssertionError, msg 1472 1474 1473 1475 else: -
anuga_core/source_numpy_conversion/anuga/shallow_water/test_data_manager.py
r5901 r5947 15 15 from sets import ImmutableSet 16 16 17 from anuga.config import Float, Int 17 18 from anuga.shallow_water import * 18 19 from anuga.shallow_water.data_manager import * … … 66 67 #Initial condition - with jumps 67 68 bed = domain.quantities['elevation'].vertex_values 68 stage = numpy.zeros(bed.shape, numpy.float)69 stage = numpy.zeros(bed.shape, Float) 69 70 70 71 h = 0.3 … … 446 447 447 448 import time, os 448 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate449 449 from Scientific.IO.NetCDF import NetCDFFile 450 450 … … 504 504 505 505 import time, os 506 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate507 506 from Scientific.IO.NetCDF import NetCDFFile 508 507 … … 559 558 560 559 import time, os, config 561 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate562 560 from Scientific.IO.NetCDF import NetCDFFile 563 561 … … 607 605 608 606 import time, os 609 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate610 607 from Scientific.IO.NetCDF import NetCDFFile 611 608 … … 663 660 664 661 import time, os 665 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate666 662 from Scientific.IO.NetCDF import NetCDFFile 667 663 … … 724 720 725 721 import time, os 726 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate, ones727 722 from Scientific.IO.NetCDF import NetCDFFile 728 723 … … 838 833 839 834 import time, os 840 ## from numpy.oldnumeric 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 = numpy.zeros(100 )857 z = numpy.zeros(100, Float) 864 858 NODATA_value = -9999 865 859 count = -1 … … 920 914 921 915 #create new reference points 922 newz = numpy.zeros(19 )916 newz = numpy.zeros(19, Float) 923 917 newz[0:2] = ref_elevation[32:34] 924 918 newz[2:5] = ref_elevation[35:38] … … 969 963 970 964 import time, os 971 ## from numpy.oldnumeric 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 = numpy.zeros(100 )987 z = numpy.zeros(100, Float) 995 988 NODATA_value = -9999 996 989 count = -1 … … 1051 1044 1052 1045 #create new reference points 1053 newz = numpy.zeros(14 )1046 newz = numpy.zeros(14, Float) 1054 1047 newz[0:2] = ref_elevation[32:34] 1055 1048 newz[2:5] = ref_elevation[35:38] … … 1103 1096 1104 1097 import time, os 1105 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1106 1098 from Scientific.IO.NetCDF import NetCDFFile 1107 1099 … … 1235 1227 1236 1228 import time, os 1237 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1238 1229 from Scientific.IO.NetCDF import NetCDFFile 1239 1230 … … 1427 1418 1428 1419 import time, os 1429 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1430 1420 from Scientific.IO.NetCDF import NetCDFFile 1431 1421 … … 1511 1501 1512 1502 import time, os 1513 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1514 1503 from Scientific.IO.NetCDF import NetCDFFile 1515 1504 … … 1649 1638 1650 1639 import time, os 1651 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1652 1640 from Scientific.IO.NetCDF import NetCDFFile 1653 1641 … … 1795 1783 1796 1784 import time, os 1797 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1798 1785 from Scientific.IO.NetCDF import NetCDFFile 1799 1786 … … 1943 1930 1944 1931 import time, os 1945 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate1946 1932 from Scientific.IO.NetCDF import NetCDFFile 1947 1933 … … 2130 2116 2131 2117 import time, os 2132 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate2133 2118 from Scientific.IO.NetCDF import NetCDFFile 2134 2119 … … 2296 2281 2297 2282 import time, os 2298 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate2299 2283 from Scientific.IO.NetCDF import NetCDFFile 2300 2284 … … 2408 2392 2409 2393 import time, os 2410 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate2411 2394 from Scientific.IO.NetCDF import NetCDFFile 2412 2395 … … 2524 2507 2525 2508 import time, os 2526 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate2527 2509 from Scientific.IO.NetCDF import NetCDFFile 2528 2510 … … 2557 2539 2558 2540 bed = domain.quantities['elevation'].vertex_values 2559 stage = numpy.zeros(bed.shape, numpy.float)2541 stage = numpy.zeros(bed.shape, Float) 2560 2542 2561 2543 h = 0.3 … … 2669 2651 2670 2652 import time, os 2671 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate2672 2653 from Scientific.IO.NetCDF import NetCDFFile 2673 2654 … … 2769 2750 2770 2751 import time, os 2771 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate, NewAxis2772 2752 from Scientific.IO.NetCDF import NetCDFFile 2773 2753 # Used for points that lie outside mesh … … 3535 3515 3536 3516 import time, os 3537 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate3538 3517 from Scientific.IO.NetCDF import NetCDFFile 3539 3518 … … 3582 3561 ################################################ 3583 3562 from mesh_factory import rectangular 3584 ## from numpy.oldnumeric import array3585 3563 3586 3564 #Create basic mesh … … 3627 3605 ########################################## 3628 3606 from data_manager import sww2domain 3629 ## from numpy.oldnumeric import allclose3630 3607 import os 3631 3608 … … 3719 3696 3720 3697 from mesh_factory import rectangular 3721 ## from numpy.oldnumeric import array3722 3698 3723 3699 #Create basic mesh … … 3761 3737 ################################## 3762 3738 from data_manager import sww2domain 3763 ## from numpy.oldnumeric import allclose3764 3739 import os 3765 3740 … … 3828 3803 ################################################ 3829 3804 from mesh_factory import rectangular 3830 ## from numpy.oldnumeric import array3831 3805 #Create basic mesh 3832 3806 … … 3872 3846 ########################################## 3873 3847 from data_manager import sww2domain 3874 ## from numpy.oldnumeric import allclose3875 3848 import os 3876 3849 … … 3959 3932 3960 3933 import os 3961 ## from numpy.oldnumeric import ones, allclose, Float, arange3962 3934 from Scientific.IO.NetCDF import NetCDFFile 3963 3935 … … 3991 3963 fid.createDimension('number_of_points', nrows*ncols) 3992 3964 3993 fid.createVariable('elevation', numpy.float, ('number_of_points',))3965 fid.createVariable('elevation', Float, ('number_of_points',)) 3994 3966 3995 3967 elevation = fid.variables['elevation'] … … 4018 3990 4019 3991 #generate a stencil for computing the decimated values 4020 stencil = numpy.ones((3,3), numpy.float) / 9.03992 stencil = numpy.ones((3,3), Float) / 9.0 4021 3993 4022 3994 decimate_dem(root, stencil=stencil, cellsize_new=100) … … 4042 4014 4043 4015 import os 4044 ## from numpy.oldnumeric import ones, allclose, Float, arange, reshape4045 4016 from Scientific.IO.NetCDF import NetCDFFile 4046 4017 … … 4075 4046 fid.createDimension('number_of_points', nrows*ncols) 4076 4047 4077 fid.createVariable('elevation', numpy.float, ('number_of_points',))4048 fid.createVariable('elevation', Float, ('number_of_points',)) 4078 4049 4079 4050 elevation = fid.variables['elevation'] … … 4113 4084 4114 4085 #generate a stencil for computing the decimated values 4115 stencil = numpy.ones((3,3), numpy.float) / 9.04086 stencil = numpy.ones((3,3), Float) / 9.0 4116 4087 4117 4088 decimate_dem(root, stencil=stencil, cellsize_new=100) … … 4138 4109 4139 4110 import time, os 4140 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate4141 4111 from Scientific.IO.NetCDF import NetCDFFile 4142 4112 … … 4164 4134 4165 4135 import time, os 4166 ## from numpy.oldnumeric import array, zeros, allclose, Float, concatenate4167 4136 from Scientific.IO.NetCDF import NetCDFFile 4168 4137 … … 5505 5474 quantities_init[i] = ensure_numeric(quantities_init[i]) 5506 5475 #print "HA_init", HA_init 5507 q_time = numpy.zeros((time_step_count, points_num), numpy.float)5476 q_time = numpy.zeros((time_step_count, points_num), Float) 5508 5477 for time in range(time_step_count): 5509 5478 q_time[time,:] = quantities_init[i] #* time * 4 … … 5588 5557 quantities_init[i] = ensure_numeric(quantities_init[i]) 5589 5558 #print "HA_init", HA_init 5590 q_time = numpy.zeros((time_step_count, points_num), numpy.float)5559 q_time = numpy.zeros((time_step_count, points_num), Float) 5591 5560 for time in range(time_step_count): 5592 5561 q_time[time,:] = quantities_init[i] #* time * 4 … … 6044 6013 if ha is None: 6045 6014 this_ha = e 6046 quantities_init[0].append(numpy.ones(time_step_count, numpy.float)*this_ha) # HA6015 quantities_init[0].append(numpy.ones(time_step_count,Float)*this_ha) # HA 6047 6016 else: 6048 6017 quantities_init[0].append(ha[i]) 6049 6018 if ua is None: 6050 6019 this_ua = n 6051 quantities_init[1].append(numpy.ones(time_step_count, numpy.float)*this_ua) # UA6020 quantities_init[1].append(numpy.ones(time_step_count,Float)*this_ua) # UA 6052 6021 else: 6053 6022 quantities_init[1].append(ua[i]) 6054 6023 if va is None: 6055 6024 this_va = e 6056 quantities_init[2].append(numpy.ones(time_step_count, numpy.float)*this_va) #6025 quantities_init[2].append(numpy.ones(time_step_count,Float)*this_va) # 6057 6026 else: 6058 6027 quantities_init[2].append(va[i]) … … 6064 6033 files = [] 6065 6034 for i,q in enumerate(quantities): 6066 q_time = numpy.zeros((time_step_count, points_num), numpy.float)6035 q_time = numpy.zeros((time_step_count, points_num), Float) 6067 6036 quantities_init[i] = ensure_numeric(quantities_init[i]) 6068 6037 for time in range(time_step_count): … … 6129 6098 first_tstep=numpy.ones(n,numpy.int) 6130 6099 last_tstep=time_step_count*numpy.ones(n,numpy.int) 6131 depth=20*numpy.ones(n, numpy.float)6132 ha=2*numpy.ones((n,time_step_count), numpy.float)6133 ua=5*numpy.ones((n,time_step_count), numpy.float)6134 va=-10*numpy.ones((n,time_step_count), numpy.float)6100 depth=20*numpy.ones(n,Float) 6101 ha=2*numpy.ones((n,time_step_count),Float) 6102 ua=5*numpy.ones((n,time_step_count),Float) 6103 va=-10*numpy.ones((n,time_step_count),Float) 6135 6104 #-ve added to take into account mux file format where south is positive. 6136 6105 base_name, files = self.write_mux2(lat_long_points, … … 6142 6111 va=va) 6143 6112 6144 weights=numpy.ones(1, numpy.float)6113 weights=numpy.ones(1, Float) 6145 6114 #ensure that files are indeed mux2 files 6146 6115 times, latitudes, longitudes, elevation, stage, starttime =read_mux2_py([files[0]],weights) … … 6184 6153 first_tstep=numpy.ones(n,numpy.int) 6185 6154 last_tstep=(time_step_count)*numpy.ones(n,numpy.int) 6186 depth=20*numpy.ones(n, numpy.float)6187 ha=2*numpy.ones((n,time_step_count), numpy.float)6155 depth=20*numpy.ones(n,Float) 6156 ha=2*numpy.ones((n,time_step_count),Float) 6188 6157 ha[0]=numpy.arange(0,time_step_count)+1 6189 6158 ha[1]=time_step_count-numpy.arange(1,time_step_count+1) … … 6191 6160 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 6192 6161 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 6193 ua=5*numpy.ones((n,time_step_count), numpy.float)6194 va=-10*numpy.ones((n,time_step_count), numpy.float)6162 ua=5*numpy.ones((n,time_step_count),Float) 6163 va=-10*numpy.ones((n,time_step_count),Float) 6195 6164 #-ve added to take into account mux file format where south is positive. 6196 6165 base_name, files = self.write_mux2(lat_long_points, … … 6202 6171 va=va) 6203 6172 6204 weights=numpy.ones(1, numpy.float)6173 weights=numpy.ones(1, Float) 6205 6174 #ensure that files are indeed mux2 files 6206 6175 times, latitudes, longitudes, elevation, stage,starttime=read_mux2_py([files[0]],weights) … … 6246 6215 last_tstep[0]-=1 6247 6216 6248 depth=20*numpy.ones(n, numpy.float)6249 ha=2*numpy.ones((n,time_step_count), numpy.float)6217 depth=20*numpy.ones(n,Float) 6218 ha=2*numpy.ones((n,time_step_count),Float) 6250 6219 ha[0]=numpy.arange(0,time_step_count) 6251 6220 ha[1]=numpy.arange(time_step_count,2*time_step_count) 6252 6221 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 6253 6222 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 6254 ua=5*numpy.ones((n,time_step_count), numpy.float)6255 va=-10*numpy.ones((n,time_step_count), numpy.float)6223 ua=5*numpy.ones((n,time_step_count),Float) 6224 va=-10*numpy.ones((n,time_step_count),Float) 6256 6225 #-ve added to take into account mux file format where south is positive. 6257 6226 base_name, files = self.write_mux2(lat_long_points, … … 6263 6232 va=va) 6264 6233 6265 weights=numpy.ones(1, numpy.float)6234 weights=numpy.ones(1, Float) 6266 6235 #ensure that files are indeed mux2 files 6267 6236 times, latitudes, longitudes, elevation, stage,starttime=read_mux2_py([files[0]],weights) … … 6319 6288 last_tstep[0]-=1 6320 6289 6321 gauge_depth=20*numpy.ones(n, numpy.float)6322 ha=2*numpy.ones((n,time_step_count), numpy.float)6290 gauge_depth=20*numpy.ones(n,Float) 6291 ha=2*numpy.ones((n,time_step_count),Float) 6323 6292 ha[0]=numpy.arange(0,time_step_count) 6324 6293 ha[1]=numpy.arange(time_step_count,2*time_step_count) 6325 6294 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 6326 6295 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 6327 ua=5*numpy.ones((n,time_step_count), numpy.float)6328 va=-10*numpy.ones((n,time_step_count), numpy.float)6296 ua=5*numpy.ones((n,time_step_count),Float) 6297 va=-10*numpy.ones((n,time_step_count),Float) 6329 6298 6330 6299 base_name, files = self.write_mux2(lat_long_points, … … 6399 6368 #momentum = velocity_ua *(stage+depth) 6400 6369 6401 depth=numpy.zeros((len(lat_long_points),time_step_count), numpy.float)6370 depth=numpy.zeros((len(lat_long_points),time_step_count),Float) 6402 6371 for i in range(len(lat_long_points)): 6403 6372 depth[i]=gauge_depth[i]+tide+ha[i] … … 6434 6403 last_tstep[0]-=1 6435 6404 6436 gauge_depth=20*numpy.ones(n, numpy.float)6437 ha=2*numpy.ones((n,time_step_count), numpy.float)6405 gauge_depth=20*numpy.ones(n,Float) 6406 ha=2*numpy.ones((n,time_step_count),Float) 6438 6407 ha[0]=numpy.arange(0,time_step_count) 6439 6408 ha[1]=numpy.arange(time_step_count,2*time_step_count) 6440 6409 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 6441 6410 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 6442 ua=5*numpy.ones((n,time_step_count), numpy.float)6443 va=-10*numpy.ones((n,time_step_count), numpy.float)6411 ua=5*numpy.ones((n,time_step_count),Float) 6412 va=-10*numpy.ones((n,time_step_count),Float) 6444 6413 6445 6414 base_name, files = self.write_mux2(lat_long_points, … … 6496 6465 last_tstep[0]-=1 6497 6466 6498 gauge_depth=20*numpy.ones(n, numpy.float)6499 ha=2*numpy.ones((n,time_step_count), numpy.float)6467 gauge_depth=20*numpy.ones(n,Float) 6468 ha=2*numpy.ones((n,time_step_count),Float) 6500 6469 ha[0]=numpy.arange(0,time_step_count) 6501 6470 ha[1]=numpy.arange(time_step_count,2*time_step_count) 6502 6471 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 6503 6472 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 6504 ua=5*numpy.ones((n,time_step_count), numpy.float)6505 va=-10*numpy.ones((n,time_step_count), numpy.float)6473 ua=5*numpy.ones((n,time_step_count),Float) 6474 va=-10*numpy.ones((n,time_step_count),Float) 6506 6475 6507 6476 base_name, files = self.write_mux2(lat_long_points, … … 6557 6526 last_tstep[0]-=1 6558 6527 6559 gauge_depth=20*numpy.ones(n, numpy.float)6560 ha=2*numpy.ones((n,time_step_count), numpy.float)6528 gauge_depth=20*numpy.ones(n,Float) 6529 ha=2*numpy.ones((n,time_step_count),Float) 6561 6530 ha[0]=numpy.arange(0,time_step_count) 6562 6531 ha[1]=numpy.arange(time_step_count,2*time_step_count) 6563 6532 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 6564 6533 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 6565 ua=5*numpy.ones((n,time_step_count), numpy.float)6566 va=-10*numpy.ones((n,time_step_count), numpy.float)6534 ua=5*numpy.ones((n,time_step_count),Float) 6535 va=-10*numpy.ones((n,time_step_count),Float) 6567 6536 6568 6537 # Create two identical mux files to be combined by urs2sts … … 6653 6622 #momentum = velocity_ua *(stage+depth) 6654 6623 6655 depth=numpy.zeros((len(lat_long_points),time_step_count), numpy.float)6624 depth=numpy.zeros((len(lat_long_points),time_step_count),Float) 6656 6625 for i in range(len(lat_long_points)): 6657 6626 depth[i]=gauge_depth[i]+tide+2.0*ha[i] … … 6685 6654 over waveheight, easting and northing velocity 6686 6655 """ 6687 ## from numpy.oldnumeric import asarray,numpy.transpose,sqrt,argmax,argmin,arange,numpy.float,\6688 ## compress,zeros,fabs,take,size6689 6656 6690 6657 # Get path where this test is run … … 6850 6817 over waveheight, easting and northing velocity 6851 6818 """ 6852 ## from numpy.oldnumeric import asarray,numpy.transpose,sqrt,argmax,argmin,arange,numpy.float,\6853 ## compress,zeros,fabs,take,size6854 6819 6855 6820 # combined … … 7033 6998 last_tstep[0]-=1 7034 6999 7035 gauge_depth=20*numpy.ones(n, numpy.float)7036 ha=2*numpy.ones((n,time_step_count), numpy.float)7000 gauge_depth=20*numpy.ones(n,Float) 7001 ha=2*numpy.ones((n,time_step_count),Float) 7037 7002 ha[0]=numpy.arange(0,time_step_count) 7038 7003 ha[1]=numpy.arange(time_step_count,2*time_step_count) 7039 7004 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 7040 7005 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 7041 ua=5*numpy.ones((n,time_step_count), numpy.float)7042 va=-10*numpy.ones((n,time_step_count), numpy.float)7006 ua=5*numpy.ones((n,time_step_count),Float) 7007 va=-10*numpy.ones((n,time_step_count),Float) 7043 7008 7044 7009 # Create two identical mux files to be combined by urs2sts … … 7171 7136 #momentum = velocity_ua *(stage+depth) 7172 7137 7173 depth=numpy.zeros((len(lat_long_points),time_step_count), numpy.float)7138 depth=numpy.zeros((len(lat_long_points),time_step_count),Float) 7174 7139 for i in range(len(lat_long_points)): 7175 7140 depth[i]=gauge_depth[i]+tide+2.0*ha[i] … … 7220 7185 last_tstep[0]-=1 7221 7186 7222 gauge_depth=20*numpy.ones(n, numpy.float)7223 ha=2*numpy.ones((n,time_step_count), numpy.float)7187 gauge_depth=20*numpy.ones(n,Float) 7188 ha=2*numpy.ones((n,time_step_count),Float) 7224 7189 ha[0]=numpy.arange(0,time_step_count) 7225 7190 ha[1]=numpy.arange(time_step_count,2*time_step_count) 7226 7191 ha[2]=numpy.arange(2*time_step_count,3*time_step_count) 7227 7192 ha[3]=numpy.arange(3*time_step_count,4*time_step_count) 7228 ua=5*numpy.ones((n,time_step_count), numpy.float)7229 va=-10*numpy.ones((n,time_step_count), numpy.float)7193 ua=5*numpy.ones((n,time_step_count),Float) 7194 va=-10*numpy.ones((n,time_step_count),Float) 7230 7195 7231 7196 # Create two identical mux files to be combined by urs2sts … … 7283 7248 """ 7284 7249 7285 ## from numpy.oldnumeric import sin, cos7286 7287 7250 tide = 1.5 7288 7251 time_step_count = 10 … … 7330 7293 7331 7294 # Create varying elevation data (positive values for seafloor) 7332 gauge_depth=20*numpy.ones(n, numpy.float)7295 gauge_depth=20*numpy.ones(n,Float) 7333 7296 for i in range(n): 7334 7297 gauge_depth[i] += i**2 … … 7337 7300 7338 7301 # Create data to be written to first mux file 7339 ha0=2*numpy.ones((n,time_step_count), numpy.float)7302 ha0=2*numpy.ones((n,time_step_count),Float) 7340 7303 ha0[0]=numpy.arange(0,time_step_count) 7341 7304 ha0[1]=numpy.arange(time_step_count,2*time_step_count) 7342 7305 ha0[2]=numpy.arange(2*time_step_count,3*time_step_count) 7343 7306 ha0[3]=numpy.arange(3*time_step_count,4*time_step_count) 7344 ua0=5*numpy.ones((n,time_step_count), numpy.float)7345 va0=-10*numpy.ones((n,time_step_count), numpy.float)7307 ua0=5*numpy.ones((n,time_step_count),Float) 7308 va0=-10*numpy.ones((n,time_step_count),Float) 7346 7309 7347 7310 # Ensure data used to write mux file to be zero when gauges are … … 7374 7337 7375 7338 # Create data to be written to second mux file 7376 ha1=numpy.ones((n,time_step_count), numpy.float)7339 ha1=numpy.ones((n,time_step_count),Float) 7377 7340 ha1[0]=numpy.sin(times_ref) 7378 7341 ha1[1]=2*numpy.sin(times_ref - 3) … … 7381 7344 ha1[4]=numpy.sin(2*times_ref-0.7) 7382 7345 7383 ua1=numpy.zeros((n,time_step_count), numpy.float)7346 ua1=numpy.zeros((n,time_step_count),Float) 7384 7347 ua1[0]=3*numpy.cos(times_ref) 7385 7348 ua1[1]=2*numpy.sin(times_ref-0.7) … … 7387 7350 ua1[4]=2*numpy.ones(time_step_count) 7388 7351 7389 va1=numpy.zeros((n,time_step_count), numpy.float)7352 va1=numpy.zeros((n,time_step_count),Float) 7390 7353 va1[0]=2*numpy.cos(times_ref-0.87) 7391 7354 va1[1]=3*numpy.ones(time_step_count) … … 7519 7482 #momentum = velocity_ua *(stage+depth) 7520 7483 7521 depth_ref = numpy.zeros((len(permutation), time_step_count), numpy.float)7484 depth_ref = numpy.zeros((len(permutation), time_step_count), Float) 7522 7485 for i in range(len(permutation)): 7523 7486 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 7631 7594 #momentum = velocity_ua *(stage+depth) 7632 7595 7633 depth_ref = numpy.zeros((len(permutation), time_step_count), numpy.float)7596 depth_ref = numpy.zeros((len(permutation), time_step_count), Float) 7634 7597 for i in range(len(permutation)): 7635 7598 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 7737 7700 #momentum = velocity_ua *(stage+depth) 7738 7701 7739 depth_ref = numpy.zeros((len(permutation), time_step_count), numpy.float)7702 depth_ref = numpy.zeros((len(permutation), time_step_count), Float) 7740 7703 for i in range(len(permutation)): 7741 7704 depth_ref[i]=gauge_depth_ref[i]+tide+ha_ref[i] … … 7819 7782 u = 10 7820 7783 v = -10 7821 gauge_depth=h*numpy.ones(n, numpy.float)7822 ha=w*numpy.ones((n,time_step_count), numpy.float)7823 ua=u*numpy.ones((n,time_step_count), numpy.float)7824 va=v*numpy.ones((n,time_step_count), numpy.float)7784 gauge_depth=h*numpy.ones(n,Float) 7785 ha=w*numpy.ones((n,time_step_count),Float) 7786 ua=u*numpy.ones((n,time_step_count),Float) 7787 va=v*numpy.ones((n,time_step_count),Float) 7825 7788 base_name, files = self.write_mux2(lat_long_points, 7826 7789 time_step_count, time_step, … … 7875 7838 finaltime=time_step*(time_step_count-1) 7876 7839 yieldstep=time_step 7877 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)7840 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1,Float) 7878 7841 7879 7842 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 7907 7870 7908 7871 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 7909 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)7872 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1,Float) 7910 7873 7911 7874 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 7969 7932 u = 10 7970 7933 v = -10 7971 gauge_depth=h*numpy.ones(n, numpy.float)7972 ha=w*numpy.ones((n,time_step_count), numpy.float)7973 ua=u*numpy.ones((n,time_step_count), numpy.float)7974 va=v*numpy.ones((n,time_step_count), numpy.float)7934 gauge_depth=h*numpy.ones(n,Float) 7935 ha=w*numpy.ones((n,time_step_count),Float) 7936 ua=u*numpy.ones((n,time_step_count),Float) 7937 va=v*numpy.ones((n,time_step_count),Float) 7975 7938 base_name, files = self.write_mux2(lat_long_points, 7976 7939 time_step_count, time_step, … … 8034 7997 finaltime = data_finaltime + 10 # Let model time exceed available data 8035 7998 yieldstep = time_step 8036 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)7999 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, Float) 8037 8000 8038 8001 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8066 8029 8067 8030 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8068 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8031 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8069 8032 8070 8033 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8127 8090 u = 10 8128 8091 v = -10 8129 gauge_depth=h*numpy.ones(n, numpy.float)8130 ha=w*numpy.ones((n,time_step_count), numpy.float)8131 ua=u*numpy.ones((n,time_step_count), numpy.float)8132 va=v*numpy.ones((n,time_step_count), numpy.float)8092 gauge_depth=h*numpy.ones(n,Float) 8093 ha=w*numpy.ones((n,time_step_count),Float) 8094 ua=u*numpy.ones((n,time_step_count),Float) 8095 va=v*numpy.ones((n,time_step_count),Float) 8133 8096 base_name, files = self.write_mux2(lat_long_points, 8134 8097 time_step_count, time_step, … … 8195 8158 finaltime = data_finaltime + 10 # Let model time exceed available data 8196 8159 yieldstep = time_step 8197 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8160 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, Float) 8198 8161 8199 8162 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8241 8204 first_tstep=numpy.ones(n,numpy.int) 8242 8205 last_tstep=(time_step_count)*numpy.ones(n,numpy.int) 8243 gauge_depth=20*numpy.ones(n, numpy.float)8244 ha=2*numpy.ones((n,time_step_count), numpy.float)8245 ua=10*numpy.ones((n,time_step_count), numpy.float)8246 va=-10*numpy.ones((n,time_step_count), numpy.float)8206 gauge_depth=20*numpy.ones(n,Float) 8207 ha=2*numpy.ones((n,time_step_count),Float) 8208 ua=10*numpy.ones((n,time_step_count),Float) 8209 va=-10*numpy.ones((n,time_step_count),Float) 8247 8210 base_name, files = self.write_mux2(lat_long_points, 8248 8211 time_step_count, … … 8286 8249 finaltime=time_step*(time_step_count-1) 8287 8250 yieldstep=time_step 8288 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8251 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8289 8252 8290 8253 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8298 8261 Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) 8299 8262 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8300 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8263 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8301 8264 8302 8265 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8347 8310 first_tstep=numpy.ones(n,numpy.int) 8348 8311 last_tstep=(time_step_count)*numpy.ones(n,numpy.int) 8349 gauge_depth=20*numpy.ones(n, numpy.float)8350 ha=2*numpy.ones((n,time_step_count), numpy.float)8351 ua=10*numpy.ones((n,time_step_count), numpy.float)8352 va=-10*numpy.ones((n,time_step_count), numpy.float)8312 gauge_depth=20*numpy.ones(n,Float) 8313 ha=2*numpy.ones((n,time_step_count),Float) 8314 ua=10*numpy.ones((n,time_step_count),Float) 8315 va=-10*numpy.ones((n,time_step_count),Float) 8353 8316 base_name, files = self.write_mux2(lat_long_points, 8354 8317 time_step_count, … … 8436 8399 finaltime=time_step*(time_step_count-1) 8437 8400 yieldstep=time_step 8438 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8401 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8439 8402 8440 8403 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8449 8412 Bd = Dirichlet_boundary([2.0+tide,220+10*tide,-220-10*tide]) 8450 8413 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8451 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8414 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8452 8415 8453 8416 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep, … … 8514 8477 last_tstep=(time_step_count)*numpy.ones(n,numpy.int) 8515 8478 8516 gauge_depth=20*numpy.ones(n, numpy.float)8479 gauge_depth=20*numpy.ones(n,Float) 8517 8480 ha1[1]=2*sin(times_ref - 3) 8518 ua=0.0*numpy.ones((n,time_step_count), numpy.float)8519 va=0.0*numpy.ones((n,time_step_count), numpy.float)8481 ua=0.0*numpy.ones((n,time_step_count),Float) 8482 va=0.0*numpy.ones((n,time_step_count),Float) 8520 8483 8521 8484 … … 8630 8593 finaltime=time_step*(time_step_count-1) 8631 8594 yieldstep=time_step 8632 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8595 temp_fbound=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8633 8596 8634 8597 for i, t in enumerate(domain_fbound.evolve(yieldstep=yieldstep, … … 8646 8609 domain_drchlt.set_boundary({'ocean': Bd,'otherocean': Br}) 8647 8610 8648 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1, numpy.float)8611 temp_drchlt=numpy.zeros(int(finaltime/yieldstep)+1,Float) 8649 8612 8650 8613 for i, t in enumerate(domain_drchlt.evolve(yieldstep=yieldstep,finaltime=finaltime, … … 10014 9977 10015 9978 import time, os 10016 ## from numpy.oldnumeric import array, zeros, allclose, numpy.float, concatenate10017 9979 from Scientific.IO.NetCDF import NetCDFFile 10018 9980 … … 10148 10110 10149 10111 import time, os 10150 ## from numpy.oldnumeric import array, zeros, allclose, numpy.float, concatenate10151 10112 from Scientific.IO.NetCDF import NetCDFFile 10152 10113 … … 10236 10197 10237 10198 import time, os 10238 ## from numpy.oldnumeric import array, zeros, allclose, numpy.float, concatenate10239 10199 from Scientific.IO.NetCDF import NetCDFFile 10240 10200 … … 10363 10323 10364 10324 import time, os 10365 ## from numpy.oldnumeric import array, zeros, allclose, numpy.float, concatenate10366 10325 from Scientific.IO.NetCDF import NetCDFFile 10367 10326 … … 10466 10425 10467 10426 import time, os 10468 ## from numpy.oldnumeric import array, zeros, allclose, numpy.float, concatenate10469 10427 from Scientific.IO.NetCDF import NetCDFFile 10470 10428 -
anuga_core/source_numpy_conversion/anuga/shallow_water/test_shallow_water_domain.py
r5901 r5947 433 433 434 434 435 assert domain.get_conserved_quantities(0, edge=1) == 0.435 assert numpy.alltrue(domain.get_conserved_quantities(0, edge=1) == 0.) 436 436 437 437 … … 6080 6080 suite = unittest.makeSuite(Test_Shallow_Water,'test') 6081 6081 6082 #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_energy_through_cross_section_with_g')6082 ## suite = unittest.makeSuite(Test_Shallow_Water,'test_wind_stress_error_condition') 6083 6083 #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain') 6084 6084 #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
Note: See TracChangeset
for help on using the changeset viewer.