Changeset 7617


Ignore:
Timestamp:
Feb 8, 2010, 1:58:13 PM (14 years ago)
Author:
habili
Message:

sww2dem no longer uses timestep. Timestep and reduction have now been combined.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r7602 r7617  
    20162016def export_grid(basename_in, extra_name_out=None,
    20172017                quantities=None, # defaults to elevation
    2018                 timestep=None,
    20192018                reduction=None,
    20202019                cellsize=10,
     
    20672066            file_out = sww2dem(dir+sep+sww_file, dir+sep+basename_out,
    20682067                               quantity,
    2069                                timestep,
    20702068                               reduction,
    20712069                               cellsize,
     
    21972195def sww2dem(basename_in, basename_out=None,
    21982196            quantity=None, # defaults to elevation
    2199             timestep=None,
    22002197            reduction=None,
    22012198            cellsize=10,
     
    22482245    if timestep (an index) is given, output quantity at that timestep
    22492246
    2250     if reduction is given use that to reduce quantity over all timesteps.
     2247    if reduction is given and its an index, output quantity at that timestep. If reduction is given
     2248    and is a built in function, use that to reduce quantity over all timesteps.
    22512249
    22522250    datum
     
    22582256
    22592257    import sys
     2258    import types
    22602259
    22612260    from anuga.utilities.polygon import inside_polygon, outside_polygon, \
     
    22722271    if quantity is None:
    22732272        quantity = 'elevation'
    2274 
    2275     # FIXME (Ole): I reckon we need a check so that
    2276     # reduction and timestep cannot both be set.   
    2277     # if reduction is not None and timestep is not None:
    2278     #     msg = 'Either reduction or timestep must be set'
    2279     #     msg += ' but not both.'
    2280     #     raise Exception(msg)
    2281    
    22822273   
    22832274    if reduction is None:
     
    23122303    y = fid.variables['y'][:]
    23132304    volumes = fid.variables['volumes'][:]
    2314     if timestep is not None:
    2315         times = fid.variables['time'][timestep]
     2305    if type(reduction) is not types.BuiltinFunctionType:
     2306        times = fid.variables['time'][reduction]
    23162307    else:
    23172308        times = fid.variables['time'][:]
     
    23452336        log.critical('  Reference:')
    23462337        log.critical('    Lower left corner: [%f, %f]' % (xllcorner, yllcorner))
    2347         if timestep is not None:
     2338        if type(reduction) is not types.BuiltinFunctionType:
    23482339            log.critical('    Time: %f' % times)
    23492340        else:
     
    23542345        log.critical('    y [m] in [%f, %f], len(y) == %d'
    23552346                     % (num.min(y), num.max(y), len(y.flat)))
    2356         if timestep is not None:
     2347        if type(reduction) is not types.BuiltinFunctionType:
    23572348            log.critical('    t [s] = %f, len(t) == %d' % (times, 1))
    23582349        else:
     
    23642355        for name in ['stage', 'xmomentum', 'ymomentum']:
    23652356            q = fid.variables[name][:].flatten()
    2366             if timestep is not None:
    2367                 q = q[timestep*len(x):(timestep+1)*len(x)]
     2357            if type(reduction) is not types.BuiltinFunctionType:
     2358                q = q[reduction*len(x):(reduction+1)*len(x)]
    23682359            if verbose: log.critical('    %s in [%f, %f]'
    23692360                                     % (name, min(q), max(q)))
     
    24112402            new_res = num.zeros(res.shape[1], num.float)
    24122403            for k in xrange(res.shape[1]):
    2413                 if reduction is None:
    2414                     new_res[k] = res[timestep,k]
     2404                if type(reduction) is not types.BuiltinFunctionType:
     2405                    new_res[k] = res[reduction,k]
    24152406                else:
    24162407                    new_res[k] = reduction(res[:,k])
     
    26122603def sww2asc(basename_in, basename_out = None,
    26132604            quantity = None,
    2614             timestep = None,
    26152605            reduction = None,
    26162606            cellsize = 10,
     
    26222612            basename_out = basename_out,
    26232613            quantity = quantity,
    2624             timestep = timestep,
    26252614            reduction = reduction,
    26262615            cellsize = cellsize,
     
    26462635def sww2ers(basename_in, basename_out=None,
    26472636            quantity=None,
    2648             timestep=None,
    26492637            reduction=None,
    26502638            cellsize=10,
     
    26562644            basename_out=basename_out,
    26572645            quantity=quantity,
    2658             timestep=timestep,
    26592646            reduction=reduction,
    26602647            cellsize=cellsize,
Note: See TracChangeset for help on using the changeset viewer.