Changeset 8273


Ignore:
Timestamp:
Dec 7, 2011, 5:02:30 PM (8 years ago)
Author:
steve
Message:

Updated sww_merge again. Hopefully doesn't break too many codes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/utilities/sww_merge.py

    r8270 r8273  
    1111from anuga.file.sww import SWW_file, Write_sww
    1212
     13def sww_merge(domain_global_name, np, verbose=False):
    1314
    14 def sww_merge(swwfiles, output, verbose = False):
     15    output = domain_global_name+".sww"
     16    swwfiles = [ domain_global_name+"_P"+str(v)+"_"+str(np)+".sww" for v in range(np)]
     17
     18    _sww_merge(swwfiles, output, verbose)
     19
     20
     21def _sww_merge(swwfiles, output, verbose):
    1522    """
    1623        Merge a list of sww files into a single file.
     
    2835        verbose True to log output information
    2936    """
    30    
     37
     38    if verbose:
     39        print "MERGING SWW Files"
     40       
    3141    static_quantities = ['elevation']
    3242    dynamic_quantities = ['stage', 'xmomentum', 'ymomentum']
     
    8898   
    8999    # Write out the SWW file
     100
     101    if verbose:
     102            print 'Writing file ', output, ':'
    90103    fido = NetCDFFile(output, netcdf_mode_w)
    91104    sww = Write_sww(static_quantities, dynamic_quantities)
     
    130143                   help='number of processors used to produce sww files')
    131144    parser.add_argument('-f', type=str, default="domain",
    132                    help='base sww file name')
     145                   help='domain global name')
    133146    parser.add_argument('-v', nargs='?', type=bool, const=True, default=False,
    134147                   help='verbosity')
     
    137150
    138151    np = args.np
    139     filebase = args.f
     152    domain_global_name = args.f
    140153    verbose = args.v
    141154
    142     #print np
    143     #print filebase
    144     #print verbose
    145 
    146 
    147 
    148     output = filebase+".sww"
    149     swwfiles = [ filebase+"_P"+str(v)+"_"+str(np)+".sww" for v in range(np)]
    150 
    151     #print swwfiles
    152155
    153156    try:
    154         sww_merge(swwfiles, output, verbose)
     157        sww_merge(domain_global_name, np, verbose)
    155158    except:
    156         msg = 'ERROR: When merging sww files '+" ".join(swwfiles)
     159        msg = 'ERROR: When merging sww files %s '% domain_global_name
    157160        print msg
    158161        raise
Note: See TracChangeset for help on using the changeset viewer.