Changeset 7814


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

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

Location:
trunk/anuga_core/source/anuga
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/__init__.py

    r7810 r7814  
    9696# File conversion utilities
    9797#-----------------------------
    98 from anuga.file_conversion.file_conversion import sww2obj, dat2obj, \
     98from anuga.file_conversion.file_conversion import sww2obj, \
    9999                    timefile2netcdf, tsh2sww
    100100from anuga.file_conversion.urs2nc import urs2nc
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_boundary_conditions.py

    r7780 r7814  
    415415        from anuga.file_conversion.file_conversion import timefile2netcdf
    416416       
    417         timefile2netcdf(filename, quantity_names = ['stage', 'xmomentum'])
     417        timefile2netcdf(filename+'.txt', quantity_names = ['stage', 'xmomentum'])
    418418
    419419       
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r7800 r7814  
    8585
    8686        #Convert ASCII file to NetCDF (Which is what we really like!)
    87         timefile2netcdf(filename)
     87        timefile2netcdf(filename+'.txt')
    8888
    8989
     
    996996
    997997        #Convert ASCII file to NetCDF (Which is what we really like!)
    998         timefile2netcdf(filename)
     998        timefile2netcdf(filename+'.txt')
    999999
    10001000
     
    10921092
    10931093        #Convert ASCII file to NetCDF (Which is what we really like!)
    1094         timefile2netcdf(filename)       
     1094        timefile2netcdf(filename+'.txt')       
    10951095
    10961096        a = [0.0, 0.0]
     
    11761176
    11771177        # Convert ASCII file to NetCDF (Which is what we really like!)
    1178         timefile2netcdf(filename)       
     1178        timefile2netcdf(filename + '.txt')       
    11791179
    11801180        a = [0.0, 0.0]
  • trunk/anuga_core/source/anuga/file_conversion/__init__.py

    r7778 r7814  
    77    for example:
    88        sww2dem('northbeach.sww', 'outfile.dem')
     9       
     10    Some formats input and output across multiple files. In that case the
     11    convention is so:
     12        urs2nc('northbeach', 'outfile')
     13    Where an array of 3 input files produce 4 output files.
    914"""
    1015
  • trunk/anuga_core/source/anuga/file_conversion/asc2dem.py

    r7804 r7814  
    77                            netcdf_float
    88
    9 ##
    10 # @brief Convert ASC file to DEM file.
    11 # formerly convert_dem_from_ascii2netcdf
    12 # @param basename_in Stem of input filename.
    13 # @param basename_out Stem of output filename.
    14 # @param use_cache ??
    15 # @param verbose True if this function is to be verbose.
    16 # @return
    17 # @note A PRJ file with same stem basename must exist and is used to fix the
    18 #       UTM zone, datum, false northings and eastings.
    19 def asc2dem(basename_in, basename_out=None,
     9def asc2dem(name_in, name_out=None,
    2010                                  use_cache=False,
    2111                                  verbose=False):
     
    3121    138.3698 137.4194 136.5062 135.5558 ..........
    3222
    33     Convert basename_in + '.asc' to NetCDF format (.dem)
     23    Convert name_in (.asc) to NetCDF format (.dem)
    3424    mimicking the ASCII format closely.
    3525
    36     An accompanying file with same basename_in but extension .prj must exist
     26    An accompanying file with same basename but extension .prj must exist
    3727    and is used to fix the UTM zone, datum, false northings and eastings.
    3828
     
    5040    """
    5141
    52     kwargs = {'basename_out': basename_out, 'verbose': verbose}
     42    kwargs = {'name_out': name_out, 'verbose': verbose}
    5343
    5444    if use_cache is True:
    5545        from caching import cache
    56         result = cache(_convert_dem_from_ascii2netcdf, basename_in, kwargs,
    57                        dependencies=[basename_in + '.asc',
    58                                      basename_in + '.prj'],
     46        result = cache(_convert_dem_from_ascii2netcdf, name_in, kwargs,
     47                       dependencies=[name_in,
     48                                     name_in[:-4] + '.prj'],
    5949                       verbose=verbose)
    6050
    6151    else:
    62         result = apply(_convert_dem_from_ascii2netcdf, [basename_in], kwargs)
     52        result = apply(_convert_dem_from_ascii2netcdf, [name_in], kwargs)
    6353
    6454    return result
     
    7060# @param basename_out Stem of output filename.
    7161# @param verbose True if this function is to be verbose.
    72 def _convert_dem_from_ascii2netcdf(basename_in, basename_out = None,
     62def _convert_dem_from_ascii2netcdf(name_in, name_out = None,
    7363                                   verbose = False):
    7464    """Read Digital Elevation model from the following ASCII format (.asc)
     
    8171    from Scientific.IO.NetCDF import NetCDFFile
    8272
    83     root = basename_in
     73    root = name_in[:-4]
    8474
    8575    # Read Meta data
     
    122112    false_northing = float(L[1].strip())
    123113
     114    if name_in[-4:] != '.asc':
     115        raise IOError('Input file %s should be of type .asc.' % name_in)
     116
    124117    #Read DEM data
    125     datafile = open(basename_in + '.asc')
    126 
    127     if verbose: log.critical('Reading DEM from %s' % (basename_in + '.asc'))
     118    datafile = open(name_in)
     119
     120    if verbose: log.critical('Reading DEM from %s' % (name_in))
    128121
    129122    lines = datafile.readlines()
     
    163156    assert len(lines) == nrows + 6
    164157
    165     if basename_out == None:
    166         netcdfname = root + '.dem'
    167     else:
    168         netcdfname = basename_out + '.dem'
     158    if name_out == None:
     159        netcdfname = name_in[:-4]+'.dem'
     160    else:
     161        netcdfname = name_out + '.dem'
    169162
    170163    if verbose: log.critical('Store to NetCDF file %s' % netcdfname)
     
    211204           
    212205        if len(fields) != ncols:
    213             msg = 'Wrong number of columns in file "%s" line %d\n' % (basename_in + '.asc', i)
     206            msg = 'Wrong number of columns in file "%s" line %d\n' % (name_in, i)
    214207            msg += 'I got %d elements, but there should have been %d\n' % (len(fields), ncols)
    215208            raise Exception, msg
  • 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)
  • 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)
  • trunk/anuga_core/source/anuga/file_conversion/esri2sww.py

    r7758 r7814  
    11
    2 ##
    3 # @brief Convert CSIRO ESRI file to an SWW boundary file.
    4 # @param bath_dir
    5 # @param elevation_dir
    6 # @param ucur_dir
    7 # @param vcur_dir
    8 # @param sww_file
    9 # @param minlat
    10 # @param maxlat
    11 # @param minlon
    12 # @param maxlon
    13 # @param zscale
    14 # @param mean_stage
    15 # @param fail_on_NaN
    16 # @param elevation_NaN_filler
    17 # @param bath_prefix
    18 # @param elevation_prefix
    19 # @param verbose
    20 # @note Also convert latitude and longitude to UTM. All coordinates are
    21 #       assumed to be given in the GDA94 datum.
     2
    223def esri2sww(bath_dir,
    234                  elevation_dir,
     
    6041    from anuga.coordinate_transforms.redfearn import redfearn
    6142
     43    if sww_file[-4:] != '.sww':
     44        raise IOError('Output file %s should be of type .sww.' % sww_file)
     45
    6246    # So if we want to change the precision it's done here
    6347    precision = netcdf_float
  • trunk/anuga_core/source/anuga/file_conversion/ferret2sww.py

    r7776 r7814  
    1717
    1818
    19 def ferret2sww(basename_in, basename_out=None,
     19def ferret2sww(basename_in, name_out=None,
    2020               verbose=False,
    2121               minlat=None, maxlat=None,
     
    6464    _assert_lat_long(minlat, maxlat, minlon, maxlon)
    6565
     66    if name_out != None and name_out[-4:] != '.sww':
     67        raise IOError('Output file %s should be of type .sww.' % name_out)
     68
    6669    # Get NetCDF data
    6770    if verbose: log.critical('Reading files %s_*.nc' % basename_in)
     
    7982    file_e = NetCDFFile(basename_in + '_e.nc', netcdf_mode_r) 
    8083
    81     if basename_out is None:
     84    if name_out is None:
    8285        swwname = basename_in + '.sww'
    8386    else:
    84         swwname = basename_out + '.sww'
     87        swwname = name_out
    8588
    8689    # Get dimensions of file_h
  • trunk/anuga_core/source/anuga/file_conversion/file_conversion.py

    r7800 r7814  
    2929
    3030
    31 def sww2obj(basefilename, size):
     31def sww2obj(filename, size):
    3232    """ Convert netcdf based data output to obj
    3333
     
    3939    from Scientific.IO.NetCDF import NetCDFFile
    4040
     41    if filename[-4:] != '.sww':
     42        raise IOError('Output file %s should be of type .sww.' % sww_file)
     43
     44    basefilename = filename[:-4]
     45
    4146    # Get NetCDF
    42     FN = create_filename('.', basefilename, 'sww', size)
    43     log.critical('Reading from %s' % FN)
    44     fid = NetCDFFile(FN, netcdf_mode_r)  #Open existing file for read
     47    nc_fname = create_filename('.', basefilename, 'sww', size)
     48    log.critical('Reading from %s' % nc_fname)
     49    fid = NetCDFFile(nc_fname, netcdf_mode_r)  #Open existing file for read
    4550
    4651    # Get the variables
     
    8186        write_obj(FN, xx, yy, zz)
    8287
    83 
    84 ##
    85 # @brief
    86 # @param basefilename Stem of filename, needs size and extension added.
    87 def dat2obj(basefilename):
    88     """Convert line based data output to obj
    89     FIXME: Obsolete?
    90     """
    91 
    92     import glob, os
    93     from anuga.config import data_dir
    94 
    95     # Get bathymetry and x,y's
    96     lines = open(data_dir+os.sep+basefilename+'_geometry.dat', 'r').readlines()
    97 
    98     M = len(lines)  #Number of lines
    99     x = num.zeros((M,3), num.float)
    100     y = num.zeros((M,3), num.float)
    101     z = num.zeros((M,3), num.float)
    102 
    103     for i, line in enumerate(lines):
    104         tokens = line.split()
    105         values = map(float, tokens)
    106 
    107         for j in range(3):
    108             x[i,j] = values[j*3]
    109             y[i,j] = values[j*3+1]
    110             z[i,j] = values[j*3+2]
    111 
    112     # Write obj for bathymetry
    113     write_obj(data_dir + os.sep + basefilename + '_geometry', x, y, z)
    114 
    115     # Now read all the data files with variable information, combine with
    116     # x,y info and store as obj.
    117 
    118     files = glob.glob(data_dir + os.sep + basefilename + '*.dat')
    119     for filename in files:
    120         log.critical('Processing %s' % filename)
    121 
    122         lines = open(data_dir + os.sep + filename, 'r').readlines()
    123         assert len(lines) == M
    124         root, ext = os.path.splitext(filename)
    125 
    126         # Get time from filename
    127         i0 = filename.find('_time=')
    128         if i0 == -1:
    129             #Skip bathymetry file
    130             continue
    131 
    132         i0 += 6  #Position where time starts
    133         i1 = filename.find('.dat')
    134 
    135         if i1 > i0:
    136             t = float(filename[i0:i1])
    137         else:
    138             raise DataTimeError, 'Hmmmm'
    139 
    140         for i, line in enumerate(lines):
    141             tokens = line.split()
    142             values = map(float,tokens)
    143 
    144             for j in range(3):
    145                 z[i,j] = values[j]
    146 
    147         # Write obj for variable data
    148         write_obj(data_dir + os.sep + basefilename + '_time=%.4f' % t, x, y, z)
    149 
    15088##
    15189# @brief Convert time-series text file to TMS file.
     
    15391# @param quantity_names
    15492# @param time_as_seconds
    155 def timefile2netcdf(filename, quantity_names=None, time_as_seconds=False):
     93def timefile2netcdf(file_text, quantity_names=None, time_as_seconds=False):
    15694    """Template for converting typical text files with time series to
    15795    NetCDF tms file.
     
    180118    from anuga.utilities.numerical_tools import ensure_numeric
    181119
    182     file_text = filename + '.txt'
     120    if file_text[-4:] != '.txt':
     121        raise IOError('Input file %s should be of type .txt.' % file_text)
     122
     123    filename = file_text[:-4]
    183124    fid = open(file_text)
    184125    line = fid.readline()
     
    288229    to check if a tsh/msh file 'looks' good.
    289230    """
     231
     232    if filename[-4:] != '.tsh' and filename[-4:] != '.msh':
     233        raise IOError('Input file %s should be .tsh or .msh.' % name_out)
    290234
    291235    if verbose == True: log.critical('Creating domain from %s' % filename)
  • trunk/anuga_core/source/anuga/file_conversion/sdf2pts.py

    r7758 r7814  
    3838
    3939
    40 def sdf2pts(basename_in,
    41                               basename_out=None,
     40def sdf2pts(name_in,
     41                              name_out=None,
    4242                              verbose=False):
    4343    """Read HEC-RAS Elevation datal from the following ASCII format (.sdf)
     
    9999    from Scientific.IO.NetCDF import NetCDFFile
    100100
    101     root = basename_in
     101    if name_in[-4:] != '.sdf':
     102        raise IOError('Input file %s should be of type .sdf.' % name_in)
     103
     104    if name_out is None:
     105        name_out = name_in[:-4] + '.pts'
     106    elif name_out[-4:] != '.pts':
     107        raise IOError('Input file %s should be of type .pts.' % name_out)
    102108
    103109    # Get ASCII file
    104     infile = open(root + '.sdf', 'r')
     110    infile = open(name_in, 'r')
    105111
    106112    if verbose: log.critical('Reading DEM from %s' % (root + '.sdf'))
     
    170176
    171177    # Get output file, write PTS data
    172     if basename_out == None:
    173         ptsname = root + '.pts'
     178    if name_out == None:
     179        ptsname = name_in[:-4] + '.pts'
    174180    else:
    175         ptsname = basename_out + '.pts'
     181        ptsname = name_out
    176182
    177183    geo_ref = Geo_reference(zone, 0, 0, datum, projection, units)
  • trunk/anuga_core/source/anuga/file_conversion/sww2dem.py

    r7796 r7814  
    2929DEFAULT_BLOCK_SIZE = 10000
    3030
    31 def sww2dem(basename_in, basename_out=None,
     31def sww2dem(name_in, name_out,
    3232            quantity=None, # defaults to elevation
    3333            reduction=None,
     
    4242            origin=None,
    4343            datum='WGS84',
    44             format='ers',
    4544            block_size=None):
    4645    """Read SWW file and convert to Digitial Elevation model format
     
    9897         apply_expression_to_dictionary
    9998
    100     msg = 'Format must be either asc or ers'
    101     assert format.lower() in ['asc', 'ers'], msg
     99    basename_in, in_ext = os.path.splitext(name_in)
     100    basename_out, out_ext = os.path.splitext(name_out)
     101    out_ext = out_ext.lower()
     102
     103    if in_ext != '.sww':
     104        raise IOError('Input format for %s must be .sww' % name_in)
     105
     106    if out_ext not in ['.asc', '.ers']:
     107        raise IOError('Format for %s must be either asc or ers.' % name_out)
    102108
    103109    false_easting = 500000
     
    110116        reduction = max
    111117
    112     if basename_out is None:
    113         basename_out = basename_in + '_%s' % quantity
    114 
    115118    if quantity_formula.has_key(quantity):
    116119        quantity = quantity_formula[quantity]
     
    122125        block_size = DEFAULT_BLOCK_SIZE
    123126
    124     # Read SWW file
    125     swwfile = basename_in + '.sww'
    126     demfile = basename_out + '.' + format
    127 
    128127    # Read sww file
    129128    if verbose:
    130         log.critical('Reading from %s' % swwfile)
    131         log.critical('Output directory is %s' % basename_out)
     129        log.critical('Reading from %s' % name_in)
     130        log.critical('Output directory is %s' % name_out)
    132131
    133132    from Scientific.IO.NetCDF import NetCDFFile
    134     fid = NetCDFFile(swwfile)
     133    fid = NetCDFFile(name_in)
    135134
    136135    #Get extent and reference
     
    168167        log.critical('------------------------------------------------')
    169168        log.critical('Statistics of SWW file:')
    170         log.critical('  Name: %s' % swwfile)
     169        log.critical('  Name: %s' % name_in)
    171170        log.critical('  Reference:')
    172171        log.critical('    Lower left corner: [%f, %f]' % (xllcorner, yllcorner))
     
    212211    if missing_vars:
    213212        msg = ("In expression '%s', variables %s are not in the SWW file '%s'"
    214                % (quantity, swwfile))
     213               % (quantity, name_in))
    215214        raise Exception, msg
    216215
     
    300299
    301300    for i in xrange(nrows):
    302         if format.lower() == 'asc':
     301        if out_ext == '.asc':
    303302            yg = i * cellsize
    304303        else:
     
    336335        grid_values[i] = NODATA_value
    337336
    338     if format.lower() == 'ers':
     337    if out_ext == '.ers':
    339338        # setup ERS header information
    340339        grid_values = num.reshape(grid_values, (nrows, ncols))
     
    362361        import ermapper_grids
    363362
    364         ermapper_grids.write_ermapper_grid(demfile, grid_values, header)
     363        ermapper_grids.write_ermapper_grid(name_out, grid_values, header)
    365364
    366365        fid.close()
     
    383382        prjid.close()
    384383
    385         if verbose: log.critical('Writing %s' % demfile)
    386 
    387         ascid = open(demfile, 'w')
     384        if verbose: log.critical('Writing %s' % name_out)
     385
     386        ascid = open(name_out, 'w')
    388387
    389388        ascid.write('ncols         %d\n' %ncols)
     
    440439    See sww2dem to find out what most of the parameters do.
    441440
     441    basename_in is a path to sww file/s, without the .sww extension.
     442
    442443    Quantities is a list of quantities.  Each quantity will be
    443444    calculated for each sww file.
     
    473474                basename_out = sww_file + '_' + quantity + '_' + extra_name_out
    474475
    475             file_out = sww2dem(dir+os.sep+sww_file, dir+os.sep+basename_out,
     476            file_out = sww2dem(dir+os.sep+sww_file+'.sww',
     477                               dir+os.sep+basename_out,
    476478                               quantity,
    477479                               reduction,
  • 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()
  • trunk/anuga_core/source/anuga/file_conversion/test_2pts.py

    r7776 r7814  
    101101
    102102        #Convert to NetCDF pts
    103         sdf2pts(root)
     103        sdf2pts(root+'.sdf')
    104104
    105105        #Check contents
     
    208208        points = num.concatenate( (x[:,num.newaxis],y[:,num.newaxis]), axis=1 )
    209209        points = num.ascontiguousarray(points)
    210         sww2pts(domain.get_name(),
     210        sww2pts(domain.get_name() + '.sww',
    211211                quantity = 'elevation',
    212212                data_points = points,
     
    223223        points = domain.get_centroid_coordinates()
    224224        #print points
    225         sww2pts(domain.get_name(),
     225        sww2pts(domain.get_name() + '.sww',
    226226                quantity = 'elevation',
    227227                data_points = points,
  • trunk/anuga_core/source/anuga/file_conversion/test_dem2dem.py

    r7778 r7814  
    9999        stencil = num.ones((3,3), num.float) / 9.0
    100100
    101         dem2dem(root, stencil=stencil, cellsize_new=100)
     101        dem2dem(filename, stencil=stencil, cellsize_new=100)
    102102
    103103        # Open decimated NetCDF file
     
    194194        stencil = num.ones((3,3), num.float) / 9.0
    195195
    196         dem2dem(root, stencil=stencil, cellsize_new=100)
     196        dem2dem(filename, stencil=stencil, cellsize_new=100)
    197197
    198198        # Open decimated NetCDF file
  • trunk/anuga_core/source/anuga/file_conversion/test_dem2pts.py

    r7742 r7814  
    7979
    8080        #Convert to NetCDF pts
    81         asc2dem(root)
    82         dem2pts(root, easting_min=2002.0, easting_max=2007.0,
     81        asc2dem(filename)
     82        dem2pts(root+'.dem', easting_min=2002.0, easting_max=2007.0,
    8383                northing_min=3003.0, northing_max=3006.0,
    8484                verbose=False)
     
    199199
    200200        #Convert to NetCDF pts
    201         asc2dem(root)
    202         dem2pts(root, easting_min=2002.0, easting_max=2007.0,
     201        asc2dem(filename)
     202        dem2pts(root+'.dem', easting_min=2002.0, easting_max=2007.0,
    203203                northing_min=3003.0, northing_max=3006.0)
    204204
     
    328328
    329329        #Convert to NetCDF pts
    330         asc2dem(root)
    331         dem2pts(root, easting_min=2002.0, easting_max=2007.0,
     330        asc2dem(filename)
     331        dem2pts(root+'.dem', easting_min=2002.0, easting_max=2007.0,
    332332                northing_min=3003.0, northing_max=3006.0)
    333333
  • trunk/anuga_core/source/anuga/file_conversion/test_sww2dem.py

    r7776 r7814  
    132132
    133133        #Export to ascii/prj files
    134         sww2dem(self.domain.get_name(),
     134        sww2dem(self.domain.get_name()+'.sww',
     135                self.domain.get_name()+'_elevation.asc',
    135136                quantity = 'elevation',
    136137                cellsize = cellsize,
    137138                number_of_decimal_places = 9,
    138                 verbose = self.verbose,
    139                 format = 'asc')
     139                verbose = self.verbose)
    140140
    141141        #Check prj (meta data)
     
    220220        os.remove(ascfile)
    221221
     222        ascfile = self.domain.get_name() + '_depth.asc'
     223        prjfile = self.domain.get_name() + '_depth.prj'
     224
    222225        #Export to ascii/prj files
    223         sww2dem(self.domain.get_name(),
     226        sww2dem(self.domain.get_name()+'.sww',
     227                ascfile,
    224228                quantity = 'depth',
    225229                cellsize = cellsize,
    226230                number_of_decimal_places = 9,
    227                 verbose = self.verbose,
    228                 format = 'asc')
     231                verbose = self.verbose)
    229232       
    230233        #Check asc file
    231         ascfile = self.domain.get_name() + '_depth.asc'
    232         prjfile = self.domain.get_name() + '_depth.prj'
    233234        ascid = open(ascfile)
    234235        lines = ascid.readlines()
     
    353354
    354355        #Export to ascii/prj files
    355         sww2dem(domain.get_name(),
     356        sww2dem(domain.get_name() + '.sww',
     357                domain.get_name() + '_elevation.asc',
    356358                quantity = 'elevation',
    357359                cellsize = cellsize,
    358360                number_of_decimal_places = 9,
    359361                verbose = self.verbose,
    360                 format = 'asc',
    361362                block_size=2)
    362363
     
    525526
    526527        #Export to ascii/prj files
    527         sww2dem(domain.get_name(),
     528        sww2dem(domain.get_name()+'.sww',
     529                domain.get_name() + '_elevation.asc',
    528530                quantity = 'elevation',
    529531                cellsize = cellsize,
    530532                number_of_decimal_places = 9,
    531533                verbose = self.verbose,
    532                 format = 'asc',
    533534                block_size=2)
    534535
     
    720721
    721722        # Export to ascii/prj files
    722         sww2dem(domain.get_name(),
     723        sww2dem(domain.get_name() + '.sww',
     724                domain.get_name() + '_elevation.asc',
    723725                quantity = 'elevation',
    724726                cellsize = cellsize,
     
    728730                northing_min = 6189050,
    729731                northing_max = 6189100,
    730                 verbose = self.verbose,
    731                 format = 'asc')
     732                verbose = self.verbose)
    732733
    733734        fid.close()
     
    867868
    868869        #Export to ascii/prj files
    869         sww2dem(self.domain.get_name(),
     870        sww2dem(self.domain.get_name() + '.sww',
     871                self.domain.get_name() + '_stage.asc',
    870872                quantity = 'stage',
    871873                cellsize = cellsize,
    872874                number_of_decimal_places = 9,
    873                 reduction = min,
    874                 format = 'asc',
    875                 verbose=self.verbose)
     875                reduction = min)
    876876
    877877
     
    974974
    975975        #Export to ascii/prj files
    976         sww2dem(self.domain.get_name(),
     976        sww2dem(self.domain.get_name() + '.sww',
     977                self.domain.get_name() + '_stage.asc',
    977978                quantity = 'stage',
    978979                cellsize = cellsize,
    979980                number_of_decimal_places = 9,
    980981                reduction = 1,
    981                 format = 'asc',
    982982                verbose=self.verbose)
    983983
     
    10821082
    10831083        #Export to ascii/prj files
    1084         sww2dem(self.domain.get_name(),
    1085                 basename_out = 'datatest_depth',
     1084        sww2dem(self.domain.get_name()+'.sww',
     1085                name_out = 'datatest_depth.asc',
    10861086                quantity = 'stage - elevation',
    10871087                cellsize = cellsize,
    10881088                number_of_decimal_places = 9,
    10891089                reduction = min,
    1090                 format = 'asc',
    10911090                verbose = self.verbose)
    10921091
     
    12341233
    12351234        #Export to ascii/prj files
    1236         sww2dem(domain.get_name(),
     1235        sww2dem(domain.get_name()+'.sww',
     1236                domain.get_name()+'_elevation.asc',
    12371237                quantity = 'elevation',
    12381238                cellsize = cellsize,
    12391239                number_of_decimal_places = 9,
    1240                 verbose = self.verbose,
    1241                 format = 'asc')
     1240                verbose = self.verbose)
    12421241
    12431242
     
    13431342
    13441343        #Export to ers files
    1345         sww2dem(self.domain.get_name(),
     1344        outname = self.domain.get_name() + '_elevation.ers'
     1345        sww2dem(self.domain.get_name() + '.sww',
     1346                outname,
    13461347                quantity = 'elevation',
    13471348                cellsize = cellsize,
    13481349                number_of_decimal_places = 9,
    13491350                NODATA_value = NODATA_value,
    1350                 verbose = self.verbose,
    1351                 format = 'ers')
     1351                verbose = self.verbose)
    13521352
    13531353        #Check header data
    13541354        from ermapper_grids import read_ermapper_header, read_ermapper_data
    13551355
    1356         header = read_ermapper_header(self.domain.get_name() + '_elevation.ers')
    1357         #print header
     1356        header = read_ermapper_header(outname)
     1357
    13581358        assert header['projection'].lower() == '"utm-56"'
    13591359        assert header['datum'].lower() == '"wgs84"'
  • trunk/anuga_core/source/anuga/file_conversion/test_urs2sts.py

    r7778 r7814  
    6969                                      va=va)
    7070
     71        sts_file = base_name + '.sts'
     72
    7173        urs2sts(base_name,
    72                 basename_out=base_name,
     74                basename_out=sts_file,
    7375                mean_stage=tide,verbose=False)
    7476
    75         # now I want to check the sts file ...
    76         sts_file = base_name + '.sts'
    7777
    7878        #Let's interigate the sww file
     
    184184                                           va=va)
    185185
     186        sts_file = base_name + '.sts'
     187
    186188        urs2sts(base_name,
    187                 basename_out=base_name,
     189                basename_out=sts_file,
    188190                central_meridian=123,
    189191                mean_stage=tide,
    190192                verbose=False)
    191 
    192         # now I want to check the sts file ...
    193         sts_file = base_name + '.sts'
    194193
    195194        #Let's interigate the sww file
  • trunk/anuga_core/source/anuga/shallow_water/test_forcing.py

    r7778 r7814  
    248248        fid.close()
    249249
    250         timefile2netcdf(filename)
     250        timefile2netcdf(filename + '.txt')
    251251        os.remove(filename + '.txt')
    252252
     
    337337        fid.close()
    338338
    339         timefile2netcdf(filename, time_as_seconds=True)
     339        timefile2netcdf(filename + '.txt', time_as_seconds=True)
    340340        os.remove(filename + '.txt')
    341341
  • trunk/anuga_core/source/anuga/shallow_water/test_forcing_terms.py

    r7743 r7814  
    543543
    544544        # Convert ASCII file to NetCDF (Which is what we really like!)
    545         timefile2netcdf(filename)
     545        timefile2netcdf(filename + '.txt')
    546546        os.remove(filename + '.txt')
    547547
     
    633633
    634634        # Convert ASCII file to NetCDF (Which is what we really like!)
    635         timefile2netcdf(filename, time_as_seconds=True)
     635        timefile2netcdf(filename + '.txt', time_as_seconds=True)
    636636        os.remove(filename + '.txt')
    637637
Note: See TracChangeset for help on using the changeset viewer.