Mercurial Hosting > traffic-intelligence
comparison python/utils.py @ 547:97c5fef5b2d6
corrected bugs
author | MohamedGomaa |
---|---|
date | Tue, 08 Jul 2014 13:43:56 -0400 |
parents | 3707eeb20f25 |
children | 3622a5653ee9 |
comparison
equal
deleted
inserted
replaced
546:6c0923f1ce68 | 547:97c5fef5b2d6 |
---|---|
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:] |