Note

Interactive online version: Binder badge

Using the DLRHTDataset#

This example shall give an overview of the methods and attributes that are available in the DLRHTDataset class.

Load trajectory data#

At first, we need to load the trajectory data of the dataset.

[1]:
from tasi.dlr import DLRTrajectoryDataset
from tasi.dlr.dataset import DLRHTDatasetManager, DLRHTVersion
from tasi.tests import DATA_PATH

dataset = DLRHTDatasetManager(DLRHTVersion.v1_1_0, path=DATA_PATH)
dataset.load()

ds = DLRTrajectoryDataset.from_csv(dataset.trajectory()[0])
ds
Extracting: 100%|██████████| 12/12 [00:00<00:00, 24.79file/s]
[1]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280701706084 -0.079 0.101 0.064 0.140 616517.884 5.793e+06 0.0 0.000 0.000 0.000 0.605 0.395 2.229 6.910 2.386 False 14.053 32.760 29.593 64.434
1728280711579163 0.089 0.600 0.593 -1.000 616874.078 5.794e+06 0.0 0.363 0.000 0.000 0.135 0.502 1.896 4.603 1.862 False -8.869 24.758 -23.115 -110.835
1728280715873385 -0.253 0.327 0.207 0.061 616362.445 5.793e+06 0.0 0.768 0.004 0.000 0.148 0.080 1.603 4.440 1.892 False 17.084 35.011 30.560 60.679
1728280715982681 -0.313 0.314 0.017 -0.045 614672.366 5.791e+06 0.0 0.392 0.000 0.000 0.233 0.375 1.859 6.250 1.932 False -37.444 42.502 -20.108 -151.427
1728280716727948 0.751 1.591 1.403 -2.409 616841.140 5.794e+06 0.0 0.000 0.000 0.011 0.989 0.000 3.970 18.454 3.073 False -10.055 25.734 -23.689 -112.937
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 06:04:59.954659+00:00 1728281098613793 0.030 0.540 0.539 0.535 616145.008 5.793e+06 0.0 0.823 0.042 0.000 0.114 0.022 1.385 4.331 1.802 False 23.553 44.165 37.360 57.679
1728281099054783 -0.117 0.245 -0.216 -0.247 617008.656 5.794e+06 0.0 0.745 0.088 0.000 0.117 0.051 1.530 4.072 1.747 False 13.955 38.632 36.023 68.594
1728281099273571 0.137 0.157 0.078 0.055 617563.625 5.796e+06 0.0 0.749 0.002 0.000 0.138 0.111 1.494 4.534 1.906 False -9.853 33.009 -31.505 -107.753
1728281099390791 -0.280 0.339 -0.190 0.318 617057.020 5.795e+06 0.0 0.818 0.001 0.000 0.121 0.060 1.385 4.833 1.958 False -13.472 36.415 -33.832 -111.618
1728281099712648 -0.354 0.660 -0.556 -1.290 615754.276 5.792e+06 0.0 0.000 0.000 0.002 0.986 0.000 3.932 16.306 3.250 False 15.734 24.467 18.737 49.541

822653 rows × 20 columns

[2]:
ds.attributes
[2]:
Index(['acceleration', 'position', 'classifications', 'dimension',
       'interpolated', 'velocity', 'yaw'],
      dtype='object')

Attributes of the dataset#

There are several attributes available to get information about a dataset. For instance, we can get the interval of a dataset via the property

[3]:
ds.interval
[3]:
Interval(2024-10-07 06:00:00.004659+00:00, 2024-10-07 06:04:59.954659+00:00, closed='right')

or all unique timestamps of it via

[4]:
ds.timestamps
[4]:
DatetimeIndex(['2024-10-07 06:00:00.004659+00:00',
               '2024-10-07 06:00:00.054659+00:00',
               '2024-10-07 06:00:00.104659+00:00',
               '2024-10-07 06:00:00.154659+00:00',
               '2024-10-07 06:00:00.204659+00:00',
               '2024-10-07 06:00:00.254659+00:00',
               '2024-10-07 06:00:00.304659+00:00',
               '2024-10-07 06:00:00.354659+00:00',
               '2024-10-07 06:00:00.404659+00:00',
               '2024-10-07 06:00:00.454659+00:00',
               ...
               '2024-10-07 06:04:59.504659+00:00',
               '2024-10-07 06:04:59.554659+00:00',
               '2024-10-07 06:04:59.604659+00:00',
               '2024-10-07 06:04:59.654659+00:00',
               '2024-10-07 06:04:59.704659+00:00',
               '2024-10-07 06:04:59.754659+00:00',
               '2024-10-07 06:04:59.804659+00:00',
               '2024-10-07 06:04:59.854659+00:00',
               '2024-10-07 06:04:59.904659+00:00',
               '2024-10-07 06:04:59.954659+00:00'],
              dtype='datetime64[ns, UTC]', name='timestamp', length=6000, freq=None)

