Ignore:
Timestamp:
Feb 14, 2006, 5:19:29 PM (19 years ago)
Author:
ole
Message:

Pushed caching into conversion functions and beautified the Sydney scenario

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r2344 r2407  
    10741074
    10751075
    1076 def dem2pts(basename_in, basename_out=None, verbose=False,
     1076def dem2pts(basename_in, basename_out=None,
    10771077            easting_min=None, easting_max=None,
    1078             northing_min=None, northing_max=None):
     1078            northing_min=None, northing_max=None,
     1079            use_cache=False, verbose=False,):
    10791080    """Read Digitial Elevation model from the following NetCDF format (.dem)
    10801081
     
    10931094    points:  (Nx2) Float array
    10941095    elevation: N Float array
     1096    """
     1097
     1098
     1099
     1100    kwargs = {'basename_out': basename_out, 
     1101              'easting_min': easting_min,
     1102              'easting_max': easting_max,
     1103              'northing_min': northing_min,
     1104              'northing_max': northing_max,
     1105              'verbose': verbose}
     1106
     1107    if use_cache is True:
     1108        from caching import cache
     1109        result = cache(_dem2pts, basename_in, kwargs,
     1110                       dependencies = [basename_in + '.dem'],
     1111                       verbose = verbose)
     1112
     1113    else:
     1114        result = apply(_dem2pts, [basename_in], kwargs)
     1115       
     1116    return result
     1117
     1118
     1119def _dem2pts(basename_in, basename_out=None, verbose=False,
     1120            easting_min=None, easting_max=None,
     1121            northing_min=None, northing_max=None):
     1122    """Read Digitial Elevation model from the following NetCDF format (.dem)
     1123
     1124    Internal function. See public function dem2pts for details.   
    10951125    """
    10961126
     
    18311861
    18321862
    1833 
    18341863def convert_dem_from_ascii2netcdf(basename_in, basename_out = None,
    1835                                   verbose=False):
    1836     """Read Digitial Elevation model from the following ASCII format (.asc)
     1864                                  use_cache = False,
     1865                                  verbose = False):
     1866    """Read Digitial Elevation model from the following ASCII format (.asc)   
    18371867
    18381868    Example:
     
    18641894    Yshift        10000000.0000000000
    18651895    Parameters
     1896    """
     1897
     1898
     1899
     1900    kwargs = {'basename_out': basename_out, 'verbose': verbose}
     1901
     1902    if use_cache is True:
     1903        from caching import cache
     1904        result = cache(_convert_dem_from_ascii2netcdf, basename_in, kwargs,
     1905                       dependencies = [basename_in + '.asc'],
     1906                       verbose = verbose)
     1907
     1908    else:
     1909        result = apply(_convert_dem_from_ascii2netcdf, [basename_in], kwargs)
     1910       
     1911    return result
     1912
     1913   
     1914   
     1915
     1916
     1917
     1918def _convert_dem_from_ascii2netcdf(basename_in, basename_out = None,
     1919                                  verbose = False):
     1920    """Read Digitial Elevation model from the following ASCII format (.asc)
     1921
     1922    Internal function. See public function convert_dem_from_ascii2netcdf for details.
    18661923    """
    18671924
Note: See TracChangeset for help on using the changeset viewer.