Mercurial Hosting > traffic-intelligence
changeset 745:3d0321abb564 dev
merged
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 10 Sep 2015 15:49:13 -0400 |
parents | ed6ff2ec0aeb (diff) 4b3518f6dd01 (current diff) |
children | e7ff0f60fef8 d45ab817ee11 |
files | |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/python/storage.py Fri Aug 28 10:42:00 2015 -0400 +++ b/python/storage.py Thu Sep 10 15:49:13 2015 -0400 @@ -829,7 +829,7 @@ return nStationary, nVehicles -def countCollisionsVissim(filename, lanes = None, collisionTimeDifference = 0.2): +def countCollisionsVissim(filename, lanes = None, collisionTimeDifference = 0.2, lowMemory = True): '''Counts the number of collisions per lane in a VISSIM trajectory file To distinguish between cars passing and collision, @@ -840,12 +840,14 @@ from pandas import read_csv, merge data = read_csv(filename, delimiter=';', comment='*', header=0, skiprows = 1, usecols = ['LANE\LINK\NO', 'LANE\INDEX', '$VEHICLE:SIMSEC', 'NO', 'POS'], low_memory = lowMemory) data = selectPDLanes(data, lanes) + data = data.convert_objects(convert_numeric=True) + merged = merge(data, data, how='inner', left_on=['LANE\LINK\NO', 'LANE\INDEX', '$VEHICLE:SIMSEC'], right_on=['LANE\LINK\NO', 'LANE\INDEX', '$VEHICLE:SIMSEC'], sort = False) merged = merged[merged['NO_x']>merged['NO_y']] nCollisions = 0 for name, group in merged.groupby(['LANE\LINK\NO', 'LANE\INDEX', 'NO_x', 'NO_y']): - diff = group['POS_x'].convert_objects(convert_numeric=True)-group['POS_y'].convert_objects(convert_numeric=True) + diff = group['POS_x']-group['POS_y'] # diff = group['POS_x']-group['POS_y'] # to check the impact of convert_objects and the possibility of using type conversion in read_csv or function to convert strings if any if len(diff) >= 2 and npmin(diff) < 0 and npmax(diff) > 0: xidx = diff[diff < 0].argmax()