Skip to content

Commit f21c90e

Browse files
authored
add new ut version and update links to latest version (#5)
1 parent 6c41cc0 commit f21c90e

File tree

5 files changed

+108
-68
lines changed

5 files changed

+108
-68
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
doc/build
66
doc/source/user_guide/faq/index.rst
77
doc/source/user_guide/data_visualization/index.rst
8+
doc/source/user_guide/data_analysis/index.rst
9+
doc/source/user_guide/data_loading_and_saving/index.rst
10+
811
*api
912

1013
# distribution

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ image_base:
5959
RUN mkdir /deps
6060
COPY dist/*.whl /deps/
6161
RUN pip install /deps/*.whl; rm -r /deps;
62-
RUN dlr-downloader --name urban --version 1.1.0 --path /tmp;
62+
RUN dlr-downloader --name urban --version 1.2.0 --path /tmp;
6363
RUN python -c 'import tilemapbase; tilemapbase.init(create=True)'" > dockerfile
6464
6565
- |

doc/source/user_guide/data_loading_and_saving/dlr-ut-dataset.pct.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#%% [markdown]
22
# # DLR Urban Traffic Dataset (DLR UT)
33
#
4-
# This example should give a short overview on how to load the [Urban Traffic
5-
# Dataset](https://zenodo.org/records/11396372) which is hosted on Zenodo.
4+
# This example should give a short overview on how to load the [DLR Urban Traffic
5+
# Dataset](https://doi.org/10.5281/zenodo.11396371) which is hosted on Zenodo.
66
#
77
# ## Download dataset
88
#
99
# At first, we need to download the dataset. For that purpose, helper classes
1010
# are available in `tasi` that we will utilize in the following. In particular,
1111
# since we want to download the DLR UT dataset, we use the. The class contains a
1212
# `tasi.dlr.dataset.DLRUTVersion` enumerator that may be used to
13-
# specify the version of the dataset to download.
13+
# specify the version of the dataset to download.
1414
# %%
1515
import os
1616
from tasi.dlr.dataset import DLRUTDatasetManager, DLRUTVersion
1717

18-
dataset = DLRUTDatasetManager(DLRUTVersion.v1_1_0)
18+
dataset = DLRUTDatasetManager(DLRUTVersion.v1_2_0)
1919
path = dataset.load(path='/tmp')
2020
path
21-
#%% [markdown]
21+
#%% [markdown]
2222
# The dataset is now available in the `/tmp` directory. Let's have
2323
# a look into the dataset and list the available traffic information
2424
#%%
@@ -30,19 +30,19 @@
3030
# We can now utilize the `tasi.dlr.dataset.DLRTrajectoryDataset` class to load
3131
# the trajectory data from the directory. For demonstration purpose, let's load
3232
# the first batch of the dataset.
33-
#%%
33+
#%%
3434
from tasi.dlr import DLRTrajectoryDataset
3535

3636
ds = DLRTrajectoryDataset.from_csv(dataset.trajectory("/tmp")[0])
3737
ds
3838
#%% [markdown]
3939
# Note that the `Dataset` is represented as a `pandas.DataFrame` since it
4040
# inherits from it. The index of the `Dataset` contains the `timestamp` of a
41-
# traffic participant's state and its `id` as a unique identifier.
41+
# traffic participant's state and its `id` as a unique identifier.
4242
#
4343
# The traffic participant's state include various information, including the
44-
# center position, the velocity, dimension and classification type.
45-
#
44+
# center position, the velocity, dimension and classification type.
45+
#
4646
# ## Load traffic light data
4747
#
4848
# The DLR UT dataset also contains information of the traffic lights. We utilize
@@ -58,7 +58,7 @@
5858
#
5959
# The DLR Research Intersection is equipped with a weather station stat collects
6060
# various information. We can utilize the `tasi.dataset.WeatherDataset` to load
61-
# some of this information.
61+
# some of this information.
6262
#%%
6363
from tasi.dataset import WeatherDataset
6464

@@ -83,5 +83,24 @@
8383

8484
road_conditions = RoadConditionDataset.from_csv(dataset.road_condition("/tmp")[0])
8585
road_conditions
86+
# %% [markdown]
87+
# ## Load traffic volume data
88+
#
89+
# The DLR UT dataset contains meta information like traffic volume data that were extracted from the raw trajectory data.
90+
# %%
91+
from tasi.dataset import TrafficVolumeDataset
92+
93+
traffic_volume = TrafficVolumeDataset.from_csv(dataset.traffic_volume("/tmp")[0])
94+
traffic_volume
95+
# %% [markdown]
96+
# ## Load OpenSCENARIO files
97+
#
98+
# The DLR UT dataset contains the trajectory data in OpenSCENARIO format.
99+
# %%
100+
from tasi.dataset import TrafficVolumeDataset
101+
102+
openscenario_files = dataset.openscenario("/tmp")
103+
openscenario_files
104+
86105
#%% [markdown]
87-
# That's it for now. We hope this page helps you get started 😎
106+
# That's it for now. We hope this page helps you get started 😎

doc/source/user_guide/data_visualization/trajectory.pct.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
# # Visualization of trajectories
33
# If we work with trajectory data, we often want to visualize them from a
44
# so called `birds eye view`. The following example demonstrates how to achieve
5-
# this with `tasi` using the [Urban Traffic
6-
# Dataset](https://zenodo.org/records/11396372).
5+
# this with `tasi` using the [DLR Urban Traffic Dataset](https://doi.org/10.5281/zenodo.11396371).
76
#
87
# ## Load trajectories
98
# At first, let's load trajectories from the DLR dataset.
109
# %%
1110
from tasi.dlr.dataset import DLRUTDatasetManager, DLRUTVersion
1211
from tasi.dlr import DLRTrajectoryDataset
1312

14-
dataset = DLRUTDatasetManager(DLRUTVersion.v1_1_0)
15-
ds = DLRTrajectoryDataset.from_csv(dataset.trajectory("/tmp")[0])
13+
dataset = DLRUTDatasetManager(DLRUTVersion.v1_2_0)
14+
# select a trajectory file from the middle of the dataset to include data from all object classes
15+
ut = DLRTrajectoryDataset.from_csv(dataset.trajectory("/tmp")[48])
16+
ut
1617
# %% [markdown]
1718
# ## Plot trajectories
1819
# We now utilize the `TrajectoryPlotter` to visualize the trajectories of the
@@ -24,28 +25,31 @@
2425
f, ax = plt.subplots()
2526

2627
plotter = TrajectoryPlotter()
27-
plotter.plot(ds, ax=ax)
28+
plotter.plot(ut, ax=ax)
2829
# %% [markdown]
2930
# ### Change trajectory color
3031
# Note that the trajectories are colorized with the default color which we can
3132
# change so any arbitrary color, such as `lightgray`.
3233
# %%
3334
f, ax = plt.subplots()
34-
plotter.plot(ds, ax=ax, color="lightgray")
35+
plotter.plot(ut, ax=ax, color="lightgray")
3536
# %% [markdown]
3637
# ### Change color of a specific trajectory
3738
# You can also define the color of a specific trajectory.
3839
# %%
3940
f, ax = plt.subplots()
40-
plotter.plot(ds, ax=ax, color="black", trajectory_kwargs={ds.ids[-1]: {"color": "red"}})
41+
plotter.plot(ut, ax=ax, color="black", trajectory_kwargs={
42+
ut.ids[-20]: {
43+
"color": "red"
44+
}
45+
})
4146
# %% [markdown]
4247
# ### Change trajectory opacity
4348
# or even change the opacity of each trajectory to quickly get an overview of
44-
# the traffic density. Let's change the opacity to 10% via the `alpha` argument
45-
# and set the color to `black`.
49+
# the traffic density. Let's change the opacity to 20% via the `alpha` argument.
4650
# %%
4751
f, ax = plt.subplots()
48-
plotter.plot(ds, ax=ax, color="black", alpha=0.1)
52+
plotter.plot(ut, ax=ax, alpha=0.2)
4953
# %% [markdown]
5054
# The plot already indicates the various traffic volumes on the different routes
5155
# at the intersection.
@@ -60,14 +64,12 @@
6064
f, ax = plt.subplots()
6165

6266
# plot the orthophoto first
63-
roi = np.array([604675, 5792680, 604875, 5792870]).reshape(-1, 2)
64-
65-
bbox_plotter = BoundingboxPlotter(roi, LowerSaxonyOrthophotoTile())
67+
bbox_plotter = BoundingboxPlotter(ut.roi, LowerSaxonyOrthophotoTile())
6668
bbox_plotter.plot(ax)
6769

6870
# and the trajectories on top
6971
tj_plotter = TrajectoryPlotter()
70-
tj_plotter.plot(ds, ax=ax)
72+
tj_plotter.plot(ut, ax=ax)
7173

7274
# hide the axis
7375
_ = ax.axis("off")
@@ -79,7 +81,7 @@
7981
f, ax = plt.subplots()
8082

8183
bbox_plotter.plot(ax, alpha=0.5)
82-
tj_plotter.plot(ds, ax=ax, alpha=0.25)
84+
tj_plotter.plot(ut, ax=ax, alpha=0.25)
8385

8486
_ = ax.axis("off")
8587

@@ -96,28 +98,18 @@
9698
# load dataset
9799
dataset = DLRHTDatasetManager(DLRHTVersion.v1_0_0)
98100
path = dataset.load(path="/tmp")
99-
ds = DLRTrajectoryDataset.from_csv(
100-
dataset.trajectory("/tmp")[3]
101-
) # use 3 as it contains objects from all object classes
101+
# use 3 as it contains objects from all object classes
102+
ht = DLRTrajectoryDataset.from_csv(dataset.trajectory("/tmp")[3])
102103

103104
f, ax = plt.subplots()
104105

105106
# plot the orthophoto first
106-
roi = np.array(
107-
[
108-
ds.center.easting.min(),
109-
ds.center.northing.min(),
110-
ds.center.easting.max(),
111-
ds.center.northing.max(),
112-
]
113-
).reshape(-1, 2)
114-
115-
bbox_plotter = BoundingboxPlotter(roi, LowerSaxonyOrthophotoTile())
107+
bbox_plotter = BoundingboxPlotter(ht.roi, LowerSaxonyOrthophotoTile())
116108
bbox_plotter.plot(ax)
117109

118110
# and the trajectories on top
119111
tj_plotter = DLRTrajectoryPlotter()
120-
tj_plotter.plot(ds, ax=ax)
112+
tj_plotter.plot(ht, ax=ax)
121113

122114
# hide the axis
123115
_ = ax.axis("off")

tasi/dlr/dataset.py

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pathlib import Path
77
from typing import List
88

9+
import numpy as np
910
import requests
1011
from tqdm import tqdm
1112

@@ -98,9 +99,7 @@ def load(self, path: Path) -> str:
9899
# define final path
99100
export_path = path.joinpath(self.name)
100101

101-
logging.info(
102-
"Checking if dataset already downloaded %s", export_path.absolute()
103-
)
102+
logging.info("Checking if dataset already downloaded %s", export_path.absolute())
104103
if not export_path.exists():
105104

106105
logging.info(f"Downloading dataset from {self.url}")
@@ -176,6 +175,17 @@ def road_condition(self, path: Path) -> List[str]:
176175
"""
177176
return self._dataset(path, "road_condition")
178177

178+
def traffic_volume(self, path: Path) -> List[str]:
179+
"""List of files with traffic volume data.
180+
181+
Args:
182+
path (Path): The path of the dataset
183+
184+
Returns:
185+
List[str]: The files with traffic volume data
186+
"""
187+
return self._dataset(path, "traffic_volume")
188+
179189

180190
class DLRUTVersion(Enum):
181191
"""The available version of the DLR UT dataset"""
@@ -191,6 +201,10 @@ class DLRUTVersion(Enum):
191201
"""The road condition information was moved into a new sub dataset from the weather data.
192202
"""
193203

204+
v1_2_0 = "v1.2.0"
205+
"""New folder structure to split raw and metadata. Add new metadata "traffic_volume" and "openscenario". Improve classification of pedestrians and bicycles.
206+
"""
207+
194208

195209
class DLRUTDatasetManager(DLRDatasetManager):
196210
"""A manager to load the DLR UT dataset from zenodo"""
@@ -199,15 +213,18 @@ class DLRUTDatasetManager(DLRDatasetManager):
199213
DLRUTVersion.v1_0_0.value: 11396372,
200214
DLRUTVersion.v1_0_1.value: 13907201,
201215
DLRUTVersion.v1_1_0.value: 14025010,
216+
DLRUTVersion.v1_2_0.value: 14773161,
202217
}
203218
"""Dict[str, int]: An internal mapping between version and the zenodo id
204219
"""
205220

206-
ARCHIVE = {
207-
DLRUTVersion.v1_0_0.value: "DLR-UT",
208-
DLRUTVersion.v1_0_1.value: "DLR-Urban-Traffic-dataset",
209-
DLRUTVersion.v1_1_0.value: "DLR-Urban-Traffic-dataset",
210-
}
221+
ARCHIVE = dict({
222+
DLRUTVersion.v1_0_0.value: "DLR-UT"
223+
},
224+
**{
225+
v: "DLR-Urban-Traffic-dataset"
226+
for v in list(VERSION.keys())[1:]
227+
})
211228

212229
@classmethod
213230
def area(cls):
@@ -265,6 +282,17 @@ def air_quality(self, path: Path) -> List[str]:
265282
"""
266283
return self._dataset(path, "air_quality")
267284

285+
def openscenario(self, path: Path) -> List[str]:
286+
"""List of files with OpenSCENARIO data.
287+
288+
Args:
289+
path (Path): The path of the dataset
290+
291+
Returns:
292+
List[str]: The files with OpenSCENARIO data
293+
"""
294+
return self._dataset(path, "openscenario")
295+
268296

269297
class ObjectClass(IntEnum):
270298
"""
@@ -349,9 +377,7 @@ def mru(self):
349377
Returns:
350378
DLRTrajectoryDataset: Dataset of all motorized objects.
351379
"""
352-
return self.get_by_object_class(
353-
[ObjectClass.motorbike, ObjectClass.car, ObjectClass.van, ObjectClass.truck]
354-
)
380+
return self.get_by_object_class([ObjectClass.motorbike, ObjectClass.car, ObjectClass.van, ObjectClass.truck])
355381

356382
@property
357383
def vru(self):
@@ -363,6 +389,21 @@ def vru(self):
363389
"""
364390
return self.get_by_object_class([ObjectClass.pedestrian, ObjectClass.bicycle])
365391

392+
@property
393+
def roi(self):
394+
"""
395+
Return the region of interest of the dataset.
396+
397+
Returns:
398+
np.ndarray: The region of interest.
399+
"""
400+
return np.array([
401+
self.center.easting.min(),
402+
self.center.northing.min(),
403+
self.center.easting.max(),
404+
self.center.northing.max(),
405+
]).reshape(-1, 2)
406+
366407

367408
class DLRUTTrafficLightDataset(TrafficLightDataset):
368409

@@ -431,26 +472,11 @@ def _dataset(self, path: Path, variant: str) -> List[str]:
431472
path = Path(path)
432473

433474
# join dataset path and name, type and variant
434-
path = (
435-
path.joinpath(self.name)
436-
.joinpath(self.DATA_TYPES[variant])
437-
.joinpath(variant)
438-
)
475+
path = (path.joinpath(self.name).joinpath(self.DATA_TYPES[variant]).joinpath(variant))
439476

440477
# return file pathes of variant
441478
return [os.path.join(path, p) for p in sorted(os.listdir(path))]
442479

443-
def traffic_volume(self, path: Path) -> List[str]:
444-
"""List of files with air quality data.
445-
446-
Args:
447-
path (Path): The path of the dataset
448-
449-
Returns:
450-
List[str]: The files with air quality data
451-
"""
452-
return self._dataset(path, "traffic_volume")
453-
454480

455481
def download():
456482

0 commit comments

Comments
 (0)