comparison trafficintelligence/indicators.py @ 1029:c6cf75a2ed08

reorganization of imports
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 18 Jun 2018 22:50:59 -0400
parents cc5cb04b04b0
children b1ba6d44fcb9
comparison
equal deleted inserted replaced
1028:cc5cb04b04b0 1029:c6cf75a2ed08
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 '''Class for indicators, temporal indicators, and safety indicators''' 2 '''Class for indicators, temporal indicators, and safety indicators'''
3 3
4 from trafficintelligence import moving
5 #import matplotlib.nxutils as nx
6 from matplotlib.pyplot import plot, ylim 4 from matplotlib.pyplot import plot, ylim
7 from matplotlib.pylab import find 5 from matplotlib.pylab import find
8 from numpy import array, arange, mean, floor, mean 6 from numpy import array, arange, mean, floor, mean
9 from scipy import percentile 7 from scipy import percentile
8
9 from trafficintelligence import moving
10 from trafficintelligence.utils import LCSS as utilsLCSS
10 11
11 def multivariateName(indicatorNames): 12 def multivariateName(indicatorNames):
12 return '_'.join(indicatorNames) 13 return '_'.join(indicatorNames)
13 14
14 # need for a class representing the indicators, their units, how to print them in graphs... 15 # need for a class representing the indicators, their units, how to print them in graphs...
119 nDimensions = len(x) 120 nDimensions = len(x)
120 for i in range(nDimensions): 121 for i in range(nDimensions):
121 if l1Distance(x[i], y[i]) <= thresholds[i]: 122 if l1Distance(x[i], y[i]) <= thresholds[i]:
122 n += 1 123 n += 1
123 return n >= nDimensions*proportionMatching 124 return n >= nDimensions*proportionMatching
124
125 from utils import LCSS as utilsLCSS
126 125
127 class LCSS(utilsLCSS): 126 class LCSS(utilsLCSS):
128 '''Adapted LCSS class for indicators, same pattern''' 127 '''Adapted LCSS class for indicators, same pattern'''
129 def __init__(self, similarityFunc, delta = float('inf'), minLength = 0, aligned = False, lengthFunc = min): 128 def __init__(self, similarityFunc, delta = float('inf'), minLength = 0, aligned = False, lengthFunc = min):
130 utilsLCSS.__init__(self, similarityFunc = similarityFunc, delta = delta, aligned = aligned, lengthFunc = lengthFunc) 129 utilsLCSS.__init__(self, similarityFunc = similarityFunc, delta = delta, aligned = aligned, lengthFunc = lengthFunc)