def aggregate_over_time_interval(
        time,
        values,
        time_point_to_id,
        aggregator):
    assert all([len(time) == len(values[i]) for i in range(len(values))])

    # List with time point ids.
    time_point_ids = [time_point_to_id(time[i]) for i in xrange(len(time))]

    # Dictionary with per time point id a list. This list contains for each
    # list in *values* another list. This list contains for each time point
    # id an empty list. This last list will recieve values from *values*.
    # Afterwords, these lists will be aggregated to single values per time
    # points.
    result = {
        # For each time point id...
        #   and for each array in values...
        #     an empty list.
        time_point_id: [[] for i in xrange(len(values))] for time_point_id in
            time_point_ids
    }

    for i in xrange(len(time)):
        time_point_id = time_point_to_id(time[i])
        for j in xrange(len(values)):
            result[time_point_id][j].append(values[j][i])

    for time_point_id in result:
        result[time_point_id] = [aggregator(numpy.array(
            result[time_point_id][i], dtype=values[i].dtype)) for i in \
                xrange(len(values))]

    result_time = result.keys()
    result_values = [[] for i in xrange(len(values))]

    for i in xrange(len(values)):
        result_values[i] = [result[time_point_id][i] for time_point_id in
            result]

    return result_time, result_values
Aggregate *values* over time, using *aggregator*.
dataset/ETHPy150Open Esri/solutions-geoprocessing-toolbox/suitability/toolboxes/scripts/MultidimensionSupplementalTools/MultidimensionSupplementalTools/Scripts/mds/math.py/aggregate_over_time_interval