Changeset 4918


Ignore:
Timestamp:
Jan 9, 2008, 2:24:52 PM (17 years ago)
Author:
nick
Message:

corrections to sww2csv_gauges in util.py

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r4910 r4918  
    15801580#        points_file = 'test_point.csv'
    15811581        file_id = open(points_file,"w")
    1582         file_id.write("name, easting, northing \n\
     1582        file_id.write("name,easting,northing \n\
    15831583point1, 5.0, 1.0\n\
    15841584point2, 0.5, 2.0\n")
     
    16411641if __name__ == "__main__":
    16421642    suite = unittest.makeSuite(Test_Util,'test')
    1643 #    suite = unittest.makeSuite(Test_Util,'test_gauges_sww')
     1643#    suite = unittest.makeSuite(Test_Util,'test_sww2')
    16441644#    runner = unittest.TextTestRunner(verbosity=2)
    16451645    runner = unittest.TextTestRunner(verbosity=1)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r4912 r4918  
    1818   
    1919from anuga.geospatial_data.geospatial_data import ensure_absolute
     20from math import sqrt, atan, degrees
    2021
    2122
     
    947948    """ Calculate velocity bearing from North
    948949    """
    949     from math import atan, degrees
     950#    from math import atan, degrees
    950951   
    951952    angle = degrees(atan(vh/(uh+1.e-15)))
     
    971972    each sww file
    972973    """
    973     from math import sqrt, atan, degrees
     974#    from math import sqrt, atan, degrees
    974975    from Numeric import ones, allclose, zeros, Float, ravel
    975976    from os import sep, altsep, getcwd, mkdir, access, F_OK, environ
     
    23282329            point2, 10.3, 70.3, 78.0
    23292330       
     2331        NOTE: order of column can change but names eg 'easting', elevation'
     2332        must be the same!
     2333       
    23302334    Outputs:
    23312335        one file for each gauge/point location in the points file. They
     
    23722376                  %(gauge_file, e)
    23732377        raise msg
    2374     if verbose: print '\n Gauges obtained from: %s \n' %gauge_filename
     2378    if verbose: print '\n Gauges obtained from: %s \n' %gauge_file
    23752379   
    23762380   
     
    23792383    point_name = []
    23802384   
    2381     #skip header
    2382     point_reader.next()
    23832385    #read point info from file
    23842386    for i,row in enumerate(point_reader):
    23852387#        print 'i',i,'row',row
    2386         points.append([float(row[1]),float(row[2])])
    2387         point_name.append(row[0])
     2388        #read header and determine the column numbers to read correcty.
     2389        if i==0:
     2390            for j,value in enumerate(row):
     2391#                print 'j',j,value, row
     2392                if value.strip()=='easting':easting=j
     2393                if value.strip()=='northing':northing=j
     2394                if value.strip()=='name':name=j
     2395                if value.strip()=='elevation':elevation=j
     2396        else:
     2397#            print i,'easting',easting,'northing',northing, row[easting]
     2398            points.append([float(row[easting]),float(row[northing])])
     2399            point_name.append(row[name])
    23882400       
    23892401    #convert to array for file_function
     
    24802492                            momentum = sqrt(point_quantities[2]**2 +\
    24812493                                            point_quantities[3]**2)
    2482                             vel = momentum/depth             
     2494#                            vel = momentum/depth             
     2495                            vel = momentum/(point_quantities[0] - point_quantities[1])
    24832496#                            vel = momentum/(depth + 1.e-6/depth)             
    24842497                       
Note: See TracChangeset for help on using the changeset viewer.