or the ids of all traffic participants in the dataset.

[5]:
ds.ids
[5]:
Index([1728280701706084, 1728280711579163, 1728280715873385, 1728280715982681,
       1728280716727948, 1728280727754870, 1728280730837967, 1728280733279069,
       1728280735549731, 1728280737215735,
       ...
       1728281091674686, 1728281092465266, 1728281092634725, 1728281096288862,
       1728281098499514, 1728281098613793, 1728281099054783, 1728281099273571,
       1728281099390791, 1728281099712648],
      dtype='int64', name='id', length=445)

Filtering#

If you want to look into a short sequence of the overall dataset, you can select specific rows of the overall dataset. The DLRTrajectoryDataset provides various ways for this purpose.

Time and object#

There are two variants to filter a dataset based on the information on the dataset’s index. For instance, if you want to filterthe dataset by an interval, you can utilize the during method

[6]:
ds.during(ds.timestamps[0], ds.timestamps[10])
[6]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280701706084 -0.079 0.101 0.064 0.140 616517.884 5.793e+06 0.0 0.000 0.000 0.000 0.605 0.395 2.229 6.910 2.386 False 14.053 32.760 29.593 64.434
1728280711579163 0.089 0.600 0.593 -1.000 616874.078 5.794e+06 0.0 0.363 0.000 0.000 0.135 0.502 1.896 4.603 1.862 False -8.869 24.758 -23.115 -110.835
1728280715873385 -0.253 0.327 0.207 0.061 616362.445 5.793e+06 0.0 0.768 0.004 0.000 0.148 0.080 1.603 4.440 1.892 False 17.084 35.011 30.560 60.679
1728280715982681 -0.313 0.314 0.017 -0.045 614672.366 5.791e+06 0.0 0.392 0.000 0.000 0.233 0.375 1.859 6.250 1.932 False -37.444 42.502 -20.108 -151.427
1728280716727948 0.751 1.591 1.403 -2.409 616841.140 5.794e+06 0.0 0.000 0.000 0.011 0.989 0.000 3.970 18.454 3.073 False -10.055 25.734 -23.689 -112.937
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 06:00:00.454659+00:00 1728280799072058 -0.172 0.228 -0.150 0.003 616898.592 5.794e+06 0.0 0.776 0.022 0.000 0.064 0.138 1.708 4.266 1.770 True 11.708 30.463 28.124 66.769
1728280799223293 0.907 1.084 0.593 0.803 617431.929 5.796e+06 0.0 0.811 0.096 0.000 0.021 0.072 1.640 4.005 1.652 False 5.658 23.084 22.380 75.173
1728280799223298 0.129 0.454 0.436 0.561 616936.189 5.794e+06 0.0 0.926 0.016 0.000 0.028 0.030 1.531 3.720 1.731 False 13.404 36.408 33.851 68.335
1728280799473798 -0.407 0.410 -0.050 -0.434 614250.210 5.791e+06 0.0 0.000 0.000 0.024 0.969 0.000 3.708 14.097 3.246 False 23.580 25.277 9.106 20.750
1728280800459886 1.734 3.515 3.058 -5.399 617558.286 5.796e+06 0.0 0.749 0.094 0.000 0.134 0.024 1.408 3.226 1.689 False -13.028 36.914 -34.539 -110.772

969 rows × 20 columns

that returns the rows within the given interval.

Another variant to select specific rows of the datasets is by the id of a traffic participant. This might be useful if you want to take a closer look into the behavior of specific traffic participants. For instance, to filter by the second traffic participant in the dataset, we can combine the ids attribute with the trajectory method.

