def readDTANetwork(self, inputDir, filePrefix, logging_dir='C:/temp'): """ Reads the dynameq files to create a network representation. """ # The SanFrancisco network will use feet for vehicle lengths and coordinates, and miles for link lengths dta.VehicleType.LENGTH_UNITS= "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging(logging_dir + "/dta.INFO.log", logging_dir+"/dta.DEBUG.log", logToConsole=False) scenario = dta.DynameqScenario() scenario.read(inputDir, filePrefix) net = dta.DynameqNetwork(scenario) net.read(inputDir, filePrefix) # initialize costs dta.Algorithms.ShortestPaths.initiaxblizeEdgeCostsWithFFTT(net) dta.Algorithms.ShortestPaths.initialiseMovementCostsWithFFTT(net) self.net = net
INPUT_DYNAMEQ_NET_PREFIX = sys.argv[2] REPORTING_START_TIME = sys.argv[3] REPORTING_END_TIME = sys.argv[4] ROUTE_DEFINITION_FILE = sys.argv[5] COUNT_DIR = sys.argv[6] LINK_COUNT_FILE_15MIN = sys.argv[7] MOVEMENT_COUNT_FILE_15MIN = sys.argv[8] MOVEMENT_COUNT_FILE_5MIN = sys.argv[9] REPORTS_ROUTE_TRAVEL_TIME_FILE = sys.argv[10] # The SanFrancisco network will use feet for vehicle lengths and coordinates, and miles for link lengths dta.VehicleType.LENGTH_UNITS= "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("visualizeDTAResults.INFO.log", "visualizeDTAResults.DEBUG.log", logToConsole=True) scenario = dta.DynameqScenario() scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) net = dta.DynameqNetwork(scenario) net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) #magic numbers here. This information may (or may not) be somewhere in the .dqt files simStartTime = 14 * 60 + 30 simEndTime = 21 * 60 + 30 simTimeStep = 5 net.readSimResults(simStartTime, simEndTime, 5) DtaLogger.info("Reading 15-minute link counts") net.readObsLinkCounts(COUNT_DIR + "/" + LINK_COUNT_FILE_15MIN)
if len(args) != 4: print USAGE sys.exit(2) INPUT_DYNAMEQ_NET_DIR = args[0] INPUT_DYNAMEQ_NET_PREFIX = args[1] INPUT_FASTTRIPS_FILE = args[2] OUTPUT_DYNAMEQ_NET_PREFIX = args[3] dta.VehicleType.LENGTH_UNITS = "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("addFastTripsDwellToTransit.INFO.log", "addFastTripsDwellToTransit.DEBUG.log", logToConsole=True) scenario = dta.DynameqScenario() scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) net = dta.DynameqNetwork(scenario) net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) # read the fasttrips file tripstop_to_dwell = readFastTripsOutput(INPUT_FASTTRIPS_FILE) # start the output file output_transit_filename = "%s_ptrn.dqt" % OUTPUT_DYNAMEQ_NET_PREFIX output_transit_file = open(output_transit_filename, mode='w') output_transit_file.write(dta.TransitLine.getDynameqFileHeaderStr())
OUTPUT_NODE_SHAPEFILE = None OUTPUT_LINK_SHAPEFILE = None for (opt, arg) in optlist: if opt == "-n": OUTPUT_NODE_SHAPEFILE = arg elif opt == "-l": OUTPUT_LINK_SHAPEFILE = arg # The SanFrancisco network will use feet for vehicle lengths and coordinates, and miles for link lengths dta.VehicleType.LENGTH_UNITS = "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("createSFNetworkFromCubeNetwork.INFO.log", "createSFNetworkFromCubeNetwork.DEBUG.log", logToConsole=True) # The rest of San Francisco currently exists as a Cube network. Initialize it from # the Cube network files (which have been exported to dbfs.) # This is where we define the :py:class:`dta.Scenario` sanfranciscoScenario = dta.DynameqScenario(dta.Time(14, 30), dta.Time(21, 30)) # We will have 4 vehicle classes: Car_NoToll, Car_Toll, Truck_NoToll, Truck_Toll # We will provide demand matrices for each of these classes sanfranciscoScenario.addVehicleClass("Car_NoToll") sanfranciscoScenario.addVehicleClass("Car_Toll") sanfranciscoScenario.addVehicleClass("Truck_NoToll") sanfranciscoScenario.addVehicleClass("Truck_Toll") # Transit is an implicit type
if len(sys.argv) != 4: print USAGE sys.exit(2) INPUT_DYNAMEQ_NET_DIR = sys.argv[1] INPUT_DYNAMEQ_NET_PREFIX = sys.argv[2] STOP_SHAPEFILE = sys.argv[3] # The SanFrancisco network will use feet for vehicle lengths and coordinates, and miles for link lengths dta.VehicleType.LENGTH_UNITS = "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("importUnsignalizedIntersections.INFO.log", "importUnsignalizedIntersections.DEBUG.log", logToConsole=True) scenario = dta.DynameqScenario() scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) net = dta.DynameqNetwork(scenario) net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) cnn_to_recordlist = readStopSignShapefile(STOP_SHAPEFILE) count_notmapped = 0 count_hassignal = 0 count_moreincoming = 0 count_allway = 0 count_twoway = 0 # no custom count_twoway_custom = 0
SF_DYNAMEQ_NET_PREFIX = args[1] OUTPUT_LINK_SHAPEFILE = None OUTPUT_MOVE_SHAPEFILE = None OUTPUT_NODE_SHAPEFILE = None for (opt, arg) in optlist: if opt == "-m": OUTPUT_MOVE_SHAPEFILE = arg elif opt == "-l": OUTPUT_LINK_SHAPEFILE = arg elif opt == "-n": OUTPUT_NODE_SHAPEFILE = arg dta.setupLogging("attachCountsFromCountDracula.INFO.log", "attachCountsFromCountDracula.DEBUG.log", logToConsole=True) dta.VehicleType.LENGTH_UNITS = "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" # Read the SF scenario and DTA network sanfranciscoScenario = dta.DynameqScenario() sanfranciscoScenario.read(dir=SF_DYNAMEQ_NET_DIR, file_prefix=SF_DYNAMEQ_NET_PREFIX) sanfranciscoDynameqNet = dta.DynameqNetwork(scenario=sanfranciscoScenario) sanfranciscoDynameqNet.read(dir=SF_DYNAMEQ_NET_DIR, file_prefix=SF_DYNAMEQ_NET_PREFIX)
CUBE_VEH_CLASS = args[2] OUTPUT_DYNAMEQ_TABLE = args[3] START_TIME = args[4] END_TIME = args[5] if optlist: for (opt,arg) in optlist: if opt=="-f": DEMAND_PROFILE_FILE = arg else: DEMAND_PROFILE_FILE = None dta.VehicleType.LENGTH_UNITS= "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("importCubeDemand.INFO.log", "importCubeDemand.DEBUG.log", logToConsole=True) outputStream = open(OUTPUT_DYNAMEQ_TABLE, "w") scenario = dta.DynameqScenario() scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) net = dta.DynameqNetwork(scenario) net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) startTime = dta.Utils.Time.readFromString(START_TIME) endTime = dta.Utils.Time.readFromString(END_TIME) # Read in the demand profile(s) if an input file was provided factorsStart = [] if DEMAND_PROFILE_FILE:
[dynameq_net_dir]\sf_trn_ptrn.dqt """ if __name__ == "__main__": INPUT_DYNAMEQ_NET_DIR = sys.argv[1] INPUT_DYNAMEQ_NET_PREFIX = sys.argv[2] TRANSIT_LINES = sys.argv[3:] dta.VehicleType.LENGTH_UNITS = "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("importTPPlusTransitRoutes.INFO.log", "importTPPlusTransitRoutes.DEBUG.log", logToConsole=True) scenario = dta.DynameqScenario() scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) net = dta.DynameqNetwork(scenario) net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) MODE_TO_LITYPE = { '11': dta.TransitLine.LINE_TYPE_BUS, # Muni Local '12': dta.TransitLine.LINE_TYPE_BUS, # Muni Express '13': dta.TransitLine.LINE_TYPE_BUS, # Muni BRT '14': dta.TransitLine.LINE_TYPE_TRAM, # Muni CableCar '15': dta.TransitLine.LINE_TYPE_TRAM, # Muni LRT }
{"Bus": dta.TransitLine.LINE_TYPE_BUS, "Cable Car": dta.TransitLine.LINE_TYPE_TRAM, "Tram": dta.TransitLine.LINE_TYPE_TRAM } GTFS_ROUTE_TYPE_TO_VTYPE = \ {"Bus": "Motor_Std", "Cable Car": "CableCar", "Tram": "LRT2" } dta.VehicleType.LENGTH_UNITS = "feet" dta.Node.COORDINATE_UNITS = "feet" dta.RoadLink.LENGTH_UNITS = "miles" dta.setupLogging("importGTFS.INFO.log", "importGTFS.DEBUG.log", logToConsole=True) scenario = dta.DynameqScenario() scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) net = dta.DynameqNetwork(scenario) net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) tfl = transitfeed.Loader(feed_path=GTFS_ZIP) schedule = tfl.Load() dta.DtaLogger.info("Read %s" % GTFS_ZIP) # Get the ServicePeriod we're interested in - we want weekday service service_period_tuples = schedule.GetServicePeriodsActiveEachDate( datetime.date(2012, 7, 10), datetime.date(2012, 7, 12)) service_period = service_period_tuples[0][1][0]