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/dem2dem.py

    r7778 r7814  
    66from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_float
    77
    8 def dem2dem(basename_in, stencil, cellsize_new, basename_out=None,
     8def dem2dem(name_in, stencil, cellsize_new, name_out=None,
    99                 verbose=False):
    1010    """Read Digitial Elevation model from the following NetCDF format (.dem)
     
    2626    from Scientific.IO.NetCDF import NetCDFFile
    2727
    28     root = basename_in
    29     inname = root + '.dem'
     28    if name_in[-4:] != '.dem':
     29        raise IOError('Input file %s should be of type .dem.' % name_in)
     30
     31    if name_out != None and basename_out[-4:] != '.dem':
     32        raise IOError('Input file %s should be of type .dem.' % name_out)
    3033
    3134    #Open existing netcdf file to read
    32     infile = NetCDFFile(inname, netcdf_mode_r)
     35    infile = NetCDFFile(name_in, netcdf_mode_r)
    3336
    3437    if verbose: log.critical('Reading DEM from %s' % inname)
     
    5154
    5255    #Get output file name
    53     if basename_out == None:
    54         outname = root + '_' + repr(cellsize_new) + '.dem'
     56    if name_out == None:
     57        outname = name_in[:-4] + '_' + repr(cellsize_new) + '.dem'
    5558    else:
    56         outname = basename_out + '.dem'
     59        outname = name_out
    5760
    5861    if verbose: log.critical('Write decimated NetCDF file to %s' % outname)
Note: See TracChangeset for help on using the changeset viewer.