Ejemplo n.º 1
0
 def readTransitNameMapping(self):
     if self.runType=="muni" or self.runType=="bigBA" or self.runType=="all":
         if self.runType == "muni": 
             system=["SF MUNI"]
             ignoreModes=[11,12,13,14,15,16,17]
         elif self.runType=="bigBA": 
             system = ["SF MUNI", "AC Transit", "SamTrans", "Caltrain", "BART", "Golden Gate Transit", "Ferry", "Presidigo"]
             ignoreModes=[11,12,13,14,15,16,17]
         else: # system == "all":
             system = []
             ignoreModes = []
         
         self.transitCapacity = TransitCapacity(self.DIR)
         self.tad = TransitAssignmentData(directory=self.DIR, 
                                          timeperiod=self.timeperiod,
                                          champtype=self.CHAMPTYPE,
                                          transitCapacity=self.transitCapacity,
                                          ignoreModes=ignoreModes,
                                          system=system)
     else:
         self.tad = TransitAssignmentData(directory=self.DIR, 
                                          timeperiod=self.timeperiod,
                                          champtype=self.CHAMPTYPE,
                                          transitCapacity=self.transitCapacity,
                                          profileNode=self.PROFILENODE)
     
     (aggdir, aggfile) = os.path.split(self.OUTFILE)
     aggfile = "agg_" + aggfile
     self.tad.writeDbfs(self.OUTFILE, os.path.join(aggdir,aggfile))
Ejemplo n.º 2
0
trnAssignIter           = int(sys.argv[2])
volDiffCond             = float(sys.argv[3])

subdir                  = "Subdir"+str(trnAssignIter)
routeFileName           = os.path.join(subdir, "trnlink{}_ALLMSA.dbf".format(timeperiod))

setupLogging(infoLogFilename=None, debugLogFilename="routeLinkMSA_%s.%d.log" % (timeperiod, trnAssignIter), 
             logToConsole=False)
    

# Read in the current assignment
logging.info("Reading in transit assignment data for " + timeperiod)
TransitNetwork.initializeTransitCapacity(directory="..")
curTad=TransitAssignmentData(timeperiod=timeperiod,
                             modelType=Network.MODEL_TYPE_TM1,
                             ignoreModes=[1,2,3,4,5,6,7],
                             tpfactor="constant_with_peaked_muni",
                             transitCapacity=TransitNetwork.capacity)

if trnAssignIter == 0:
    prevTad = False
else:
    prevSubdir              = "Subdir"+str(trnAssignIter-1)
    prevRouteFileName       = os.path.join(prevSubdir, "trnlink{}_ALLMSA.dbf".format(timeperiod))    
    # Read the MSA assignment from the previous iteration
    prevTad=TransitAssignmentData(timeperiod=timeperiod,
                                  modelType=Network.MODEL_TYPE_TM1,
                                  ignoreModes=[1,2,3,4,5,6,7],
                                  tpfactor="constant_with_peaked_muni",
                                  transitCapacity=TransitNetwork.capacity,                                  
                                  lineLevelAggregateFilename=prevRouteFileName)