[7]:
ds.trajectory(ds.ids[1])
[7]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280711579163 0.089 0.600 0.593 -1.000 616874.078 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.869 24.758 -23.115 -110.835
2024-10-07 06:00:00.054659+00:00 1728280711579163 0.088 0.603 0.596 -0.996 616873.639 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.858 24.708 -23.065 -110.857
2024-10-07 06:00:00.104659+00:00 1728280711579163 0.088 0.605 0.599 -0.991 616873.200 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.848 24.658 -23.016 -110.879
2024-10-07 06:00:00.154659+00:00 1728280711579163 0.087 0.606 0.600 -0.982 616872.762 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.838 24.609 -22.967 -110.900
2024-10-07 06:00:00.204659+00:00 1728280711579163 0.086 0.607 0.600 -0.971 616872.325 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.828 24.561 -22.919 -110.922
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 06:00:19.654659+00:00 1728280711579163 0.223 0.598 0.555 -0.597 616701.503 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.091 20.809 -19.171 -112.780
2024-10-07 06:00:19.704659+00:00 1728280711579163 0.223 0.598 0.555 -0.597 616701.099 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.080 20.779 -19.144 -112.778
2024-10-07 06:00:19.754659+00:00 1728280711579163 0.223 0.598 0.555 -0.597 616700.695 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.069 20.749 -19.116 -112.776
2024-10-07 06:00:19.804659+00:00 1728280711579163 0.223 0.598 0.555 -0.597 616700.292 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.057 20.719 -19.088 -112.775
2024-10-07 06:00:19.854659+00:00 1728280711579163 0.223 0.598 0.555 -0.597 616699.889 5.794e+06 0.0 0.363 0.0 0.0 0.135 0.502 1.896 4.603 1.862 False -8.046 20.689 -19.060 -112.773

398 rows × 20 columns

Traffic participant properties#

