def __init__(self, node): self.node = node self.label = helpers.getLabel(node) self.label = wrap(self.label, self.wrap_width) self.label = [escape(s) for s in self.label] self.label = '\n'.join(self.label) self.topMatter = '\n\t\tlabel="%s"' % self.label self.topMatter += '\n\t\tbgcolor="lightblue"' self.topMatter += '\n' self.tabs = self.getTabs(node)
def __init__(self, node): self.node = node self.label = helpers.getLabel(node) self.label = wrap(self.label, self.wrap_width) self.label = [escape(s) for s in self.label] self.label = '<br/>'.join(self.label) self.topMatter = '\n\t\t\tlabel=""' self.topMatter += '\n\t\t\tbgcolor="white"' self.topMatter += '\n\t\t\tordering="in"' self.topMatter += '\n' self.guiBlocks = self.getGuiBlocks(node)
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) 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", "--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) 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", "--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) 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) 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", "--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) 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)
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) 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)