PySport / kloppy

kloppy: standardizing soccer tracking- and event data
https://kloppy.pysport.org
BSD 3-Clause "New" or "Revised" License
326 stars 55 forks source link

Uniform implementation of timestamps #294

Closed probberechts closed 3 months ago

probberechts commented 5 months ago

The representation of timestamps was inconsistent between different data providers.

This commit implements a uniform implementation between data providers. The timestamps of events and frames are now relative to the kick-off event in each period. This implies that timestamps are reset to zero for each period and that tracking frames before the kick-off event get a negative timestamp. The standard implementation for the start_timestamp and end_timestamp of periods is the absolute UTC datetime of respectively the kick-off and final whistle of the corresponding period. If the absolute datetime is not available, we use the offset between the start of the period's data feed and the kick-off for the start_timestamp, and the offset between the start of the period's data feed and the final whistle for the end_timestamp.

BREAKING CHANGES:

probberechts commented 5 months ago

~For Wyscout v3 it was unclear whether timestamps are reset at the start of each period. That is, does the first event of the second period get timestamp "00:00" or "45:00". This is not clear from the test data which contains artificial data. Maybe @DriesDeprest can answer this?~

For DataFactory, I am not sure whether the timestamps are in UTC or local time. The test file contains a field match.stadiumGMT = +03.00. Does this mean that all timestamps are in the UTC+03.00 local time or are all timestamps in UTC time and can we get the local time by adding 3 hours?

JanVanHaaren commented 5 months ago

For Wyscout v3 it was unclear whether timestamps are reset at the start of each period. That is, does the first event of the second period get timestamp "00:00" or "45:00". This is not clear from the test data which contains artificial data.

In Wyscout V3 event data, the second period starts at timestamp "45:00".

{
    "matchPeriod": "2H",
    "minute": 45,
    "second": 2,
    "matchTimestamp": "00:45:02.581",
    "videoTimestamp": "3011.581222",
}
probberechts commented 5 months ago

Thanks, @JanVanHaaren! I guessed incorrectly 😅 but it should be fixed.

JanVanHaaren commented 3 months ago

@probberechts Can you please resolve the merge conflicts? Thanks!