Ignore:
Timestamp:
Jun 9, 2010, 12:28:24 PM (12 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/dem2pts.py

    r7804 r7814  
    1818# @param verbose
    1919# @return
    20 def dem2pts(basename_in, basename_out=None,
     20def dem2pts(name_in, name_out=None,
    2121            easting_min=None, easting_max=None,
    2222            northing_min=None, northing_max=None,
     
    4040    """
    4141
    42     kwargs = {'basename_out': basename_out,
     42    kwargs = {'name_out': name_out,
    4343              'easting_min': easting_min,
    4444              'easting_max': easting_max,
     
    4949    if use_cache is True:
    5050        from caching import cache
    51         result = cache(_dem2pts, basename_in, kwargs,
    52                        dependencies = [basename_in + '.dem'],
     51        result = cache(_dem2pts, name_in, kwargs,
     52                       dependencies = [name_in],
    5353                       verbose = verbose)
    5454
    5555    else:
    56         result = apply(_dem2pts, [basename_in], kwargs)
     56        result = apply(_dem2pts, [name_in], kwargs)
    5757
    5858    return result
     
    6868# @param northing_min
    6969# @param northing_max
    70 def _dem2pts(basename_in, basename_out=None, verbose=False,
     70def _dem2pts(name_in, name_out=None, verbose=False,
    7171            easting_min=None, easting_max=None,
    7272            northing_min=None, northing_max=None):
     
    8181    from Scientific.IO.NetCDF import NetCDFFile
    8282
    83     root = basename_in
     83    if name_in[-4:] != '.dem':
     84        raise IOError('Input file %s should be of type .dem.' % name_in)
     85
     86    if name_out != None and basename_out[-4:] != '.pts':
     87        raise IOError('Input file %s should be of type .pts.' % name_out)
     88
     89    root = name_in[:-4]
    8490
    8591    # Get NetCDF
    86     infile = NetCDFFile(root + '.dem', netcdf_mode_r)
    87 
    88     if verbose: log.critical('Reading DEM from %s' % (root + '.dem'))
     92    infile = NetCDFFile(name_in, netcdf_mode_r)
     93
     94    if verbose: log.critical('Reading DEM from %s' % (name_in))
    8995
    9096    ncols = infile.ncols[0]
     
    106112
    107113    # Get output file
    108     if basename_out == None:
     114    if name_out == None:
    109115        ptsname = root + '.pts'
    110116    else:
    111         ptsname = basename_out + '.pts'
     117        ptsname = name_out
    112118
    113119    if verbose: log.critical('Store to NetCDF file %s' % ptsname)
Note: See TracChangeset for help on using the changeset viewer.