Changeset 3647 for anuga_validation/okushiri_2005/create_okushiri.py
- Timestamp:
- Sep 21, 2006, 3:20:23 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_validation/okushiri_2005/create_okushiri.py
r3646 r3647 6 6 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 7 7 8 from Numeric import array, zeros, Float, allclose 9 8 10 from anuga.pmesh.mesh import * 9 11 from anuga.coordinate_transforms.geo_reference import Geo_reference 10 12 13 import project 14 15 16 def prepare_timeboundary(filename): 17 """Converting benchmark 2 time series to NetCDF tms file. 18 This is a 'throw-away' code taylor made for files like 19 'Benchmark_2_input.txt' from the LWRU2 benchmark 20 """ 21 22 print 'Preparing time boundary from %s' %filename 23 from Numeric import array 24 25 fid = open(filename) 26 27 #Skip first line 28 line = fid.readline() 29 30 #Read remaining lines 31 lines = fid.readlines() 32 fid.close() 33 34 35 N = len(lines) 36 T = zeros(N, Float) #Time 37 Q = zeros(N, Float) #Values 38 39 for i, line in enumerate(lines): 40 fields = line.split() 41 42 T[i] = float(fields[0]) 43 Q[i] = float(fields[1]) 44 45 46 #Create tms file 47 from Scientific.IO.NetCDF import NetCDFFile 48 49 outfile = filename[:-4] + '.tms' 50 print 'Writing to', outfile 51 fid = NetCDFFile(outfile, 'w') 52 53 fid.institution = 'Geoscience Australia' 54 fid.description = 'Input wave for Benchmark 2' 55 fid.starttime = 0.0 56 fid.createDimension('number_of_timesteps', len(T)) 57 fid.createVariable('time', Float, ('number_of_timesteps',)) 58 fid.variables['time'][:] = T 59 60 fid.createVariable('stage', Float, ('number_of_timesteps',)) 61 fid.variables['stage'][:] = Q[:] 62 63 fid.createVariable('xmomentum', Float, ('number_of_timesteps',)) 64 fid.variables['xmomentum'][:] = 0.0 65 66 fid.createVariable('ymomentum', Float, ('number_of_timesteps',)) 67 fid.variables['ymomentum'][:] = 0.0 68 69 fid.close() 70 71 11 72 #------------------------------------------------------------- 12 73 if __name__ == "__main__": 13 74 75 #Preparing points 76 #(Only when using original Benchmark_2_Bathymetry.txt file) 77 #from anuga.abstract_2d_finite_volumes.data_manager import xya2pts 78 #xya2pts(project.bathymetry_filename, verbose = True, 79 # z_func = lambda z: -z) 80 81 82 83 84 85 # Prepare time boundary 86 prepare_timeboundary(project.boundary_filename) 87 88 89 # Create Mesh 14 90 15 91 #Basic geometry
Note: See TracChangeset
for help on using the changeset viewer.