Changeset 1123
- Timestamp:
- Mar 22, 2005, 4:32:40 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/most2nc.py
r1122 r1123 1 def most2nc(input_file=None,output_file=None,inverted_bathymetry = False): 1 def most2nc(input_file=None,output_file=None,inverted_bathymetry = False,\ 2 verbose = True): 2 3 #input_file = 'small.txt' 3 4 #output_file = 'small_e.nc' … … 6 7 lat_name = 'LAT' 7 8 if inverted_bathymetry: 9 up = -1. 10 else: 8 11 up = +1. 9 else:10 up = -1.11 12 12 13 from Scientific.IO.NetCDF import NetCDFFile … … 22 23 23 24 in_file = open(input_file,'r') 24 print 'reading header'25 if verbose: print 'reading header' 25 26 nx_ny_str = in_file.readline() 26 27 nx_str,ny_str = nx_ny_str.split() … … 37 38 h2_list.reverse() 38 39 39 print 'reading depths'40 if verbose: print 'reading depths' 40 41 in_depth_list = in_file.readlines() 41 42 in_file.close() … … 43 44 out_depth_list = [[]] 44 45 45 print 'processing depths'46 if verbose: print 'processing depths' 46 47 k=1 47 48 for in_line in in_depth_list: … … 59 60 out_depth_list.reverse() 60 61 depth_list = out_depth_list 61 print out_depth_list62 if verbose: print out_depth_list 62 63 63 print 'writing results'64 if verbose: print 'writing results' 64 65 out_file = NetCDFFile(output_file,'w') 65 66 -
inundation/ga/storm_surge/pyvolution/test_most2nc.py
r1122 r1123 12 12 13 13 def test_small_nxn(self): 14 most2nc.most2nc(input_file= small.txt,output_file=test.nc\15 ,inverted_bathymetry = False )14 most2nc.most2nc(input_file='small.txt',output_file='test.nc'\ 15 ,inverted_bathymetry = False,verbose = False) 16 16 17 17 fid = NetCDFFile('test.nc') 18 18 elevation = fid.variables['ELEVATION'][:] 19 fid.close() 19 20 20 z=[[-13. -14. -15. -16.]\ 21 ,[-9. -10. -11. -12.]\ 22 ,[-5. -6. -7. -8.]\ 23 ,[-1. -2. -3. -4.]] 24 21 z=[[-13., -14., -15., -16.]\ 22 ,[-9., -10., -11., -12.]\ 23 ,[-5., -6., -7., -8.]\ 24 ,[-1., -2., -3., -4.]] 25 25 z = asarray(z) 26 26 27 27 assert allclose(z,elevation) 28 import os 29 os.remove('test.nc') 30
Note: See TracChangeset
for help on using the changeset viewer.