Changeset 1674
- Timestamp:
- Aug 2, 2005, 6:04:27 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/validation/LWRU2/lwru2.py
r1657 r1674 8 8 9 9 """ 10 11 def prepare_timeboundary(filename): 12 """Converting benchmark 2 time series to NetCDF sww file. 13 """ 14 15 16 print 'Preparing time boundary from %s' %filename 17 from Numeric import array 18 19 fid = open(filename) 20 21 #Skip first line 22 line = fid.readline() 23 24 lines = fid.readlines() 25 fid.close() 26 27 N = len(lines) 28 29 T = zeros(N, Float) #Time 30 Q = zeros(N, Float) #Values 31 32 for i, line in enumerate(lines): 33 fields = line.split() 34 35 T[i] = float(fields[0]) 36 Q[i] = float(fields[1]) 37 38 #Create sww file 39 from Scientific.IO.NetCDF import NetCDFFile 40 41 fid = NetCDFFile(filename[-4:] + '.sww', 'w') 42 43 fid.institution = 'Geoscience Australia' 44 fid.description = 'Input wave for Benchmark 2' 45 fid.starttime = 0.0 46 fid.createDimension('number_of_timesteps', len(T)) 47 fid.createVariable('time', Float, ('number_of_timesteps',)) 48 fid.variables['time'][:] = T 49 50 fid.createVariable('stage', Float, ('number_of_timesteps',)) 51 fid.variables['stage'][:] = Q[:] 52 53 fid.createVariable('xmomentum', Float, ('number_of_timesteps',)) 54 fid.variables['xmomentum'][:] = 0.0 55 56 fid.createVariable('ymomentum', Float, ('number_of_timesteps',)) 57 fid.variables['ymomentum'][:] = 0.0 58 59 60 61 fid.close() 62 10 63 11 64 … … 24 77 except: 25 78 79 #Preparing time boundary 80 prepare_timeboundary('Benchmark_2_input.txt') 81 26 82 #Preparing points 27 83 from pyvolution.data_manager import xya2pts 28 xya2pts(' bathymetry.txt', verbose = True)84 xya2pts('Benchmark_2_Bathymetry.txt', verbose = True) 29 85 30 86 … … 75 131 print 'Boundaries' 76 132 Br = Reflective_boundary(domain) 77 Bf = File_boundary(' input_wave.txt', domain)133 Bf = File_boundary('Benchmark_2_input.sww', domain, verbose=True) 78 134 79 135 #Set boundary conditions
Note: See TracChangeset
for help on using the changeset viewer.