Exemple #1
0
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser
    optParser = OptionParser()
    optParser.add_option("-i",
                         "--input",
                         dest="input",
                         metavar="FILE",
                         help="Defines the input file to use")
    optParser.add_option("-v",
                         "--verbose",
                         dest="verbose",
                         action="store_true",
                         default=False,
                         help="If set, the script says what it's doing")
    optParser.add_option("-c",
                         "--columns",
                         dest="columns",
                         default=None,
                         help="Defines which columns shall be plotted")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, _ = optParser.parse_args(args=args)

    if options.input is None:
        print("Error: an input file must be given")
        sys.exit(1)

    minV = 0
    maxV = 0
    if options.columns is not None:
        options.columns = [int(i) for i in options.columns.split(",")]
    nums = readValues(options.input, options.verbose, options.columns)
    for f in nums:
        maxV = max(maxV, len(nums[f]))
    ts = range(minV, maxV + 1)

    fig, ax = helpers.openFigure(options)
    for i in nums:
        v = nums[i]
        ci = i
        if options.columns is not None:
            ci = options.columns.index(i)
        c = helpers.getColor(options, ci, len(nums))
        plt.plot(ts[0:len(v)],
                 v,
                 label=helpers.getLabel(str(i), ci, options),
                 color=c)
    helpers.closeFigure(fig, ax, options)
Exemple #2
0
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser
    optParser = OptionParser()
    optParser.add_option(
        "-i",
        "--summary-inputs",
        dest="summary",
        metavar="FILE",
        help="Defines the summary-output files to use as input")
    optParser.add_option("-v",
                         "--verbose",
                         dest="verbose",
                         action="store_true",
                         default=False,
                         help="If set, the script says what it's doing")
    optParser.add_option("-m",
                         "--measure",
                         dest="measure",
                         default="running",
                         help="Define which measure to plot")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, remaining_args = optParser.parse_args(args=args)

    if options.summary is None:
        print("Error: at least one summary file must be given")
        sys.exit(1)

    minV = 0
    maxV = 0
    files = options.summary.split(",")
    nums = readValues(files, options.verbose, options.measure)
    times = readValues(files, options.verbose, "time")
    for f in files:
        maxV = max(maxV, len(nums[f]))
    ts = range(minV, maxV + 1)

    fig, ax = helpers.openFigure(options)
    for i, f in enumerate(files):
        v = sumolib.output.toList(nums[f], options.measure)
        t = sumolib.output.toList(times[f], "time")
        c = helpers.getColor(options, i, len(files))
        l = helpers.getLabel(f, i, options)
        plt.plot(t, v, label=l, color=c)
    helpers.closeFigure(fig, ax, options)
Exemple #3
0
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser

    optParser = OptionParser()
    optParser.add_option(
        "-i",
        "--summary-inputs",
        dest="summary",
        metavar="FILE",
        help="Defines the summary-output files to use as input",
    )
    optParser.add_option(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="If set, the script says what it's doing",
    )
    optParser.add_option("-m", "--measure", dest="measure", default="running", help="Define which measure to plot")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, remaining_args = optParser.parse_args(args=args)

    if options.summary == None:
        print("Error: at least one summary file must be given")
        sys.exit(1)

    minV = 0
    maxV = 0
    files = options.summary.split(",")
    nums = readValues(files, options.verbose, options.measure)
    for f in files:
        maxV = max(maxV, len(nums[f]))
    ts = range(minV, maxV + 1)

    fig, ax = helpers.openFigure(options)
    for i, f in enumerate(files):
        v = sumolib.output.toList(nums[f], options.measure)
        c = helpers.getColor(options, i, len(files))
        l = helpers.getLabel(f, i, options)
        plt.plot(ts[0 : len(v)], v, label=l, color=c)
    helpers.closeFigure(fig, ax, options)
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser

    optParser = OptionParser()
    optParser.add_option("-i", "--input", dest="input", metavar="FILE", help="Defines the input file to use")
    optParser.add_option(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="If set, the script says what it's doing",
    )
    optParser.add_option("-c", "--columns", dest="columns", default=None, help="Defines which columns shall be plotted")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, remaining_args = optParser.parse_args(args=args)

    if options.input == None:
        print("Error: an input file must be given")
        sys.exit(1)

    minV = 0
    maxV = 0
    if options.columns != None:
        options.columns = [int(i) for i in options.columns.split(",")]
    nums = readValues(options.input, options.verbose, options.columns)
    for f in nums:
        maxV = max(maxV, len(nums[f]))
    ts = range(minV, maxV + 1)

    fig, ax = helpers.openFigure(options)
    for i in nums:
        v = nums[i]
        ci = i
        if options.columns != None:
            ci = options.columns.index(i)
        c = helpers.getColor(options, ci, len(nums))
        l = helpers.getLabel(str(i), ci, options)
        plt.plot(ts[0 : len(v)], v, label=l, color=c)
    helpers.closeFigure(fig, ax, options)
