Ignore:
Timestamp:
Jun 9, 2010, 12:28:24 PM (13 years ago)
Author:
hudson
Message:

New filename conventions for file conversion. Filenames must always be passed in with the correct extension.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/file_conversion/sww2pts.py

    r7758 r7814  
    11
    22import numpy as num
     3import os
    34
    45from anuga.coordinate_transforms.geo_reference import Geo_reference
     
    1516# @param verbose True if this function is to be verbose.
    1617# @param origin ??
    17 def sww2pts(basename_in, basename_out=None,
     18def sww2pts(name_in, name_out=None,
    1819            data_points=None,
    1920            quantity=None,
     
    4849        reduction = max
    4950
    50     if basename_out is None:
     51    basename_in, in_ext = os.path.splitext(name_in)
     52   
     53    if name_out != None:
     54        basename_out, out_ext = os.path.splitext(name_out)
     55    else:
    5156        basename_out = basename_in + '_%s' % quantity
     57        out_ext = '.pts'
     58        name_out = basename_out + out_ext
    5259
    53     swwfile = basename_in + '.sww'
    54     ptsfile = basename_out + '.pts'
     60    if in_ext != '.sww':
     61        raise IOError('Input format for %s must be .sww' % name_in)
     62
     63    if out_ext != '.pts':
     64        raise IOError('Output format for %s must be .pts' % name_out)
     65
    5566
    5667    # Read sww file
    57     if verbose: log.critical('Reading from %s' % swwfile)
     68    if verbose: log.critical('Reading from %s' % name_in)
    5869    from Scientific.IO.NetCDF import NetCDFFile
    59     fid = NetCDFFile(swwfile)
     70    fid = NetCDFFile(name_in)
    6071
    6172    # Get extent and reference
     
    163174    G = Geospatial_data(data_points=data_points, attributes=interpolated_values)
    164175
    165     G.export_points_file(ptsfile, absolute = True)
     176    G.export_points_file(name_out, absolute = True)
    166177
    167178    fid.close()
Note: See TracChangeset for help on using the changeset viewer.