Changeset 6013


Ignore:
Timestamp:
Nov 28, 2008, 11:17:57 AM (15 years ago)
Author:
kristy
Message:

Created and out name for sww2csv, so that it can be renamed due to several sww files in the one directory.

File:
1 edited

Legend:

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

    r6011 r6013  
    20742074def sww2csv_gauges(sww_file,
    20752075                   gauge_file,
     2076                   out_name=None,
    20762077                   quantities = ['stage', 'depth', 'elevation',
    20772078                                 'xmomentum', 'ymomentum'],
     
    20962097        NOTE: order of column can change but names eg 'easting', 'elevation'
    20972098        must be the same! ALL lowercaps!
     2099
     2100        out_name: prefix for output file name (default is 'gauge_')
    20982101       
    20992102    Outputs:
    21002103        one file for each gauge/point location in the points file. They
    21012104        will be named with this format in the same directory as the 'sww_file'
    2102             gauge_<name>.csv    eg gauge_point1.csv
     2105            <out_name><name>.csv
     2106        eg gauge_point1.csv if <out_name> not supplied
     2107           myfile_2_point1.csv if <out_name> ='myfile_2_'
     2108           
    21032109           
    21042110        They will all have a header
     
    21332139    assert type(gauge_file) == type(''),\
    21342140           'Gauge filename must be a string'
     2141    assert type(out_name) == type(''),\
     2142           'Output filename prefix must be a string'
    21352143   
    21362144    try:
     
    22082216                                 use_cache=use_cache)
    22092217
    2210     gauge_file='gauge_'
     2218    if out_name is None:
     2219        gauge_file='gauge_'
     2220    else:
     2221        gauge_file = out_name
    22112222
    22122223    heading = [quantity for quantity in quantities]
     
    22192230    for i,point in enumerate(points):
    22202231        #print 'gauge file:',dir_name+sep+'gauge_'+point_name[i]+'.csv'
    2221         points_writer.append(writer(file(dir_name+sep+'gauge_'+point_name[i]+'.csv', "wb")))
     2232        points_writer.append(writer(file(dir_name+sep+gauge_file+point_name[i]+'.csv', "wb")))
    22222233        points_writer[i].writerow(heading)
    22232234   
Note: See TracChangeset for help on using the changeset viewer.