def readProcessedFCD(): """Reads the processed FCD and creates a List of vtypeDict fakes with can be used similarly.""" procFcdDict = {} pqDateDict = {} # each date is a period / quota tupel assigned simDate = '2007-07-18 ' day = 0 # create keys for the procFcdDict for p in period: for q in quota: day += 86400 date, time = calcTime.getDateFromDepart(day).split(" ") pqDateDict.setdefault(date, (p, q)) procFcdDict.setdefault((p, q), {}) # print date,p,q inputFile = open(path.FQprocessedFCD, 'r') for line in inputFile: timestamp, edge, speed, cover, id = line.split('\t') date, time = calcTime.getNiceTimeLabel(timestamp).split(" ") # add values to actual Dict timestep = calcTime.getTimeInSecs(simDate + time) procFcdDict[pqDateDict[date]].setdefault(timestep, []).append( (id, edge, float(speed) / 3.6)) inputFile.close() return procFcdDict
def readProcessedFCD(): """Reads the processed FCD and creates a List of vtypeDict fakes with can be used similarly.""" procFcdDict={} pqDateDict={} #each date is a period / quota tupel assigned simDate='2007-07-18 ' day=0 #create keys for the procFcdDict for p in period: for q in quota: day+=86400 date,time=calcTime.getDateFromDepart(day).split(" ") pqDateDict.setdefault(date,(p,q)) procFcdDict.setdefault((p,q),{}) #print date,p,q inputFile=open(path.FQprocessedFCD,'r') for line in inputFile: timestamp,edge,speed,cover,id=line.split('\t') date,time=calcTime.getNiceTimeLabel(timestamp).split(" ") #add values to actual Dict timestep= calcTime.getTimeInSecs(simDate+time) procFcdDict[pqDateDict[date]].setdefault(timestep,[]).append((id,edge,float(speed)/3.6)) inputFile.close() return procFcdDict
def writeRawFCD(): """Creates a file in the raw-fcd-format of the chosen taxis""" global vehId, vehIdDict vehIdDict = {} vehId = 0 day = 0 def getVehId(orgId): """creates new vehicle id's which consists only numerics""" global vehId, vehIdDict value = vehIdDict.get(orgId, vehId) if value is vehId: vehIdDict[orgId] = vehId vehId = (vehId + 1) % 65500 return value outputFile = open(path.FQrawFCD, 'w') for period, quota, vtypeDictR, taxiSum in generatePeriodQuotaSets(): day += 86400 # reset dict so that every taxi (even if the vehicle is chosen several # times) gets its own id vehIdDict = {} # dataset=0 sortedKeys = vtypeDictR.keys() sortedKeys.sort() for timestep in sortedKeys: taxiList = vtypeDictR[timestep] for tup in taxiList: # all elements in this timestep # calc timestep ->for every period /quota set a new day time = timestep + day time = calcTime.getDateFromDepart(time) # dataset+=1 # print ouptut # veh_id date (time to simDate+time) x (remove and # set comma new) outputFile.write( str(getVehId(tup[0])) + '\t' + time + '\t' + tup[3][0:2] + '.' + tup[3][2:7] + tup[3][8:] + # y (remove and set comma new) # status speed form m/s in km/h '\t' + tup[4][0:2] + '.' + tup[4][2:7] + tup[4][8:] + '\t' + "90" + '\t' + str(int(round(tup[2] * 3.6))) + '\n') # print dataset, time print(vehId) outputFile.close()
def writeRawFCD(): """Creates a file in the raw-fcd-format of the chosen taxis""" global vehId, vehIdDict vehIdDict = {} vehId = 0 day = 0 def getVehId(orgId): """creates new vehicle id's which consists only numerics""" global vehId, vehIdDict value = vehIdDict.get(orgId, vehId) if value is vehId: vehIdDict[orgId] = vehId vehId = (vehId + 1) % 65500 return value outputFile = open(path.FQrawFCD, 'w') for period, quota, vtypeDictR, taxiSum in generatePeriodQuotaSets(): day += 86400 # reset dict so that every taxi (even if the vehicle is chosen several # times) gets its own id vehIdDict = {} # dataset=0 sortedKeys = vtypeDictR.keys() sortedKeys.sort() for timestep in sortedKeys: taxiList = vtypeDictR[timestep] for tup in taxiList: # all elements in this timestep # calc timestep ->for every period /quota set a new day time = timestep + day time = calcTime.getDateFromDepart(time) # dataset+=1 # print ouptut # veh_id date (time to simDate+time) x (remove and # set comma new) outputFile.write(str(getVehId(tup[0])) + '\t' + time + '\t' + tup[3][0:2] + '.' + tup[3][2:7] + tup[3][8:] + # y (remove and set comma new) # status speed form m/s in km/h '\t' + tup[4][0:2] + '.' + tup[4][2:7] + tup[4][8:] + '\t' + "90" + '\t' + str(int(round(tup[2] * 3.6))) + '\n') # print dataset, time print(vehId) outputFile.close()
def clacAvg(): durationList = [] taxis = reader.readAnalysisInfo() for taxi in taxis: try: dur = getTimeDiff(taxi.getSteps()) durationList.append(dur) if dur >= 1479: print("maxtaxi", taxi) except TypeError as e: print("Error by taxi %s : %s" % (taxi.id, e.message)) print("no", len(durationList)) print("avg", sum(durationList) / (len(durationList) + 0.0), "s =", end=" ") CalcTime.getSecsInTime(int(round(sum(durationList) / (len(durationList) + 0.0)))) print("min", min(durationList), "s =", end=" ") CalcTime.getSecsInTime(min(durationList)) print("max", max(durationList), "s =", end=" ") CalcTime.getSecsInTime(max(durationList))
def clacAvg(): durationList = [] taxis = reader.readAnalysisInfo() for taxi in taxis: try: dur = getTimeDiff(taxi.getSteps()) durationList.append(dur) if dur >= 1479: print("maxtaxi", taxi) except TypeError as e: print("Error by taxi %s : %s" % (taxi.id, e.message)) print("no", len(durationList)) print("avg", sum(durationList) / (len(durationList) + 0.0), "s =", end=' ') CalcTime.getSecsInTime( int(round(sum(durationList) / (len(durationList) + 0.0)))) print("min", min(durationList), "s =", end=' ') CalcTime.getSecsInTime(min(durationList)) print("max", max(durationList), "s =", end=' ') CalcTime.getSecsInTime(max(durationList))
def clacAvg(): durationList = [] taxis = reader.readAnalysisInfo() for taxi in taxis: try: dur = getTimeDiff(taxi.getSteps()) durationList.append(dur) if dur >= 1479: print "maxtaxi", taxi except TypeError, e: print "Error by taxi %s : %s" % (taxi.id, e.message) print "no", len(durationList) print "avg", sum(durationList) / (len(durationList) + 0.0), "s =", CalcTime.getSecsInTime( int(round(sum(durationList) / (len(durationList) + 0.0)))) print "min", min(durationList), "s =", CalcTime.getSecsInTime(min(durationList)) print "max", max(durationList), "s =", CalcTime.getSecsInTime(max(durationList)) def drawPieChart(): """Draws a pie chart with the relative travel time aberrance.""" #sets the window size figure(1, figsize=(10, 10)) labels = 'Diff <10%', 'Diff 10%-30%', 'Diff 30%-50%', 'Diff 50%-70%', 'Diff 70%-90%', 'Diff >90%' #fracs = [15,30,45, 10,66,7] pie(getPiePieces(),
return fcd #FCD duration def clacAvg(): durationList=[] taxis=reader.readAnalysisInfo() for taxi in taxis: try: dur=getTimeDiff(taxi.getSteps()) durationList.append(dur) if dur >=1479: print "maxtaxi", taxi except TypeError, e: print "Error by taxi %s : %s" %(taxi.id,e.message) print "no",len(durationList) print "avg", sum(durationList)/(len(durationList)+0.0),"s =", CalcTime.getSecsInTime(int(round(sum(durationList)/(len(durationList)+0.0)))) print "min", min(durationList),"s =", CalcTime.getSecsInTime(min(durationList)) print "max", max(durationList),"s =", CalcTime.getSecsInTime(max(durationList)) def drawPieChart(): """Draws a pie chart with the relative travel time aberrance.""" #sets the window size figure(1, figsize=(10,10)) labels = 'Diff <10%', 'Diff 10%-30%', 'Diff 30%-50%', 'Diff 50%-70%', 'Diff 70%-90%', 'Diff >90%' #fracs = [15,30,45, 10,66,7] pie(getPiePieces(), labels=labels, autopct='%1.1f%%', shadow=True, colors=colorTupel, labeldistance=1.2 ) title("Relative Differenz der Reisezeit zwischen simulierten Taxis und Taxi-FCD\n(nicht simulierten Taxi-FCD!)\n")