Ignore:
Timestamp:
Nov 1, 2006, 10:58:50 AM (17 years ago)
Author:
ole
Message:

Added time_thinning to Interpolation_function and improved diagnostics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r3850 r3900  
    1313
    1414def file_function(filename,
    15                   domain = None,
    16                   quantities = None,
    17                   interpolation_points = None,
    18                   verbose = False,
    19                   use_cache = False):
     15                  domain=None,
     16                  quantities=None,
     17                  interpolation_points=None,
     18                  time_thinning=1,
     19                  verbose=False,
     20                  use_cache=False):
    2021    """Read time history of spatial data from NetCDF file and return
    2122    a callable object.
     
    5859
    5960
     61    # Build arguments and keyword arguments for use with caching or apply.
     62    args = (filename,)
     63   
     64    kwargs = {'domain': domain,
     65              'quantities': quantities,
     66              'interpolation_points': interpolation_points,
     67              'time_thinning': time_thinning,                   
     68              'verbose': verbose}
     69
     70
     71    # Call underlying engine with or without caching
    6072    if use_cache is True:
    6173        try:
     
    6678            raise msg
    6779
    68 
    6980        f = cache(_file_function,
    70                   filename,
    71                   {'domain': domain,
    72                    'quantities': quantities,
    73                    'interpolation_points': interpolation_points,
    74                    'verbose': verbose},
    75                   dependencies = [filename],
    76                   compression = False,
    77                   verbose = verbose)
    78         #FIXME (Ole): Pass cache arguments, such as compression, in some sort of
    79         #structure
     81                  args, kwargs,
     82                  dependencies=[filename],
     83                  compression=False,                 
     84                  verbose=verbose)
     85
     86    else:
     87        f = apply(_file_function,
     88                  args, kwargs)
     89
     90
     91    #FIXME (Ole): Pass cache arguments, such as compression, in some sort of
     92    #structure
    8093       
    81     else:
    82         f = _file_function(filename,
    83                            domain,
    84                            quantities,
    85                            interpolation_points,
    86                            verbose)           
    8794
    8895    return f
     
    9198
    9299def _file_function(filename,
    93                    domain = None,
    94                    quantities = None,
    95                    interpolation_points = None,
    96                    verbose = False):
     100                   domain=None,
     101                   quantities=None,
     102                   interpolation_points=None,
     103                   time_thinning=1,                                               
     104                   verbose=False):
    97105    """Internal function
    98106   
     
    133141        return get_netcdf_file_function(filename, domain, quantities,
    134142                                        interpolation_points,
     143                                        time_thinning=time_thinning,
    135144                                        verbose = verbose)
    136145    else:
     
    143152                             quantity_names=None,
    144153                             interpolation_points=None,
     154                             time_thinning=1,                             
    145155                             verbose = False):
    146156    """Read time history of spatial data from NetCDF sww file and
     
    238248    time = fid.variables['time'][:]   
    239249
     250    # Get time independent stuff
    240251    if spatial:
    241252        #Get origin
     
    296307       
    297308   
    298     #Produce values for desired data points at
    299     #each timestep
    300 
     309    # Produce values for desired data points at
     310    # each timestep for each quantity
    301311    quantities = {}
    302312    for i, name in enumerate(quantity_names):
     
    318328                                  triangles,
    319329                                  interpolation_points,
     330                                  time_thinning=time_thinning,
    320331                                  verbose=verbose)
    321332
Note: See TracChangeset for help on using the changeset viewer.