changeset 375:2ea8584aa80a

making indicator LCSS work
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 17 Jul 2013 01:29:25 -0400
parents a7af3519687e
children 2e6b8610bcaa
files python/indicators.py python/utils.py
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/python/indicators.py	Wed Jul 17 00:50:44 2013 -0400
+++ b/python/indicators.py	Wed Jul 17 01:29:25 2013 -0400
@@ -74,14 +74,14 @@
     def getValues(self):
         return [self.__getitem__(t) for t in self.timeInterval]
 
-    def plot(self, options = '', xfactor = 1., **kwargs):
+    def plot(self, options = '', xfactor = 1., timeShift = 0, **kwargs):
         from matplotlib.pylab import plot,ylim
         if self.getTimeInterval().length() == 1:
             marker = 'o'
         else:
             marker = ''
         time = sorted(self.values.keys())
-        plot([x/xfactor for x in time], [self.values[i] for i in time], options+marker, **kwargs)
+        plot([(x+timeShift)/xfactor for x in time], [self.values[i] for i in time], options+marker, **kwargs)
         if self.maxValue:
             ylim(ymax = self.maxValue)
 	
@@ -110,9 +110,9 @@
     def __init__(self, threshold, delta = float('inf'), aligned = False, lengthFunc = min):
         utilsLCSS.__init__(self, lambda x,y: (distanceForLCSS(x,y) <= threshold), delta, aligned, lengthFunc)
 
-    def compute(self, indicator1, indicator2):
+    def compute(self, indicator1, indicator2, computeSubSequence = False):
         if indicator1 and indicator2:
-            return self._compute(indicator1.getValues(), indicator2.getValues())
+            return self._compute(indicator1.getValues(), indicator2.getValues(), computeSubSequence)
         else:
             return 0
 
--- a/python/utils.py	Wed Jul 17 00:50:44 2013 -0400
+++ b/python/utils.py	Wed Jul 17 01:29:25 2013 -0400
@@ -289,7 +289,7 @@
         '''get methods are to be shadowed in child classes '''
         return self._compute(l1, l2, computeSubSequence)
 
-    def computeAlignement(self):
+    def computeAlignment(self):
         from numpy import mean
         return mean([j-i for i,j in self.subSequenceIndices])
 
@@ -297,14 +297,14 @@
         ''' compute the normalized LCSS
         ie, the LCSS divided by the min or mean of the indicator lengths (using lengthFunc)
         lengthFunc = lambda x,y:float(x,y)/2'''
-        return float(self.compute(l1, l2))/self.lengthFunc(len(l1), len(l2))
+        return float(self._compute(l1, l2))/self.lengthFunc(len(l1), len(l2))
 
     def computeNormalized(self, l1, l2):
         return self._computeNormalized(l1, l2)
 
     def _computeDistance(self, l1, l2):
         ''' compute the LCSS distance'''
-        return 1-self.computeNormalized(l1, l2)
+        return 1-self._computeNormalized(l1, l2)
 
     def computeDistance(self, l1, l2):
         return self._computeDistance(l1, l2)