# HG changeset patch # User Nicolas Saunier # Date 1288331618 14400 # Node ID b8b3768f8d543cf62cb840dd7822b3d4491d4f61 # Parent 61fe73df2d36d5ddd415a00c1ae6ca4f113c5b6b added functions to load interactions and indicators diff -r 61fe73df2d36 -r b8b3768f8d54 python/ubc_utils.py --- a/python/ubc_utils.py Wed Oct 27 18:32:27 2010 -0400 +++ b/python/ubc_utils.py Fri Oct 29 01:53:38 2010 -0400 @@ -17,6 +17,32 @@ 'prototype', 'contoursequence'] +severityIndicatorNames = ['Distance', + 'Cosine', + 'Velocity Cosine', + 'Speed Differential', + 'Collision Probability', + 'Severity Index', + 'TTC'] + +# severityIndicator = {'Distance': 0, +# 'Cosine': 1, +# 'Velocity Cosine': 2, +# 'Speed Differential': 3, +# 'Collision Probability': 4, +# 'Severity Index': 5, +# 'TTC': 6} + +mostSevereIsMax = [False, + False, + True, + True, + True, + True, + False] + +ignoredValue = [None, None, None, None, None, None, -1] + def getFileType(s): 'Finds the type in fileTypeNames' for fileType in fileTypeNames: @@ -104,6 +130,37 @@ file.close() return objects +def loadInteractions(filename, nInteractions = -1): + 'Loads interactions from the old UBC traffic event format' + from event import Interaction + from moving import SeverityIndicator + file = utils.openCheck(filename) + if (not file): + return [] + + interactions = [] + interactionNum = 0 + lines = utils.getLines(file) + while (lines != []) and ((nInteractions<0) or (interactionNum