Mercurial Hosting > traffic-intelligence
comparison python/utils.py @ 549:b5525249eda1
Merged in mohamedgomaa/trafficintelligence (pull request #7)
add some functions for behaviour analysis and corrected a few bugs
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 08 Jul 2014 16:32:09 -0400 |
parents | 97c5fef5b2d6 |
children | 3622a5653ee9 |
comparison
equal
deleted
inserted
replaced
545:9816fab353f3 | 549:b5525249eda1 |
---|---|
244 return bound1 <= x <= bound2 or bound2 <= x<= bound1 | 244 return bound1 <= x <= bound2 or bound2 <= x<= bound1 |
245 | 245 |
246 def crossProduct(l1, l2): | 246 def crossProduct(l1, l2): |
247 return l1[0]*l2[1]-l1[1]*l2[0] | 247 return l1[0]*l2[1]-l1[1]*l2[0] |
248 | 248 |
249 def filterMovingWindow(input, halfWidth): | 249 def filterMovingWindow(inputSignal, halfWidth): |
250 '''Returns an array obtained after the smoothing of the input by a moving average | 250 '''Returns an array obtained after the smoothing of the input by a moving average |
251 The first and last points are copied from the original.''' | 251 The first and last points are copied from the original.''' |
252 from numpy import ones,convolve,array | |
252 width = float(halfWidth*2+1) | 253 width = float(halfWidth*2+1) |
253 win = ones(width,'d') | 254 win = ones(width,'d') |
254 result = convolve(win/width,array(inputSignal),'same') | 255 result = convolve(win/width,array(inputSignal),'same') |
255 result[:halfWidth] = inputSignal[:halfWidth] | 256 result[:halfWidth] = inputSignal[:halfWidth] |
256 result[-halfWidth:] = inputSignal[-halfWidth:] | 257 result[-halfWidth:] = inputSignal[-halfWidth:] |