Ejemplo n.º 3
0
class TransitDbfCombiner:
    
    def __init__(self, timeperiod,runDir,outFile,
                 champType='champ4',runType='',includeAll=False):
        """ 
        Interpret the args into my local variables.
        ALL CAPS class variables indicate arg-based constants.
        """
        self.timeperiod = timeperiod
        if self.timeperiod not in ["AM", "MD", "PM", "EV", "EA"]:
            print USAGE
            exit(1)
        if (self.timeperiod == "AM"):
            self.vtypeIdx = 2
        elif (self.timeperiod == "PM"):
            self.vtypeIdx = 3
        else:
            self.vtypeIdx = 4
            
        self.DIR        = runDir
        self.OUTFILE    = outFile
        self.runType    = runType
        self.includeAll=bool(includeAll)
        self.PROFILENODE= 0           
        
        if self.runType not in ["muni","bigBA","all"] and self.runType[0:7] != "profile":
            print "Don't understand runType %s" % self.runType
            print USAGE
            exit(1)
        if self.runType[0:7].lower() == "profile":
            self.PROFILENODE = int(self.runType[7:])
        self.CHAMPTYPE = champType
        if self.CHAMPTYPE not in ["champ3","champ4","champ3-sfonly"]:
            print "Don't understand CHAMPTYPE %s" % CHAMPTYPE
            print USAGE
            exit(1)
        
        logging.info("includeAll= " + str(self.includeAll))
        logging.info("timeperiod = " + self.timeperiod)
        logging.info("DIR        = " + self.DIR)
        logging.info("OUTFILE    = " + self.OUTFILE)
        logging.info("runType    = " + self.runType)
        logging.info("PROFILENODE= " + str(self.PROFILENODE))
        logging.info("CHAMPTYPE  = " + self.CHAMPTYPE)
        
    def readTransitNameMapping(self):
        if self.runType=="muni" or self.runType=="bigBA" or self.runType=="all":
            if self.runType == "muni": 
                system=["SF MUNI"]
                ignoreModes=[11,12,13,14,15,16,17]
            elif self.runType=="bigBA": 
                system = ["SF MUNI", "AC Transit", "SamTrans", "Caltrain", "BART", "Golden Gate Transit", "Ferry", "Presidigo"]
                ignoreModes=[11,12,13,14,15,16,17]
            else: # system == "all":
                system = []
                ignoreModes = []
            
            self.transitCapacity = TransitCapacity(self.DIR)
            self.tad = TransitAssignmentData(directory=self.DIR, 
                                             timeperiod=self.timeperiod,
                                             champtype=self.CHAMPTYPE,
                                             transitCapacity=self.transitCapacity,
                                             ignoreModes=ignoreModes,
                                             system=system)
        else:
            self.tad = TransitAssignmentData(directory=self.DIR, 
                                             timeperiod=self.timeperiod,
                                             champtype=self.CHAMPTYPE,
                                             transitCapacity=self.transitCapacity,
                                             profileNode=self.PROFILENODE)
        
        (aggdir, aggfile) = os.path.split(self.OUTFILE)
        aggfile = "agg_" + aggfile
        self.tad.writeDbfs(self.OUTFILE, os.path.join(aggdir,aggfile))
Ejemplo n.º 4
0
    
    # No PHT condition must mean we're using volume conditions so use the MSA'd
    # assignment we already have
    if PHTDiffCond==0:
        curRouteFileName       = os.path.join(curSubdir, "trnlink{}_ALLMSA.dbf".format(timeperiod))
    else:
        curRouteFileName       = None

    WranglerLogger.info("curRouteFileName   = {}".format(curRouteFileName))
        
    TransitNetwork.initializeTransitCapacity(directory="..")
    tad = None
    try:
        tad = TransitAssignmentData(timeperiod=timeperiod,
                                    modelType=Network.MODEL_TYPE_TM1,
                                    ignoreModes=[1,2,3,4,5,6,7],
                                    tpfactor="constant_with_peaked_muni",
                                    transitCapacity=TransitNetwork.capacity,
                                    lineLevelAggregateFilename=curRouteFileName)
    except Exception, err:
        WranglerLogger.fatal(sys.exc_info()[0])
        WranglerLogger.fatal(sys.exc_info()[1])
        WranglerLogger.fatal(traceback.format_exc())
        sys.exit(2)

    # since we've aggregated, write it out
    if not curRouteFileName:
        tad.writeDbfs(os.path.join(curSubdir, "trnlink{}_ALL.dbf".format(timeperiod)))
        
    currentNet = TransitNetwork(modelType=Network.MODEL_TYPE_TM1, modelVersion=1.5)
    currentNet.parseFile(fullfile=curNetFile)
    originalNet = TransitNetwork(modelType=Network.MODEL_TYPE_TM1, modelVersion=1.5)