comparison trafficintelligence/utils.py @ 1077:3939ae415be0

Merging
author Wendlasida
date Fri, 20 Jul 2018 14:03:34 -0400
parents c04550f957ab
children 8734742c08c0
comparison
equal deleted inserted replaced
1076:108c5dc4e34a 1077:3939ae415be0
339 seconds = seconds - m*60 339 seconds = seconds - m*60
340 return time(h, m, seconds) 340 return time(h, m, seconds)
341 341
342 def timeToFrames(t, frameRate): 342 def timeToFrames(t, frameRate):
343 return frameRate*(t.hour*3600+t.minute*60+t.second) 343 return frameRate*(t.hour*3600+t.minute*60+t.second)
344
345 def timeModulo(t, duration):
346 'returns the time modulo the duration in min'
347 return time(t.hour, t.minute//duration, t.second)
344 348
345 def sortXY(X,Y): 349 def sortXY(X,Y):
346 'returns the sorted (x, Y(x)) sorted on X' 350 'returns the sorted (x, Y(x)) sorted on X'
347 D = {} 351 D = {}
348 for x, y in zip(X,Y): 352 for x, y in zip(X,Y):
589 return lambda x: percentile(x, 85) 593 return lambda x: percentile(x, 85)
590 else: 594 else:
591 print('Unknown aggregation method: {}'.format(funcStr)) 595 print('Unknown aggregation method: {}'.format(funcStr))
592 return None 596 return None
593 597
598 def aggregationMethods(methods, centiles = None):
599 aggFunctions = {}
600 headers = []
601 for method in methods:
602 if method == 'centile':
603 aggFunctions[method] = aggregationFunction(method, centiles)
604 for c in centiles:
605 headers.append('{}{}'.format(method,c))
606 else:
607 aggFunctions[method] = aggregationFunction(method)
608 headers.append(method)
609 return aggFunctions, headers
610
594 ######################### 611 #########################
595 # regression analysis using statsmodels (and pandas) 612 # regression analysis using statsmodels (and pandas)
596 ######################### 613 #########################
597 614
598 # TODO make class for experiments? 615 # TODO make class for experiments?