Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/moving.py @ 1250:77fbd0e2ba7d
dltrack works with moving average filtering
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 15 Feb 2024 22:04:35 -0500 |
| parents | 2aa56b101041 |
| children | fe35473acee3 |
comparison
equal
deleted
inserted
replaced
| 1249:2aa56b101041 | 1250:77fbd0e2ba7d |
|---|---|
| 988 def __mul__(self, alpha): | 988 def __mul__(self, alpha): |
| 989 '''Returns a new trajectory of the same length''' | 989 '''Returns a new trajectory of the same length''' |
| 990 return Trajectory([[alpha*x for x in self.getXCoordinates()], | 990 return Trajectory([[alpha*x for x in self.getXCoordinates()], |
| 991 [alpha*y for y in self.getYCoordinates()]]) | 991 [alpha*y for y in self.getYCoordinates()]]) |
| 992 | 992 |
| 993 def filterMovingWindow(self, halfWidth, mode = 'valid'): | 993 def filterMovingWindow(self, halfWidth): |
| 994 '''Returns a new Trajectory obtained after the smoothing of the input by a moving average''' | 994 '''Returns a new Trajectory obtained after the smoothing of the input by a moving average''' |
| 995 return Trajectory([utils.filterMovingWindow(self.positions[0], halfWidth, mode), | 995 return Trajectory([utils.filterMovingWindow(self.positions[0], halfWidth), |
| 996 utils.filterMovingWindow(self.positions[1], halfWidth, mode)]) | 996 utils.filterMovingWindow(self.positions[1], halfWidth)]) |
| 997 | 997 |
| 998 def differentiate(self, doubleLastPosition = False): | 998 def differentiate(self, doubleLastPosition = False): |
| 999 diff = Trajectory() | 999 diff = Trajectory() |
| 1000 for i in range(1, self.length()): | 1000 for i in range(1, self.length()): |
| 1001 diff.addPosition(self[i]-self[i-1]) | 1001 diff.addPosition(self[i]-self[i-1]) |
