diff python/moving.py @ 511:ad518f0c3218

merged pulling from main
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 28 May 2014 17:46:38 -0400
parents c81cbd6953fb
children a40c75f04903
line wrap: on
line diff
--- a/python/moving.py	Fri May 23 17:33:11 2014 -0400
+++ b/python/moving.py	Wed May 28 17:46:38 2014 -0400
@@ -805,11 +805,15 @@
         at constant speed'''
         return predictPositionNoLimit(nTimeSteps, self.getPositionAtInstant(instant), self.getVelocityAtInstant(instant), externalAcceleration)
 
-    def classifyUserTypeSpeed(self, threshold, statisticsFunc = median):
+    def classifyUserTypeSpeed(self, threshold, statisticsFunc = median, ignoreNInstantsAtEnds = 0):
         '''Classifies slow and fast road users
         slow: non-motorized -> pedestrians
         fast: motorized -> cars'''
-        if statisticsFunc(self.velocities.norm()) >= threshold:
+        if ignoreNInstantsAtEnds > 0:
+            speeds = self.velocities.norm()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds]
+        else:
+            speeds = self.velocities.norm()
+        if statisticsFunc(speeds) >= threshold:
             self.setUserType(userType2Num['car'])
         else:
             self.setUserType(userType2Num['pedestrian'])