def METHOD_NAME (step, table, map):
    """Reads a pcraster.tbl file for step and assigns using the map in map.
    The behaviour of is a bit similar to the timeinputSparse
    command but in this case for both the tbl file and the map file.
    Input: step (int), table (string, path, without the .tbl extension), map
          (ordinal map, without the .map extension)
    How to create your maps/tables:
    if the maps for the timstep is not found the
    defaultmap (without the step appended) is returned or the last map
    that has been found.
    How to use this:
    - if you create the following maps and step ranges from 1 to 400 and
    the map name is "LAI":
    LAI.map
    LAI10.map
    LAI120.map
    LAI300.map
    - LAI.map will be use for step between 1 and 9 (default)
    - LAI10.map will be used between 10 and 119
    etc....
    The same holds for the tables.
    """
    global debug
    if not hasattr(METHOD_NAME,"_tableToMap_LastTbl"):
        _tableToMap_LastTbl = {}
        _tableToMap_LastMap = {}
    # construct filenames
    fname_map = map + str(step) + ".map"
    fname_tbl = table + str(step) + ".tbl"
    if os.path.exists(fname_map):
        print "found: " + fname_map
        METHOD_NAME._tableToMap_LastMap[map] = step
    if os.path.exists(fname_tbl):
        print "found: " + fname_tbl
        METHOD_NAME._tableToMap_LastTbl[table] = step
    if METHOD_NAME._tableToMap_LastTbl.has_key(table) == False:
        fname_tbl = table + ".tbl"
    else:
        fname_tbl = table + str(METHOD_NAME._tableToMap_LastTbl[table]) + ".tbl"
    if METHOD_NAME._tableToMap_LastMap.has_key(map) == False:
        fname_map = map + ".map"
    else:
        fname_map = map + str(METHOD_NAME._tableToMap_LastMap[map]) + ".map"
    rmat = lookupscalar(str(fname_tbl),str(fname_map))
    return rmat