本文整理汇总了Python中util.Reader.readAnalysisInfo方法的典型用法代码示例。如果您正苦于以下问题:Python Reader.readAnalysisInfo方法的具体用法?Python Reader.readAnalysisInfo怎么用?Python Reader.readAnalysisInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Reader
的用法示例。
在下文中一共展示了Reader.readAnalysisInfo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getBars
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getBars():
"""Classifies the time difference in single bars."""
taxis=reader.readAnalysisInfo(WEE)
barsDict={}
barsDictSim={}
stdDev=[]
mw=[]
for taxi in taxis:
if len(taxi.getSteps())<1:
continue
try:
#diff=getTimeDiff(taxi.getSteps(),False)
diffSim,fcd,sim,no=getTimeDiff(taxi.getSteps())
#anna
if diffSim>150:
print diffSim," ",taxi.id," ",no," ",fcd," ",sim
#standard deviation
stdDev.append((diffSim-9.46)*(diffSim-9.46))
mw.append(diffSim)
#classify the absolute time difference
#barsDict[(diff/10)*10]=barsDict.setdefault((diff/10)*10,0)+1
barsDictSim[(diffSim/10)*10]=barsDictSim.setdefault((diffSim/10)*10,0)+1
except TypeError, e:
tueNichts=True
示例2: getBarsMulti
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getBarsMulti():
"""Classifies the time difference in single bars.
But uses insted of getBars() several analysis-File and calculates a mean value"""
fileIter=iglob(path.newPath(path.main,"auswertung/reisezeit/analysisFiles/taxiAnalysisInformation*.xml"))
fcdDiffDict={}
simDiffDict={}
barsDict={}
barsDictSim={}
stdDev=[]
mw=[]
#calc diffs
for file in fileIter: #for each
path.analysisWEE=path.newPath(file)
print path.analysisWEE
taxis=reader.readAnalysisInfo(WEE)
for taxi in taxis:
if len(taxi.getSteps())<1:
continue
try:
#diff=getTimeDiff(taxi.getSteps(),False)
diffSim,fcd,sim,no=getTimeDiff(taxi.getSteps())
simDiffDict.setdefault(taxi.id,[]).append(sim)
fcdDiffDict.setdefault(taxi.id,fcd)
except TypeError, e:
tueNichts=True
示例3: getBars
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getBars():
"""Classifies the time difference in single bars."""
taxis = reader.readAnalysisInfo(WEE)
barsDict = {}
barsDictSim = {}
stdDev = []
mw = []
for taxi in taxis:
if len(taxi.getSteps()) < 1:
continue
try:
# diff=getTimeDiff(taxi.getSteps(),False)
diffSim, fcd, sim, no = getTimeDiff(taxi.getSteps())
# anna
if diffSim > 150:
print(diffSim, " ", taxi.id, " ", no, " ", fcd, " ", sim)
# standard deviation
stdDev.append((diffSim - 9.46) * (diffSim - 9.46))
mw.append(diffSim)
# classify the absolute time difference
# barsDict[(diff/10)*10]=barsDict.setdefault((diff/10)*10,0)+1
barsDictSim[
(diffSim / 10) * 10] = barsDictSim.setdefault((diffSim / 10) * 10, 0) + 1
except TypeError as e:
tueNichts = True
# print "Error by taxi %s : %s" %(taxi.id,e.message)
print("mw", sum(mw) / (len(mw) + 0.0)) # 9.46
print("standard deviation ", sqrt(sum(stdDev) / (len(stdDev) + 0.0)))
return (barsDictSim, barsDict)
示例4: getPiePieces
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getPiePieces():
"""Classifies the relative time difference into pieces (intervals) used for drawing the pie chart."""
taxis = reader.readAnalysisInfo()
pieces = [0, 0, 0, 0, 0, 0]
for taxi in taxis:
try:
diff = getTimeDiff(taxi.getSteps())
except TypeError as e:
print("Error by taxi %s : %s" % (taxi.id, e.message))
# classify the relative time difference
#<10%', '10%-30%', '30%-50%', '50%-70%', '70%-90%', '>90%
if diff < 10:
pieces[0] += 1
elif diff < 30:
pieces[1] += 1
elif diff < 50:
pieces[2] += 1
elif diff < 70:
pieces[3] += 1
elif diff < 90:
pieces[4] += 1
else:
pieces[5] += 1
print(pieces)
print(sum(pieces))
return pieces
示例5: getAveragedValues
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getAveragedValues(interval):
"""catches all data in the given interval steps and calculates the average speed for each interval."""
timeValues = range(0, 86410, interval)
fcdValues = [[] for i in range(0, 86410, interval)]
simFcdValues = [[] for i in range(0, 86410, interval)]
vtypeValues = [[] for i in range(0, 86410, interval)]
relErrorValues = [[] for i in range(0, 86410, interval)]
absErrorValues = [[] for i in range(0, 86410, interval)]
fcdValuesNo = [set() for i in range(0, 86410, interval)]
simFcdValuesNo = [set() for i in range(0, 86410, interval)]
vtypeValuesNo = [set() for i in range(0, 86410, interval)]
taxis = reader.readAnalysisInfo(WEE)
# helper function
def calcAverageOrLen(list, no=False):
for i in range(len(list)):
if len(list[i]) > 0:
if no: # if no True clac Len
list[i] = len(list[i])
else:
list[i] = sum(list[i]) / len(list[i])
else:
list[i] = None
return list
for taxi in taxis:
for step in taxi.getSteps():
if step.source == SOURCE_FCD:
# add the speed to the corresponding time interval
fcdValues[step.time / interval].append(step.speed)
fcdValuesNo[step.time / interval].add(taxi.id)
elif step.source == SOURCE_SIMFCD:
# add the speed to the corresponding time interval
simFcdValues[step.time / interval].append(step.speed)
simFcdValuesNo[step.time / interval].add(taxi.id)
elif step.source == SOURCE_VTYPE:
# add the speed to the corresponding time interval
vtypeValues[step.time / interval].append(step.speed)
vtypeValuesNo[step.time / interval].add(taxi.id)
vtypeValues = calcAverageOrLen(vtypeValues)
fcdValues = calcAverageOrLen(fcdValues)
simFcdValues = calcAverageOrLen(simFcdValues)
vtypeValuesNo = calcAverageOrLen(vtypeValuesNo, True)
fcdValuesNo = calcAverageOrLen(fcdValuesNo, True)
simFcdValuesNo = calcAverageOrLen(simFcdValuesNo, True)
# calc relative Error
for i in range(len(fcdValues)):
if simFcdValues[i] is None or fcdValues[i] is None:
relErrorValues[i] = None
absErrorValues[i] = None
else:
# (angezeigter-richtiger Wert)
absErr = simFcdValues[i] - fcdValues[i]
relErrorValues[i] = absErr / float(fcdValues[i]) * 100
absErrorValues[i] = absErr
return ([timeValues, fcdValues, simFcdValues, vtypeValues, fcdValuesNo, simFcdValuesNo, vtypeValuesNo,
relErrorValues, absErrorValues], interval)
示例6: main
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def main():
print "start program"
global taxis, edgeDict
#load data
edgeDict=load(open(path.edgeLengthDict,'r'))
taxis=reader.readAnalysisInfo(WEE)
plotAllTaxis()
#plotIt(taxiId)
#reader.readEdgesLength()
print "end"
示例7: clacAvg
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
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)
示例8: getBarsMulti
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getBarsMulti():
"""Classifies the time difference in single bars.
But uses insted of getBars() several analysis-File and calculates a mean value"""
fileIter = iglob(path.newPath(
path.main, "auswertung/reisezeit/analysisFiles/taxiAnalysisInformation*.xml"))
fcdDiffDict = {}
simDiffDict = {}
barsDict = {}
barsDictSim = {}
stdDev = []
mw = []
# calc diffs
for file in fileIter: # for each
path.analysisWEE = path.newPath(file)
print(path.analysisWEE)
taxis = reader.readAnalysisInfo(WEE)
for taxi in taxis:
if len(taxi.getSteps()) < 1:
continue
try:
# diff=getTimeDiff(taxi.getSteps(),False)
diffSim, fcd, sim, no = getTimeDiff(taxi.getSteps())
simDiffDict.setdefault(taxi.id, []).append(sim)
fcdDiffDict.setdefault(taxi.id, fcd)
except TypeError as e:
tueNichts = True
# print "Error by taxi %s : %s" %(taxi.id,e.message)
for taxi, simList in simDiffDict.iteritems():
simDiffDict[taxi] = sum(simList) / (len(simList) + 0.0)
# create barsDict
for taxi in fcdDiffDict:
fcd = fcdDiffDict[taxi]
sim = simDiffDict[taxi]
diff = sim - fcd
relDiff = int(round(((100.0 * diff) / fcd)))
barsDictSim[
(relDiff / 10) * 10] = barsDictSim.setdefault((relDiff / 10) * 10, 0) + 1
# standard deviation
stdDev.append((relDiff - 9.53) * (relDiff - 9.53))
mw.append(relDiff)
print("mw", sum(mw) / (len(mw) + 0.0)) # 9.91 #kor 0.48
print("standard deviation ", sqrt(sum(stdDev) / (len(stdDev) + 0.0)))
return (barsDictSim, barsDict)
示例9: clacAvg
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
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))
示例10: getDataForTaxi
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getDataForTaxi(taxiId):
"""Gets the Data for a single Taxi"""
values=[[],[],[],[],[],[]] #x1,y1,x2,y2,x3,y3
starttime=0
taxis=reader.readAnalysisInfo(WEE)
for step in taxis[taxis.index(taxiId)].getSteps():
if step.source==SOURCE_FCD:
values[0].append(step.time-starttime)
values[1].append(step.speed)
elif step.source==SOURCE_SIMFCD:
values[2].append(step.time-starttime)
values[3].append(step.speed)
elif step.source==SOURCE_VTYPE:
if starttime==0:
starttime=step.time
values[4].append(step.time-starttime)
values[5].append(step.speed)
return (values,starttime)
示例11: main
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def main():
print("start program")
global taxis, edgeDict
# decide if you want to save charts for every taxi or show a single one
all = False
taxiId = "316_3"
# load data
edgeDict = load(open(path.edgeLengthDict, "r"))
taxis = reader.readAnalysisInfo(WEE)
# reader.readEdgesLength()
if all:
plotAllTaxis()
else:
plotIt(taxiId)
show()
print("end")
示例12: getSpeeds
# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readAnalysisInfo [as 别名]
def getSpeeds():
"""Reads the speeds from the analysis file"""
taxis=reader.readAnalysisInfo(WEE)
#read speeds for every edge
for taxi in taxis:
for step in taxi.getSteps():
if step.source==SOURCE_SIMFCD:
vtypeEdgeDict.setdefault(step.edge,[]).append(float(step.speed))
elif step.source==SOURCE_FCD:
fcdEdgeDict.setdefault(step.edge,[]).append(float(step.speed))
#calc avg speed for each edge
#print fcdEdgeDict["558300689"]
#print vtypeEdgeDict["558300689"]
for edge in fcdEdgeDict:
fcdEdgeDict[edge]=sum(fcdEdgeDict[edge])/len(fcdEdgeDict[edge])
print len(fcdEdgeDict)
for edge in vtypeEdgeDict:
vtypeEdgeDict[edge]=sum(vtypeEdgeDict[edge])/len(vtypeEdgeDict[edge])
print len(vtypeEdgeDict)