Skip to content

Commit

Permalink
standardise macrOutput plotting ref #14103
Browse files Browse the repository at this point in the history
Signed-off-by: m-kro <m.barthauer@t-online.de>
  • Loading branch information
m-kro committed Jan 3, 2024
1 parent b4f6ed7 commit 77f21d9
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tools/visualization/macrOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@
if "SUMO_HOME" in os.environ:
sys.path.append(os.path.join(os.environ['SUMO_HOME'], 'tools'))
import sumolib # noqa

from sumolib.visualization import helpers # noqa

def main(args=None):

ap = sumolib.options.ArgumentParser()
ap.add_argument("file", category="input", type=ap.file, help="An XML input file")
helpers.addPlotOptions(ap)
helpers.addInteractionOptions(ap)
options = ap.parse_args(args=args)

if options.output is not None and os.path.exists(options.output) and os.path.isfile(options.output):
options.output = os.path.dirname(options.output)

df = pdx.read_xml(options.file, ['meandata'])

df = pdx.flatten(df)
Expand Down Expand Up @@ -110,18 +115,21 @@ def main(args=None):
j = j+_seg

# plot
fig, ax = helpers.openFigure(options)
plt.scatter(MD, MS)
plt.xlabel("Density (Veh/km)")
plt.ylabel("Speed (Km/hr)")
plt.show()
helpers.closeFigure(fig, ax, options, optOut = None if options.output is None else os.path.join(options.output, "Edge_vk.png"))
fig, ax = helpers.openFigure(options)
plt.scatter(MD, MF)
plt.xlabel("Density (Veh/km)")
plt.ylabel("Flow (Veh/hr)")
plt.show()
helpers.closeFigure(fig, ax, options, optOut = None if options.output is None else os.path.join(options.output, "Edge_qk.png"))
fig, ax = helpers.openFigure(options)
plt.scatter(MS, MF)
plt.xlabel("Speed (Km/hr)")
plt.ylabel("Flow (Veh/hr)")
plt.show()
helpers.closeFigure(fig, ax, options, optOut = None if options.output is None else os.path.join(options.output, "Edge_qv.png"))

# calculating meandensity,meanflow,meanspeed (density=laneDensity)
i = 0
Expand All @@ -146,18 +154,21 @@ def main(args=None):
j = j+_seg

# plot
fig, ax = helpers.openFigure(options)
plt.scatter(lMD, lMS)
plt.xlabel("Density (Veh/km)")
plt.ylabel("Speed (Km/hr)")
plt.show()
helpers.closeFigure(fig, ax, options, optOut = None if options.output is None else os.path.join(options.output, "Lane_vk.png"))
fig, ax = helpers.openFigure(options)
plt.scatter(lMD, lMF)
plt.xlabel("Density (Veh/km)")
plt.ylabel("Flow (Veh/hr)")
plt.show()
helpers.closeFigure(fig, ax, options, optOut = None if options.output is None else os.path.join(options.output, "Lane_qk.png"))
fig, ax = helpers.openFigure(options)
plt.scatter(lMS, lMF)
plt.xlabel("Speed (Km/hr)")
plt.ylabel("Flow (Veh/hr)")
plt.show()
helpers.closeFigure(fig, ax, options, optOut = None if options.output is None else os.path.join(options.output, "Lane_qv.png"))

# Build a csv file
Macro_Features = {'Density': MD,
Expand Down

0 comments on commit 77f21d9

Please sign in to comment.