comparison trafficintelligence/moving.py @ 1184:f9cf827a73a6

minor bug with window length for savgol
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 01 Apr 2022 15:41:24 -0400
parents 38f0d0ceac3f
children d381a06e2d9e
comparison
equal deleted inserted replaced
1183:38f0d0ceac3f 1184:f9cf827a73a6
1572 wlength = min(window_length, len(speeds)) 1572 wlength = min(window_length, len(speeds))
1573 if wlength % 2 == 0: 1573 if wlength % 2 == 0:
1574 wlength -=1 1574 wlength -=1
1575 else: 1575 else:
1576 wlength = window_length 1576 wlength = window_length
1577 return savgol_filter(speeds, wlength, polyorder, 1, delta, axis, mode, cval) 1577 return savgol_filter(speeds, wlength, min(wlength, polyorder), 1, delta, axis, mode, cval)
1578 1578
1579 def getSpeedIndicator(self): 1579 def getSpeedIndicator(self):
1580 from indicators import SeverityIndicator 1580 from indicators import SeverityIndicator
1581 return SeverityIndicator('Speed', {t:self.getVelocityAtInstant(t).norm2() for t in self.getTimeInterval()}) 1581 return SeverityIndicator('Speed', {t:self.getVelocityAtInstant(t).norm2() for t in self.getTimeInterval()})
1582 1582