Mercurial Hosting > traffic-intelligence
comparison python/ubc_utils.py @ 306:93d851d0d21e
bug correction, minor work on indicators
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 02 Apr 2013 15:27:42 -0400 |
parents | 1f253f218b9f |
children | a70c205ebdd9 |
comparison
equal
deleted
inserted
replaced
305:ca9131968bce | 306:93d851d0d21e |
---|---|
168 featureNumbers += o.featureNumbers | 168 featureNumbers += o.featureNumbers |
169 return featureNumbers | 169 return featureNumbers |
170 | 170 |
171 def loadInteractions(filename, nInteractions = -1): | 171 def loadInteractions(filename, nInteractions = -1): |
172 'Loads interactions from the old UBC traffic event format' | 172 'Loads interactions from the old UBC traffic event format' |
173 from event import Interaction | 173 from events import Interaction |
174 from indicators import SeverityIndicator | 174 from indicators import SeverityIndicator |
175 file = utils.openCheck(filename) | 175 file = utils.openCheck(filename) |
176 if (not file): | 176 if (not file): |
177 return [] | 177 return [] |
178 | 178 |
182 while (lines != []) and ((nInteractions<0) or (interactionNum<nInteractions)): | 182 while (lines != []) and ((nInteractions<0) or (interactionNum<nInteractions)): |
183 parsedLine = [int(n) for n in lines[0].split(' ')] | 183 parsedLine = [int(n) for n in lines[0].split(' ')] |
184 inter = Interaction(interactionNum, TimeInterval(parsedLine[1],parsedLine[2]), parsedLine[3], parsedLine[4], categoryNum = parsedLine[5]) | 184 inter = Interaction(interactionNum, TimeInterval(parsedLine[1],parsedLine[2]), parsedLine[3], parsedLine[4], categoryNum = parsedLine[5]) |
185 | 185 |
186 indicatorFrameNums = [int(n) for n in lines[1].split(' ')] | 186 indicatorFrameNums = [int(n) for n in lines[1].split(' ')] |
187 inter.indicators = [] | |
188 for indicatorNum,line in enumerate(lines[2:]): | 187 for indicatorNum,line in enumerate(lines[2:]): |
189 values = {} | 188 values = {} |
190 for i,v in enumerate([float(n) for n in line.split(' ')]): | 189 for i,v in enumerate([float(n) for n in line.split(' ')]): |
191 if not ignoredValue[indicatorNum] or v != ignoredValue[indicatorNum]: | 190 if not ignoredValue[indicatorNum] or v != ignoredValue[indicatorNum]: |
192 values[indicatorFrameNums[i]] = v | 191 values[indicatorFrameNums[i]] = v |