There are also methods available that might help to find the relevant information in the dataset. The most straight forward option is to use pandas’ capability to access specific attributesof the datasets. The available attributes on the dataset, are available via theattribute` property.

[8]:
ds.attributes
[8]:
Index(['acceleration', 'position', 'classifications', 'dimension',
       'interpolated', 'velocity', 'yaw'],
      dtype='object')

We can, for instance, access the traffic participants position.

[9]:
ds.position
[9]:
easting northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280701706084 616517.884 5.793e+06
1728280711579163 616874.078 5.794e+06
1728280715873385 616362.445 5.793e+06
1728280715982681 614672.366 5.791e+06
1728280716727948 616841.140 5.794e+06
... ... ... ...
2024-10-07 06:04:59.954659+00:00 1728281098613793 616145.008 5.793e+06
1728281099054783 617008.656 5.794e+06
1728281099273571 617563.625 5.796e+06
1728281099390791 617057.020 5.795e+06
1728281099712648 615754.276 5.792e+06

822653 rows × 2 columns

or the classification propabilities.

[10]:
ds.classifications
[10]:
bicycle car motorbike pedestrian truck van
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280701706084 0.0 0.000 0.000 0.000 0.605 0.395
1728280711579163 0.0 0.363 0.000 0.000 0.135 0.502
1728280715873385 0.0 0.768 0.004 0.000 0.148 0.080
1728280715982681 0.0 0.392 0.000 0.000 0.233 0.375
1728280716727948 0.0 0.000 0.000 0.011 0.989 0.000
... ... ... ... ... ... ... ...
2024-10-07 06:04:59.954659+00:00 1728281098613793 0.0 0.823 0.042 0.000 0.114 0.022
1728281099054783 0.0 0.745 0.088 0.000 0.117 0.051
1728281099273571 0.0 0.749 0.002 0.000 0.138 0.111
1728281099390791 0.0 0.818 0.001 0.000 0.121 0.060
1728281099712648 0.0 0.000 0.000 0.002 0.986 0.000

822653 rows × 6 columns

We extended these basic capabilities with additional methods, that, for instance, allow to get the most likely class by each traffic participant’s pose

[11]:
ds.most_likely_class(by="pose")
[11]:
timestamp                         id
2024-10-07 06:00:00.004659+00:00  1728280701706084    truck
                                  1728280711579163      van
                                  1728280715873385      car
                                  1728280715982681      car
                                  1728280716727948    truck
                                                      ...
2024-10-07 06:04:59.954659+00:00  1728281098613793      car
                                  1728281099054783      car
                                  1728281099273571      car
                                  1728281099390791      car
                                  1728281099712648    truck
Length: 822653, dtype: object

or by the overall trajectory (the default), i.e. all poses of a traffic participants.

[12]:
ds.most_likely_class(by="trajectory")
[12]:
id
1728280701706084    truck
1728280710052318      car
1728280711579163      van
1728280715873385      car
1728280715982681      car
                    ...
1728281098613793      car
1728281099054783      car
1728281099273571      car
1728281099390791      car
1728281099712648    truck
Name: classification, Length: 445, dtype: object

This might help to filter the dataset to select only traffic participants that are classified as a car. To archieve this, we first get the most likely class per trajectory, select the rows having the value ‘car’ and pass their index (the traffic particpant’s id) into the trajectory method of the Dataset.

[13]:
classification = ds.most_likely_class(by="trajectory")

ds.trajectory(classification[classification == "car"].index)
[13]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280715873385 -0.253 0.327 0.207 0.061 616362.445 5.793e+06 0.0 0.768 0.004 0.0 0.148 0.080 1.603 4.440 1.892 False 17.084 35.011 30.560 60.679
1728280715982681 -0.313 0.314 0.017 -0.045 614672.366 5.791e+06 0.0 0.392 0.000 0.0 0.233 0.375 1.859 6.250 1.932 False -37.444 42.502 -20.108 -151.427
1728280727754870 0.130 0.505 0.488 -0.464 615179.647 5.792e+06 0.0 0.714 0.000 0.0 0.176 0.109 1.520 5.372 1.954 False -26.590 33.465 -20.320 -142.421
1728280733279069 -1.547 1.843 -1.001 2.754 615319.645 5.792e+06 0.0 0.758 0.000 0.0 0.141 0.101 1.541 4.917 2.043 False -24.288 31.461 -19.997 -140.535
1728280735549731 -0.772 0.777 -0.091 -0.040 616098.083 5.793e+06 0.0 0.761 0.000 0.0 0.149 0.090 1.481 4.994 2.066 False -26.823 49.453 -41.547 -122.699
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 06:04:59.954659+00:00 1728281098499514 -0.345 0.368 0.127 -0.036 615579.443 5.792e+06 0.0 0.895 0.035 0.0 0.059 0.011 1.385 4.280 1.676 False 24.172 34.260 24.279 45.214
1728281098613793 0.030 0.540 0.539 0.535 616145.008 5.793e+06 0.0 0.823 0.042 0.0 0.114 0.022 1.385 4.331 1.802 False 23.553 44.165 37.360 57.679
1728281099054783 -0.117 0.245 -0.216 -0.247 617008.656 5.794e+06 0.0 0.745 0.088 0.0 0.117 0.051 1.530 4.072 1.747 False 13.955 38.632 36.023 68.594
1728281099273571 0.137 0.157 0.078 0.055 617563.625 5.796e+06 0.0 0.749 0.002 0.0 0.138 0.111 1.494 4.534 1.906 False -9.853 33.009 -31.505 -107.753
1728281099390791 -0.280 0.339 -0.190 0.318 617057.020 5.795e+06 0.0 0.818 0.001 0.0 0.121 0.060 1.385 4.833 1.958 False -13.472 36.415 -33.832 -111.618

560110 rows × 20 columns

You can achieve the same result by directly calling

[14]:
ds.cars
[14]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280715873385 -0.253 0.327 0.207 0.061 616362.445 5.793e+06 0.0 0.768 0.004 0.0 0.148 0.080 1.603 4.440 1.892 False 17.084 35.011 30.560 60.679
1728280715982681 -0.313 0.314 0.017 -0.045 614672.366 5.791e+06 0.0 0.392 0.000 0.0 0.233 0.375 1.859 6.250 1.932 False -37.444 42.502 -20.108 -151.427
1728280727754870 0.130 0.505 0.488 -0.464 615179.647 5.792e+06 0.0 0.714 0.000 0.0 0.176 0.109 1.520 5.372 1.954 False -26.590 33.465 -20.320 -142.421
1728280733279069 -1.547 1.843 -1.001 2.754 615319.645 5.792e+06 0.0 0.758 0.000 0.0 0.141 0.101 1.541 4.917 2.043 False -24.288 31.461 -19.997 -140.535
1728280735549731 -0.772 0.777 -0.091 -0.040 616098.083 5.793e+06 0.0 0.761 0.000 0.0 0.149 0.090 1.481 4.994 2.066 False -26.823 49.453 -41.547 -122.699
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 06:04:59.954659+00:00 1728281098499514 -0.345 0.368 0.127 -0.036 615579.443 5.792e+06 0.0 0.895 0.035 0.0 0.059 0.011 1.385 4.280 1.676 False 24.172 34.260 24.279 45.214
1728281098613793 0.030 0.540 0.539 0.535 616145.008 5.793e+06 0.0 0.823 0.042 0.0 0.114 0.022 1.385 4.331 1.802 False 23.553 44.165 37.360 57.679
1728281099054783 -0.117 0.245 -0.216 -0.247 617008.656 5.794e+06 0.0 0.745 0.088 0.0 0.117 0.051 1.530 4.072 1.747 False 13.955 38.632 36.023 68.594
1728281099273571 0.137 0.157 0.078 0.055 617563.625 5.796e+06 0.0 0.749 0.002 0.0 0.138 0.111 1.494 4.534 1.906 False -9.853 33.009 -31.505 -107.753
1728281099390791 -0.280 0.339 -0.190 0.318 617057.020 5.795e+06 0.0 0.818 0.001 0.0 0.121 0.060 1.385 4.833 1.958 False -13.472 36.415 -33.832 -111.618

560110 rows × 20 columns

This works similarly for all object classes.

[15]:
ds.trucks
[15]:
acceleration position classifications dimension interpolated velocity yaw
easting magnitude northing signed easting northing bicycle car motorbike pedestrian truck van height length width easting magnitude northing
timestamp id
2024-10-07 06:00:00.004659+00:00 1728280701706084 -0.079 0.101 0.064 0.140 616517.884 5.793e+06 0.00 0.000 0.000 0.000 0.605 0.395 2.229 6.910 2.386 False 14.053 32.760 29.593 64.434
1728280716727948 0.751 1.591 1.403 -2.409 616841.140 5.794e+06 0.00 0.000 0.000 0.011 0.989 0.000 3.970 18.454 3.073 False -10.055 25.734 -23.689 -112.937
1728280730837967 0.123 0.245 0.212 0.479 615581.832 5.792e+06 0.01 0.000 0.000 0.000 0.990 0.000 3.970 17.494 3.304 False 16.155 22.998 16.368 45.275
1728280749766815 -0.152 0.187 -0.110 -0.519 615626.126 5.792e+06 0.00 0.000 0.009 0.002 0.946 0.043 2.832 7.239 2.395 False 14.157 20.580 14.937 46.555
1728280753645333 0.628 0.807 0.506 1.392 615705.450 5.792e+06 0.00 0.000 0.001 0.004 0.948 0.046 2.609 8.203 2.500 False 13.377 20.337 15.319 47.824
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2024-10-07 06:04:59.954659+00:00 1728281069009598 -0.186 0.202 0.078 -0.152 614953.412 5.791e+06 0.00 0.000 0.000 0.000 0.971 0.016 3.112 7.305 2.543 False 21.090 25.065 13.544 32.731
1728281084274747 0.130 0.455 0.436 0.447 614735.269 5.791e+06 0.00 0.000 0.005 0.000 0.537 0.457 2.514 6.343 2.278 True 30.898 35.283 17.037 28.923
1728281088700404 -0.109 0.164 -0.123 0.235 617199.967 5.795e+06 0.00 0.017 0.000 0.000 0.975 0.008 1.762 9.153 2.282 False -10.456 30.860 -29.035 -109.793
1728281091674686 -0.096 0.275 0.258 -0.004 614489.455 5.791e+06 0.00 0.000 0.000 0.000 0.705 0.290 2.755 6.512 2.373 False 29.902 32.903 13.728 24.823
1728281099712648 -0.354 0.660 -0.556 -1.290 615754.276 5.792e+06 0.00 0.000 0.000 0.002 0.986 0.000 3.932 16.306 3.250 False 15.734 24.467 18.737 49.541

165937 rows × 20 columns