1#!/usr/bin/env python
2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3# Copyright (C) 2012-2026 German Aerospace Center (DLR) and others.
4# This program and the accompanying materials are made available under the
5# terms of the Eclipse Public License 2.0 which is available at
6# https://www.eclipse.org/legal/epl-2.0/
7# This Source Code may also be made available under the following Secondary
8# Licenses when the conditions for such availability set forth in the Eclipse
9# Public License 2.0 are satisfied: GNU General Public License, version 2
10# or later which is available at
11# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14# @file checkFlows.py
15# @author Daniel Krajzewicz
16# @date 2014-09-11
17
18
19from __future__ import absolute_import
20import sys
21import sumolib.output
22from pylab import legend, plot, show
23
24
25if __name__ == "__main__":
26 f = {}
27 pd = sumolib.output.parse(sys.argv[1], "vehicle")
28 for v in pd:
29 t = int(float(v.depart))
30 e = v["route"][0].edges.split(" ")[0]
31 if e not in f:
32 f[e] = [0] * 86400
33 f[e][t] = f[e][t] + 1
34
35
36 AGG = 3600
37 fa = {}
38 for e in f:
39 fa[e] = [0] * (86400 / AGG)
40 for th in range(0, 86400 / AGG):
41 for tl in range(0, AGG):
42 fa[e][th] = fa[e][th] + f[e][th * AGG + tl]
43 ts = range(0, 86400 / AGG)
44
45
46 for e in f:
47 plot(ts, fa[e], 'o-', label=e)
48 legend()
49 show()