Mercurial Hosting > traffic-intelligence
diff python/storage.py @ 660:994dd644f6ab
corrected impact of warmUpLastInstant
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 15 May 2015 23:09:49 +0200 |
parents | df9ddeaee4a6 |
children | 455f9b93819c |
line wrap: on
line diff
--- a/python/storage.py Thu May 14 23:18:44 2015 +0200 +++ b/python/storage.py Fri May 15 23:09:49 2015 +0200 @@ -648,6 +648,9 @@ for example, there seems to be 5 simulation steps per simulated second in VISSIM, so simulationStepsPerTimeUnit should be 5, so that all times correspond to the number of the simulation step (and can be stored as integers) + + Objects positions will be considered only after warmUpLastInstant + (if the object has no such position, it won't be loaded) Assumed to be sorted over time''' objects = {} # dictionary of objects index by their id @@ -658,10 +661,10 @@ data = read_csv(filename, delimiter=';', comment='*', header=0, skiprows = 1) generatePDLaneColumn(data) data['TIME'] = data['$VEHICLE:SIMSEC']*simulationStepsPerTimeUnit + if warmUpLastInstant is not None: + data = data[data['TIME']>=warmUpLastInstant] grouped = data.loc[:,['NO','TIME']].groupby(['NO'], as_index = False) instants = grouped['TIME'].agg({'first': min, 'last': max}) - if warmUpLastInstant is not None: - instants = instants[instants['first'] >= warmUpLastInstant] for row_index, row in instants.iterrows(): objNum = int(row['NO']) tmp = data[data['NO'] == objNum] @@ -670,7 +673,6 @@ objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory(S = round(tmp['POS'].tolist(), nDecimals), Y = round(tmp['POSLAT'].tolist(), nDecimals), lanes = tmp['LANE'].tolist()) return objects.values() else: - firstInstants = {} inputfile = openCheck(filename, quitting = True) # data = pd.read_csv(filename, skiprows=15, delimiter=';') # skip header: 15 lines + 1 @@ -682,13 +684,12 @@ s = float(data[4]) y = float(data[5]) lane = data[2]+'_'+data[3] - if objNum not in firstInstants: - firstInstants[objNum] = instant - if warmUpLastInstant is None or firstInstants[objNum] >= warmUpLastInstant: + if objNum not in objects: + if warmUpLastInstant is None or instant >= warmUpLastInstant: if nObjects < 0 or len(objects) < nObjects: objects[objNum] = moving.MovingObject(num = objNum, timeInterval = moving.TimeInterval(instant, instant)) objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory() - if (warmUpLastInstant is None or firstInstants[objNum] >= warmUpLastInstant) and objNum in objects: + if (warmUpLastInstant is None or instant >= warmUpLastInstant) and objNum in objects: objects[objNum].timeInterval.last = instant objects[objNum].curvilinearPositions.addPositionSYL(s, y, lane) line = readline(inputfile, '*$')