Changeset 1123


Ignore:
Timestamp:
Mar 22, 2005, 4:32:40 PM (20 years ago)
Author:
prow
Message:

adding most2nc and tests. It is working.

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):
     1def most2nc(input_file=None,output_file=None,inverted_bathymetry = False,\
     2            verbose = True):
    23    #input_file = 'small.txt'
    34    #output_file = 'small_e.nc'
     
    67    lat_name = 'LAT'
    78    if inverted_bathymetry:
     9        up = -1.
     10    else:
    811        up = +1.
    9     else:
    10         up = -1.
    1112   
    1213    from Scientific.IO.NetCDF import NetCDFFile
     
    2223   
    2324    in_file = open(input_file,'r')
    24     print 'reading header'
     25    if verbose: print 'reading header'
    2526    nx_ny_str = in_file.readline()
    2627    nx_str,ny_str = nx_ny_str.split()
     
    3738    h2_list.reverse()
    3839
    39     print 'reading depths'
     40    if verbose: print 'reading depths'
    4041    in_depth_list = in_file.readlines()
    4142    in_file.close()
     
    4344    out_depth_list = [[]]
    4445
    45     print 'processing depths'
     46    if verbose: print 'processing depths'
    4647    k=1
    4748    for in_line in in_depth_list:
     
    5960    out_depth_list.reverse()
    6061    depth_list = out_depth_list
    61     print out_depth_list
     62    if verbose: print out_depth_list
    6263
    63     print 'writing results'
     64    if verbose: print 'writing results'
    6465    out_file = NetCDFFile(output_file,'w')
    6566
  • inundation/ga/storm_surge/pyvolution/test_most2nc.py

    r1122 r1123  
    1212
    1313    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)
    1616
    1717        fid = NetCDFFile('test.nc')
    1818        elevation = fid.variables['ELEVATION'][:]
     19        fid.close()
    1920
    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.]]
    2525        z = asarray(z)
    2626
    2727        assert allclose(z,elevation)
     28        import os
     29        os.remove('test.nc')
     30       
Note: See TracChangeset for help on using the changeset viewer.