diff python/moving.py @ 66:56fe4ef1377e

generalized map combination to different functions
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 07 Nov 2010 01:34:43 -0500
parents 75cf537b8d88
children ded58c424783
line wrap: on
line diff
--- a/python/moving.py	Sun Nov 07 01:09:50 2010 -0500
+++ b/python/moving.py	Sun Nov 07 01:34:43 2010 -0500
@@ -407,11 +407,11 @@
         indicatorMap[k] = mean(indicatorMap[k])
     return indicatorMap
 
-def combineIndicatorMaps(maps, squareSize):
+def combineIndicatorMaps(maps, squareSize, combinationFunction):
     '''Puts many indicator maps together 
     (averaging the values in each cell 
     if more than one maps has a value)'''
-    from numpy import mean
+    #from numpy import mean
     indicatorMap = {}
     for m in maps:
         for k,v in m.iteritems():
@@ -420,7 +420,7 @@
             else:
                 indicatorMap[k] = [v]
     for k in indicatorMap.keys():
-        indicatorMap[k] = mean(indicatorMap[k])
+        indicatorMap[k] = combinationFunction(indicatorMap[k])
     return indicatorMap
 
 if __name__ == "__main__":