Mercurial > hg > nsaunier > traffic-intelligence
comparison python/storage.py @ 643:bfaa6b95dae2
added function to plot curvilinear position as a function of time
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 10 Apr 2015 15:40:27 +0200 |
| parents | 932f96c89212 |
| children | 5ed2118c959d |
comparison
equal
deleted
inserted
replaced
| 642:932f96c89212 | 643:bfaa6b95dae2 |
|---|---|
| 659 so simulationStepsPerTimeUnit should be 5, | 659 so simulationStepsPerTimeUnit should be 5, |
| 660 so that all times correspond to the number of the simulation step (and can be stored as integers) | 660 so that all times correspond to the number of the simulation step (and can be stored as integers) |
| 661 | 661 |
| 662 Assumed to be sorted over time''' | 662 Assumed to be sorted over time''' |
| 663 objects = {} # dictionary of objects index by their id | 663 objects = {} # dictionary of objects index by their id |
| 664 firstInstants = {} | |
| 665 | 664 |
| 666 if usePandas: | 665 if usePandas: |
| 667 from pandas import read_csv | 666 from pandas import read_csv |
| 668 from numpy import min, max, round | 667 from numpy import min, max, round |
| 669 data = read_csv(filename, delimiter=';', skiprows=16) | 668 data = read_csv(filename, delimiter=';', skiprows=16) |
| 679 objects[objNum] = moving.MovingObject(num = objNum, timeInterval = moving.TimeInterval(row['first'], row['last'])) | 678 objects[objNum] = moving.MovingObject(num = objNum, timeInterval = moving.TimeInterval(row['first'], row['last'])) |
| 680 # positions should be rounded to nDecimals decimals only | 679 # positions should be rounded to nDecimals decimals only |
| 681 objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory(S = round(tmp['POS'].tolist(), nDecimals), Y = round(tmp['POSLAT'].tolist(), nDecimals), lanes = tmp['LANE'].tolist()) | 680 objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory(S = round(tmp['POS'].tolist(), nDecimals), Y = round(tmp['POSLAT'].tolist(), nDecimals), lanes = tmp['LANE'].tolist()) |
| 682 return objects.values() | 681 return objects.values() |
| 683 else: | 682 else: |
| 683 firstInstants = {} | |
| 684 inputfile = openCheck(filename, quitting = True) | 684 inputfile = openCheck(filename, quitting = True) |
| 685 # data = pd.read_csv(filename, skiprows=15, delimiter=';') | 685 # data = pd.read_csv(filename, skiprows=15, delimiter=';') |
| 686 # skip header: 15 lines + 1 | 686 # skip header: 15 lines + 1 |
| 687 line = readline(inputfile, '*$') | 687 line = readline(inputfile, '*$') |
| 688 while len(line) > 0:#for line in inputfile: | 688 while len(line) > 0:#for line in inputfile: |
