Mercurial Hosting > traffic-intelligence
diff trafficintelligence/indicators.py @ 1265:0f5bebd62a55
minor modifications
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 24 May 2024 16:15:38 -0400 |
parents | 56d0195d043e |
children | ad60e5adf084 |
line wrap: on
line diff
--- a/trafficintelligence/indicators.py Wed May 22 17:11:40 2024 -0400 +++ b/trafficintelligence/indicators.py Fri May 24 16:15:38 2024 -0400 @@ -185,12 +185,19 @@ else: return None - def getInstantOfMostSevereValue(self): - '''Returns the instant at which the indicator reaches its most severe value''' - if self.mostSevereIsMax: - return max(self.values, key=self.values.get) + def getInstantOfMostSevereValue(self, minSevereValue = None): + '''Returns the instant at which the indicator reaches its most severe value + or the instants when value is above minSevereValue (it not None)''' + if minSevereValue is None: + if self.mostSevereIsMax: + return max(self.values, key=self.values.get) + else: + return min(self.values, key=self.values.get) else: - return min(self.values, key=self.values.get) + if self.mostSevereIsMax: + return [t for t in self.values if self.values[t] >= minSevereValue] + else: + return [t for t in self.values if self.values[t] <= minSevereValue] # functions to aggregate discretized maps of indicators # TODO add values in the cells between the positions (similar to discretizing vector graphics to bitmap)