def getOptions(args=None): optParser = ArgumentParser( description='Plot arbitrary attributes from xml files', epilog='Individual trajectories can be clicked in interactive mode to print the data Id on the console\n' 'selects two attributs for x and y axis and optionally a third (id-attribute)\n' 'for grouping of data points into lines\n\n' 'Example\n' ' plotXMLAttributes.py -x started -y initialPersons -s stopout.xml\n' ' plots passengers over time for vehicles from SUMO stop output', formatter_class=RawDescriptionHelpFormatter) optParser.add_option("-x", "--xattr", help="attribute for x-axis") optParser.add_option("-y", "--yattr", help="attribute for y-axis") optParser.add_option("-i", "--idattr", default="id", help="attribute for grouping data points into lines") optParser.add_option("--xelem", help="element for x-axis") optParser.add_option("--yelem", help="element for y-axis") optParser.add_option("--idelem", help="element for grouping data points into lines") optParser.add_option("-s", "--show", action="store_true", default=False, help="show plot directly") optParser.add_option("-o", "--output", help="outputfile for saving plots", default="plot.png") optParser.add_option("--csv-output", dest="csv_output", help="write plot as csv", metavar="FILE") optParser.add_option("--filter-ids", dest="filterIDs", help="only plot data points from the given list of ids") optParser.add_option("-p", "--pick-distance", dest="pickDist", type=float, default=1, help="pick lines within the given distance in interactive plot mode") optParser.add_option("--label", help="plot label (default input file name") optParser.add_option("--xlabel", help="plot label (default xattr)") optParser.add_option("--ylabel", help="plot label (default yattr)") optParser.add_option("--xfactor", help="multiplier for x-data", type=float, default=1) optParser.add_option("--yfactor", help="multiplier for y-data", type=float, default=1) optParser.add_option("--invert-yaxis", dest="invertYAxis", action="store_true", default=False, help="Invert the Y-Axis") optParser.add_option("--scatterplot", action="store_true", default=False, help="Draw a scatterplot instead of lines") optParser.add_option("--legend", action="store_true", default=False, help="Add legend") optParser.add_option("-v", "--verbose", action="store_true", default=False, help="tell me what you are doing") optParser.add_argument("files", nargs='+', help="List of XML files to plot") options = optParser.parse_args(args=args) options.attrOptions = ['idattr', 'xattr', 'yattr'] options.attrElems = [options.idelem, options.xelem, options.yelem] if options.filterIDs is not None: options.filterIDs = set(options.filterIDs.split(',')) for a in options.attrOptions: if getattr(options, a) is None: sys.exit("mandatory argument --%s is missing" % a) if options.xlabel is None: options.xlabel = options.xattr if options.ylabel is None: options.ylabel = options.yattr return options
def get_options(args=None): argParser = ArgumentParser() argParser.add_argument("-t", "--tripinfo-file", dest="tripinfoFile", help="tripinfo file written by the simulation") argParser.add_argument("-a", "--attribute", default="duration", help="attribute to use for statistics") argParser.add_argument("-o", "--output", help="the output file") argParser.add_argument("-i", "--interval", help="custom aggregation interval (seconds or H:M:S)") argParser.add_argument("--by-arrivals", action="store_true", default=False, dest="byArrivals", help="When using --interval, aggregated by arrival time instead of depart time") options = argParser.parse_args(args=args) if not options.tripinfoFile: sys.exit("Required argument --tripinfo-file is missing") if options.interval is not None: options.interval = parseTime(options.interval) return options
def get_options(args=None): argParser = ArgumentParser() argParser.add_argument("-t", "--tripinfo-file", dest="tripinfoFile", help="tripinfo file written by the simulation") argParser.add_argument("-a", "--attribute", default="duration", help="attribute to use for statistics") argParser.add_argument("-o", "--output", help="the output file") options = argParser.parse_args(args=args) if not options.tripinfoFile: sys.exit("Required argument --tripinfo-file is missing") return options
def parse_args(): argParser = ArgumentParser() db_manipulator.add_db_arguments(argParser) argParser.add_argument( "-a", "--all-pairs", dest="all_pairs", default=False, action="store_true", help="Generate trips for all pairs of traffic zones") argParser.add_argument( "-d", "--departure", type=int, default=3600 * 16, help="When used with --all-pairs, set departure second to <INT>") argParser.add_argument("-k", "--simkey", help="simulation key to retrieve") argParser.add_argument("-l", "--limit", type=int, help="maximum number of trips to retrieve") argParser.add_argument("--seed", type=int, default=23432, help="random seed") argParser.add_argument("--representatives", default='berlin_location_representatives', help="set the table to read representatives from") argParser.add_argument("--triptable", default='berlin_trips', help="set the table to receive trips from") argParser.add_argument("--taztable", default='berlin_taz', help="set the table to read districts from") argParser.add_argument( "-m", "--modes", default=','.join(CAR_MODES), help= "the traffic modes to retrieve as a list of integers (default '%default')" ) options = argParser.parse_args() options.limit_sql = "" if options.limit is None else "LIMIT %s" % options.limit return options
def parse_args(): argParser = ArgumentParser() db_manipulator.add_db_arguments(argParser) argParser.add_argument("-o", "--output", default="osm_scenario_pre/mitte_net/location_priorities.xml", help="output file") options = argParser.parse_args() return options
def initOptions(): ap = ArgumentParser() ap.add_argument("-n", "--network", required=True, help="SUMO network file") ap.add_argument("--osm-routes", required=True, help="osm routes file") ap.add_argument("--gtfs", required=True, help="define gtfs zip file to load (mandatory)") ap.add_argument( "--bbox", required=True, help="define the bounding box to filter the gtfs data, format: W,S,E,N" ) # noqa ap.add_argument("--date", help="define the day to import, format: 'YYYYMMDD'") ap.add_argument( "--pt-types", default="bus,tram,train,subway,ferry", help= "filter pt-types to import (bus, tram, train, subway and/or ferry). format: 'bus,tram'" ) # noqa ap.add_argument("--repair", help="repair osm routes", action='store_true') ap.add_argument("--debug", action='store_true') ap.add_argument("--bus-stop-length", default=13, type=float, help="length for a bus stop") ap.add_argument("--train-stop-length", default=110, type=float, help="length for a train stop") ap.add_argument("--tram-stop-length", default=60, type=float, help="length for a tram stop") ap.add_argument("--duration", default=10, type=int, help="minimum time to wait on a stop") ap.add_argument( "--min-stops", default=3, type=int, help= "minimum number of stops a public transport line must have to be imported" ) # noqa options = ap.parse_args() options.pt_types = options.pt_types.split(",") options.region = [float(boundary) for boundary in options.bbox.split(",")] return options
def main(): argParser = ArgumentParser() db_manipulator.add_db_arguments(argParser) argParser.add_argument("-n", "--net-file", help="specifying the net file of the scenario to use") argParser.add_argument("-k", "--simkey", default="test", help="simulation key to use") argParser.add_argument("-l", "--limit", type=int, help="maximum number of trips to retrieve") argParser.add_argument("--representatives", default="", help="set the route alternatives file to read representative travel times from") argParser.add_argument("--real-trips", default="", help="set the route file to read travel times for real trips from") argParser.add_argument("-a", "--all-pairs", default=False, action="store_true", help="Only write the all pairs table") options, args = argParser.parse_known_args() if len(args) == 2: aggregate_weights(args[0], [float(x) for x in args[1].split(",")]) return conn = db_manipulator.get_conn(options) if os.path.isfile(options.real_trips) and not options.all_pairs: upload_trip_results(conn, options.simkey, SP.OPTIONAL, options.real_trips, options.limit) if os.path.isfile(options.representatives): tables = create_all_pairs(conn, options.simkey, SP.OPTIONAL) upload_all_pairs(conn, tables, 0, 86400, "passenger", options.real_trips, options.representatives, readNet(options.net_file), []) conn.close()
print("running pre test instructions") run_instructions(options, pre_test) process_db_manipulator = None if par_test: # run as parallel process print("starting parallel test instructions") process_db_manipulator = multiprocessing.Process( target=run_instructions, args=(options, par_test)) process_db_manipulator.start() print("starting main") sys.stdout.flush() subprocess.call(call) sys.stdout.flush() sys.stderr.flush() if process_db_manipulator: print("waiting for parallel test") process_db_manipulator.join() if post_test: print("running post test instructions") run_instructions(options, post_test) if __name__ == "__main__": argParser = ArgumentParser() add_db_arguments(argParser) argParser.add_argument("sqlfile", nargs="*", help="SQL files to process") options = argParser.parse_args() # get connection to (test) db print('using server', options) run_instructions(options, [open(o) for o in options.sqlfile])