Mercurial > hg > nsaunier > traffic-intelligence
comparison python/indicators.py @ 341:2f39c4ed0b62
first version of indicator saving to sqlite
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 20 Jun 2013 14:31:24 -0400 |
| parents | 1046b7346886 |
| children | 2db4e76599a1 |
comparison
equal
deleted
inserted
replaced
| 340:1046b7346886 | 341:2f39c4ed0b62 |
|---|---|
| 16 | 16 |
| 17 it should have more information like name, unit''' | 17 it should have more information like name, unit''' |
| 18 | 18 |
| 19 def __init__(self, name, values, timeInterval=None, maxValue = None): | 19 def __init__(self, name, values, timeInterval=None, maxValue = None): |
| 20 self.name = name | 20 self.name = name |
| 21 self.isCosine = (name.find('Cosine') >= 0) | |
| 22 if timeInterval: | 21 if timeInterval: |
| 23 assert len(values) == timeInterval.length() | 22 assert len(values) == timeInterval.length() |
| 24 self.timeInterval = timeInterval | 23 self.timeInterval = timeInterval |
| 25 self.values = {} | 24 self.values = {} |
| 26 for i in xrange(int(round(self.timeInterval.length()))): | 25 for i in xrange(int(round(self.timeInterval.length()))): |
| 66 self.iterInstantNum += 1 | 65 self.iterInstantNum += 1 |
| 67 return self.getIthValue(self.iterInstantNum-1) | 66 return self.getIthValue(self.iterInstantNum-1) |
| 68 | 67 |
| 69 def getTimeInterval(self): | 68 def getTimeInterval(self): |
| 70 return self.timeInterval | 69 return self.timeInterval |
| 70 | |
| 71 def getName(self): | |
| 72 return self.name | |
| 71 | 73 |
| 72 def getValues(self): | 74 def getValues(self): |
| 73 return [self.__getitem__(t) for t in self.timeInterval] | 75 return [self.__getitem__(t) for t in self.timeInterval] |
| 74 | 76 |
| 75 def plot(self, options = '', xfactor = 1., **kwargs): | 77 def plot(self, options = '', xfactor = 1., **kwargs): |
