Changeset 5745


Ignore:
Timestamp:
Sep 8, 2008, 3:55:57 PM (16 years ago)
Author:
ole
Message:

Arranged for permutation passed in to urs2sts to also be stored in
the NetCDF file.
Updated tests and user manual as well.

Location:
anuga_core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/anuga_user_manual.tex

    r5744 r5745  
    30303030\begin{itemize}
    30313031    \item \code{x} and \code{y}: coordinates of the points, represented as Numeric arrays
     3032    \item \code{permutation}: Original indices of the points as specified by
     3033    the optional \code{ordering\_file}
     3034    (see the function \code{urs2sts} in Section \ref{sec:basicfileconversions}).
     3035   
    30323036    \item \code{elevation}, a Numeric array storing bed-elevations
    30333037    % Refer here to the example to be provided in describing the simple example
     
    31783182  Module: \module{shallow\_water.data\_manager}
    31793183
    3180   Takes urs data in (timeseries data in mux2 format) and converts it to STS format.
     3184  Takes urs data in (timeseries data in mux2 format) and converts it to STS format. The optional filename \code{ordering\_filename} specifies the permutation of indices of points to select along with their longitudes and latitudes. This permutation will also be
     3185  stored in the STS file. If absent, all points are taken and the permutation will be trivial, i.e. $0, 1, \ldots, N-1$, where $N$ is the total number of points stored. 
    31813186  \end{funcdesc}
    31823187
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r5736 r5745  
    52075207    number_of_longitudes = longitudes.shape[0] # Number longitudes
    52085208
     5209   
     5210    # The permutation vector of contains original indices
     5211    # as given in ordering file or None in which case points
     5212    # are assigned the trivial indices enumerating them from
     5213    # 0 to number_of_points-1
     5214    if permutation is None:
     5215        permutation = arange(number_of_points, typecode=Int)
     5216   
     5217   
    52095218    # NetCDF file definition
    52105219    outfile = NetCDFFile(stsname, 'w')
     
    52545263
    52555264    elevation = resize(elevation,outfile.variables['elevation'][:].shape)
     5265    outfile.variables['permutation'][:] = permutation
    52565266    outfile.variables['x'][:] = x - geo_ref.get_xllcorner()
    52575267    outfile.variables['y'][:] = y - geo_ref.get_yllcorner()
     
    57685778
    57695779        # Variable definitions
     5780        outfile.createVariable('permutation', Int, ('number_of_points',))       
    57705781        outfile.createVariable('x', sts_precision, ('number_of_points',))
    57715782        outfile.createVariable('y', sts_precision, ('number_of_points',))
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r5734 r5745  
    68226822        elevation = fid.variables['elevation'][:]
    68236823        time=fid.variables['time'][:]+fid.starttime
     6824       
     6825       
     6826        # Check that stored permutation is as per default
     6827        permutation = range(len(x))
     6828        stored_permutation = fid.variables['permutation'][:]
     6829        msg = 'Permutation was not stored correctly. I got '
     6830        msg += str(stored_permutation)
     6831        assert allclose(stored_permutation, permutation), msg       
    68246832
    68256833        # get quantity data from sts file
     
    70207028        # Note, the sts info is not gridded.  It is point data.
    70217029        fid = NetCDFFile(sts_file)
     7030       
     7031        # Check that original indices have been stored
     7032        stored_permutation = fid.variables['permutation'][:]
     7033        msg = 'Permutation was not stored correctly. I got '
     7034        msg += str(stored_permutation)
     7035        assert allclose(stored_permutation, permutation), msg
     7036       
    70227037
    70237038        # Make x and y absolute
     
    73597374
    73607375        #------------------------------------------------------------
    7361         # Now read the mux files one by one with out weights and test
     7376        # Now read the mux files one by one without weights and test
    73627377       
    73637378        # Call urs2sts with mux file #0
     
    73727387        fid = NetCDFFile(sts_file)
    73737388
     7389        # Check that original indices have been stored
     7390        stored_permutation = fid.variables['permutation'][:]
     7391        msg = 'Permutation was not stored correctly. I got '
     7392        msg += str(stored_permutation)
     7393        assert allclose(stored_permutation, permutation), msg
     7394       
     7395
     7396       
     7397       
    73747398        # Make x and y absolute
    73757399        x = fid.variables['x'][:]
     
    74767500        sts_file = base_nameI + '.sts'
    74777501        fid = NetCDFFile(sts_file)
    7478 
     7502       
     7503        # Check that original indices have been stored
     7504        stored_permutation = fid.variables['permutation'][:]
     7505        msg = 'Permutation was not stored correctly. I got '
     7506        msg += str(stored_permutation)
     7507        assert allclose(stored_permutation, permutation), msg
     7508       
    74797509        # Make x and y absolute
    74807510        x = fid.variables['x'][:]
Note: See TracChangeset for help on using the changeset viewer.