Exemple #5
0
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser
    optParser = OptionParser()
    optParser.add_option(
        "-i",
        "--summary-inputs",
        dest="summary",
        metavar="FILE",
        help="Defines the summary-output files to use as input")
    optParser.add_option("-v",
                         "--verbose",
                         dest="verbose",
                         action="store_true",
                         default=False,
                         help="If set, the script says what it's doing")
    optParser.add_option("-m",
                         "--measure",
                         dest="measure",
                         default="running",
                         help="Define which measure to plot")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, _ = optParser.parse_args(args=args)

    if options.summary is None:
        print("Error: at least one summary file must be given")
        sys.exit(1)

    files = options.summary.split(",")
    fig, ax = helpers.openFigure(options)
    for i, f in enumerate(files):
        t = []
        v = []
        for time, val in sumolib.xml.parse_fast(f, "step",
                                                ("time", options.measure)):
            t.append(sumolib.miscutils.parseTime(time))
            v.append(float(val))
        c = helpers.getColor(options, i, len(files))
        plt.plot(t, v, label=helpers.getLabel(f, i, options), color=c)
    helpers.closeFigure(fig, ax, options)
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser
    optParser = OptionParser()
    optParser.add_option("-i", "--tripinfos-inputs", dest="tripinfos", metavar="FILE",
                         help="Defines the tripinfo-output files to use as input")
    optParser.add_option("-v", "--verbose", dest="verbose", action="store_true",
                         default=False, help="If set, the script says what it's doing")
    optParser.add_option("-m", "--measure", dest="measure",
                         default="duration", help="Define which measure to plot")
    optParser.add_option("--bins", dest="bins",
                         type="int", default=20, help="Define the bin number")
    optParser.add_option("--norm", dest="norm",
                         type="float", default=1., help="Read values will be devided by this number")
    optParser.add_option("--minV", dest="minV",
                         type="float", default=None, help="Define the minimum value boundary")
    optParser.add_option("--maxV", dest="maxV",
                         type="float", default=None, help="Define the maximum value boundary")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, remaining_args = optParser.parse_args(args=args)

    if options.tripinfos == None:
        print "Error: at least one tripinfo file must be given"
        sys.exit(1)

    minV = options.minV
    maxV = options.maxV
    files = options.tripinfos.split(",")
    values = {}
    for f in files:
        if options.verbose:
            print "Reading '%s'..." % f
        nums = sumolib.output.parse_sax__asList(
            f, "tripinfo", [options.measure])
        fvp = sumolib.output.toList(nums, options.measure)
        fv = [x / options.norm for x in fvp]
        sumolib.output.prune(fv, options.minV, options.maxV)

        values[f] = fv
        if minV == None:
            minV = fv[0]
            maxV = fv[0]
        minV = min(minV, min(fv))
        maxV = max(maxV, max(fv))

    hists = {}
    binWidth = (maxV - minV) / float(options.bins)
    for f in files:
        h = [0] * options.bins
        for v in values[f]:
            i = min(int((v - minV) / binWidth), options.bins - 1)
            h[i] = h[i] + 1
        hists[f] = h

    width = binWidth / float(len(files)) * .8
    offset = binWidth * .1
    center = []
    for j in range(0, options.bins):
        center.append(binWidth * j + offset)

    fig, ax = helpers.openFigure(options)
    for i, f in enumerate(files):
        c = helpers.getColor(options, i, len(files))
        l = helpers.getLabel(f, i, options)
        plt.bar(center, hists[f], width=width, label=l, color=c)
        for j in range(0, options.bins):
            center[j] = center[j] + width
    helpers.closeFigure(fig, ax, options)
Exemple #7
0
def main(args=None):
    """The main function; parses options and plots"""
    # ---------- build and read options ----------
    from optparse import OptionParser
    optParser = OptionParser()
    optParser.add_option(
        "-i",
        "--tripinfos-inputs",
        dest="tripinfos",
        metavar="FILE",
        help="Defines the tripinfo-output files to use as input")
    optParser.add_option("-v",
                         "--verbose",
                         dest="verbose",
                         action="store_true",
                         default=False,
                         help="If set, the script says what it's doing")
    optParser.add_option("-m",
                         "--measure",
                         dest="measure",
                         default="duration",
                         help="Define which measure to plot")
    optParser.add_option("--bins",
                         dest="bins",
                         type="int",
                         default=20,
                         help="Define the bin number")
    optParser.add_option("--norm",
                         dest="norm",
                         type="float",
                         default=1.,
                         help="Read values will be devided by this number")
    optParser.add_option("--minV",
                         dest="minV",
                         type="float",
                         default=None,
                         help="Define the minimum value boundary")
    optParser.add_option("--maxV",
                         dest="maxV",
                         type="float",
                         default=None,
                         help="Define the maximum value boundary")
    # standard plot options
    helpers.addInteractionOptions(optParser)
    helpers.addPlotOptions(optParser)
    # parse
    options, remaining_args = optParser.parse_args(args=args)

    if options.tripinfos == None:
        print "Error: at least one tripinfo file must be given"
        sys.exit(1)

    minV = options.minV
    maxV = options.maxV
    files = options.tripinfos.split(",")
    values = {}
    for f in files:
        if options.verbose:
            print "Reading '%s'..." % f
        nums = sumolib.output.parse_sax__asList(f, "tripinfo",
                                                [options.measure])
        fvp = sumolib.output.toList(nums, options.measure)
        fv = [x / options.norm for x in fvp]
        sumolib.output.prune(fv, options.minV, options.maxV)

        values[f] = fv
        if minV == None:
            minV = fv[0]
            maxV = fv[0]
        minV = min(minV, min(fv))
        maxV = max(maxV, max(fv))

    hists = {}
    binWidth = (maxV - minV) / float(options.bins)
    for f in files:
        h = [0] * options.bins
        for v in values[f]:
            i = min(int((v - minV) / binWidth), options.bins - 1)
            h[i] = h[i] + 1
        hists[f] = h

    width = binWidth / float(len(files)) * .8
    offset = binWidth * .1
    center = []
    for j in range(0, options.bins):
        center.append(binWidth * j + offset)

    fig, ax = helpers.openFigure(options)
    for i, f in enumerate(files):
        c = helpers.getColor(options, i, len(files))
        l = helpers.getLabel(f, i, options)
        plt.bar(center, hists[f], width=width, label=l, color=c)
        for j in range(0, options.bins):
            center[j] = center[j] + width
    helpers.closeFigure(fig, ax, options)