PySport / kloppy

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

Wyscout v2 does not seem to use BALL_OWNING_TEAM orientation #236

Closed probberechts closed 3 weeks ago

probberechts commented 7 months ago

It seems Wyscout v2 uses the ACTION_EXECUTING_TEAM orientation. Not the BALL_OWNING_TEAM orientation as it is currently implemented.

Below is some proof from the public data (match id 2058007). It is a duel between a player of the attacking team and a player of the defending team. With the ACTION_EXECUTING_TEAM orientation, both events should have the same coordinates, but they are mirrored.

      {
         "eventId":1,
         "subEventName":"Ground attacking duel",
         "tags":[
            {
               "id":502
            },
            {
               "id":703
            },
            {
               "id":1801
            }
         ],
         "playerId":14816,
         "positions":[
            {
               "y":65,
               "x":78
            },
            {
               "y":57,
               "x":79
            }
         ],
         "matchId":2058007,
         "eventName":"Duel",
         "teamId":12913,
         "matchPeriod":"1H",
         "eventSec":54.589237000000026,
         "subEventId":11,
         "id":261445464
      },
      {
         "eventId":1,
         "subEventName":"Ground defending duel",
         "tags":[
            {
               "id":501
            },
            {
               "id":701
            },
            {
               "id":1802
            }
         ],
         "playerId":48,
         "positions":[
            {
               "y":35,
               "x":22
            },
            {
               "y":43,
               "x":21
            }
         ],
         "matchId":2058007,
         "eventName":"Duel",
         "teamId":5629,
         "matchPeriod":"1H",
         "eventSec":54.84165100000001,
         "subEventId":12,
         "id":261445573
      },

I am not entirely sure though since I don't have access to recent Wyscout data and according to the API docs, it is the "position in percentage from the left corner of the attacking team".

Anyway, if Wyscout would indeed use the BALL_OWNING_TEAM orientation, the serializer should set the ball owning team (which is not defined in the raw data of v2, btw).

I couldn't check it for the v3 data. But that datastream indeed defines the ball owning team, so it might be correct.

DriesDeprest commented 6 months ago

No, in Wyscout v3 raw data, the orientation seems to also be ACTION_EXECUTING_TEAM. As you can see below. This should thus be fixed, as currently it is implemented as BALL_OWNING_TEAM.

{
      "id": 1,
      "matchId": 1,
      "matchPeriod": "1H",
      "minute": 3,
      "second": 26,
      "matchTimestamp": "00:03:26.604",
      "videoTimestamp": "207.604431",
      "relatedEventId": 1291912482,
      "type": {
        "primary": "duel",
        "secondary": [
          "dribble",
          "ground_duel",
          "offensive_duel"
        ]
      },
      "location": {
        "x": 67,
        "y": 93
      },
      "team": {
        "id": 1,
        "formation": "3-4-1-2"
      },
      "opponentTeam": {
        "id": 2,
        "formation": "3-5-2"
      },
      "player": {
        "id": 1
      },
      "pass": null,
      "shot": null,
      "groundDuel": {
        "opponent": {
          "id": 2
        },
        "duelType": "dribble",
        "keptPossession": false,
        "progressedWithBall": false,
        "stoppedProgress": null,
        "recoveredPossession": null,
        "takeOn": true,
        "side": "left",
        "relatedDuelId": 2
      },
      "aerialDuel": null,
      "infraction": null,
      "carry": null
    },
    {
      "id": 2,
      "matchId": 1,
      "matchPeriod": "1H",
      "minute": 3,
      "second": 26,
      "matchTimestamp": "00:03:26.604",
      "videoTimestamp": "207.604431",
      "relatedEventId": 1291912482,
      "type": {
        "primary": "duel",
        "secondary": [
          "defensive_duel",
          "dribbled_past_attempt",
          "ground_duel"
        ]
      },
      "location": {
        "x": 33,
        "y": 7
      },
      "team": {
        "id": 2,
        "formation": "3-5-2"
      },
      "opponentTeam": {
        "id": 1,
        "formation": "3-4-1-2"
      },
      "player": {
        "id": 2,
        "position": "LWB"
      },
      "pass": null,
      "shot": null,
      "groundDuel": {
        "opponent": {
          "id": 1,
          "position": "RWB"
        },
        "duelType": "defensive_duel",
        "keptPossession": null,
        "progressedWithBall": null,
        "stoppedProgress": true,
        "recoveredPossession": false,
        "takeOn": true,
        "side": "right",
        "relatedDuelId": 1291912287
      },
      "aerialDuel": null,
      "infraction": null,
      "carry": null
    }