Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 501:c81cbd6953fb
update to classify speed to remove data at both ends
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 20 May 2014 15:18:55 -0400 |
parents | 6464e4f0cc26 |
children | a40c75f04903 |
comparison
equal
deleted
inserted
replaced
500:3b99d712bbee | 501:c81cbd6953fb |
---|---|
803 def predictPosition(self, instant, nTimeSteps, externalAcceleration = Point(0,0)): | 803 def predictPosition(self, instant, nTimeSteps, externalAcceleration = Point(0,0)): |
804 '''Predicts the position of object at instant+deltaT, | 804 '''Predicts the position of object at instant+deltaT, |
805 at constant speed''' | 805 at constant speed''' |
806 return predictPositionNoLimit(nTimeSteps, self.getPositionAtInstant(instant), self.getVelocityAtInstant(instant), externalAcceleration) | 806 return predictPositionNoLimit(nTimeSteps, self.getPositionAtInstant(instant), self.getVelocityAtInstant(instant), externalAcceleration) |
807 | 807 |
808 def classifyUserTypeSpeed(self, threshold, statisticsFunc = median): | 808 def classifyUserTypeSpeed(self, threshold, statisticsFunc = median, ignoreNInstantsAtEnds = 0): |
809 '''Classifies slow and fast road users | 809 '''Classifies slow and fast road users |
810 slow: non-motorized -> pedestrians | 810 slow: non-motorized -> pedestrians |
811 fast: motorized -> cars''' | 811 fast: motorized -> cars''' |
812 if statisticsFunc(self.velocities.norm()) >= threshold: | 812 if ignoreNInstantsAtEnds > 0: |
813 speeds = self.velocities.norm()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds] | |
814 else: | |
815 speeds = self.velocities.norm() | |
816 if statisticsFunc(speeds) >= threshold: | |
813 self.setUserType(userType2Num['car']) | 817 self.setUserType(userType2Num['car']) |
814 else: | 818 else: |
815 self.setUserType(userType2Num['pedestrian']) | 819 self.setUserType(userType2Num['pedestrian']) |
816 | 820 |
817 @staticmethod | 821 @staticmethod |