From 38671712365f871b3cbd850fda7be9ac2f0e4f88 Mon Sep 17 00:00:00 2001 From: Joris Bekkers Date: Fri, 18 Aug 2023 12:06:57 +0200 Subject: [PATCH 1/6] fixed end position coordinates not scaling --- .../serializers/event/sportec/deserializer.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/kloppy/infra/serializers/event/sportec/deserializer.py b/kloppy/infra/serializers/event/sportec/deserializer.py index 87cabab9..2a7e86da 100644 --- a/kloppy/infra/serializers/event/sportec/deserializer.py +++ b/kloppy/infra/serializers/event/sportec/deserializer.py @@ -112,7 +112,10 @@ def sportec_metadata_from_xml_elm(match_root) -> SportecMetadata: if not away_team: raise DeserializationError("Away team is missing from metadata") - (home_score, away_score,) = match_root.MatchInformation.General.attrib[ + ( + home_score, + away_score, + ) = match_root.MatchInformation.General.attrib[ "Result" ].split(":") score = Score(home=int(home_score), away=int(away_score)) @@ -538,13 +541,21 @@ def deserialize(self, inputs: SportecEventDataInputs) -> EventDataset: and previous_event.result == PassResult.COMPLETE ): if "X-Source-Position" in event_chain["Event"]: - previous_event.receiver_coordinates = Point( - x=float( - event_chain["Event"]["X-Source-Position"] - ), - y=float( - event_chain["Event"]["Y-Source-Position"] - ), + previous_event.receiver_coordinates = ( + transformer.change_point_dimensions( + Point( + x=float( + event_chain["Event"][ + "X-Source-Position" + ] + ), + y=float( + event_chain["Event"][ + "Y-Source-Position" + ] + ), + ) + ) ) if ( From 11d8f7a76c229899d2c4b1bbeb1bf2a171673931 Mon Sep 17 00:00:00 2001 From: Joris Bekkers Date: Fri, 18 Aug 2023 12:54:59 +0200 Subject: [PATCH 2/6] fixed own goal --- kloppy/infra/serializers/event/sportec/deserializer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kloppy/infra/serializers/event/sportec/deserializer.py b/kloppy/infra/serializers/event/sportec/deserializer.py index 2a7e86da..d63b7fc3 100644 --- a/kloppy/infra/serializers/event/sportec/deserializer.py +++ b/kloppy/infra/serializers/event/sportec/deserializer.py @@ -200,6 +200,7 @@ def _event_chain_from_xml_elm(event_elm): SPORTEC_EVENT_NAME_SHOT_WOODWORK = "ShotWoodWork" SPORTEC_EVENT_NAME_SHOT_OTHER = "OtherShot" SPORTEC_EVENT_NAME_SHOT_GOAL = "SuccessfulShot" +SPORTEC_EVENT_NAME_OWN_GOAL = "OwnGoal" SPORTEC_SHOT_EVENT_NAMES = ( SPORTEC_EVENT_NAME_SHOT_WIDE, SPORTEC_EVENT_NAME_SHOT_SAVED, @@ -207,6 +208,7 @@ def _event_chain_from_xml_elm(event_elm): SPORTEC_EVENT_NAME_SHOT_WOODWORK, SPORTEC_EVENT_NAME_SHOT_OTHER, SPORTEC_EVENT_NAME_SHOT_GOAL, + SPORTEC_EVENT_NAME_OWN_GOAL, ) SPORTEC_EVENT_NAME_PASS = "Pass" From 280206ddd891d915e48d6c31987e8921b8a1e484 Mon Sep 17 00:00:00 2001 From: Joris Bekkers Date: Fri, 18 Aug 2023 12:56:33 +0200 Subject: [PATCH 3/6] fixed own goal shotresult --- kloppy/infra/serializers/event/sportec/deserializer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kloppy/infra/serializers/event/sportec/deserializer.py b/kloppy/infra/serializers/event/sportec/deserializer.py index d63b7fc3..5e0d2189 100644 --- a/kloppy/infra/serializers/event/sportec/deserializer.py +++ b/kloppy/infra/serializers/event/sportec/deserializer.py @@ -293,6 +293,8 @@ def _parse_shot(event_name: str, event_chain: OrderedDict) -> Dict: result = ShotResult.POST elif event_name == SPORTEC_EVENT_NAME_SHOT_GOAL: result = ShotResult.GOAL + elif event_name == SPORTEC_EVENT_NAME_OWN_GOAL: + result = ShotResult.OWN_GOAL elif event_name == SPORTEC_EVENT_NAME_SHOT_OTHER: result = None else: From 63fe79f8393d29754968ce9d821cf5c189620a9c Mon Sep 17 00:00:00 2001 From: Joris Bekkers Date: Mon, 21 Aug 2023 14:02:29 +0200 Subject: [PATCH 4/6] fixed wrong orientation setting --- kloppy/infra/serializers/event/sportec/deserializer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kloppy/infra/serializers/event/sportec/deserializer.py b/kloppy/infra/serializers/event/sportec/deserializer.py index 5e0d2189..0267299a 100644 --- a/kloppy/infra/serializers/event/sportec/deserializer.py +++ b/kloppy/infra/serializers/event/sportec/deserializer.py @@ -411,6 +411,7 @@ def deserialize(self, inputs: SportecEventDataInputs) -> EventDataset: start_timestamp=timestamp, end_timestamp=None, ) + print(event_chain[SPORTEC_EVENT_NAME_KICKOFF]) if period_id == 1: team_left = event_chain[SPORTEC_EVENT_NAME_KICKOFF][ "TeamLeft" @@ -418,12 +419,12 @@ def deserialize(self, inputs: SportecEventDataInputs) -> EventDataset: if team_left == home_team.team_id: # goal of home team is on the left side. # this means they attack from left to right - orientation = Orientation.FIXED_HOME_AWAY + orientation = Orientation.HOME_TEAM period.set_attacking_direction( AttackingDirection.HOME_AWAY ) else: - orientation = Orientation.FIXED_AWAY_HOME + orientation = Orientation.AWAY_TEAM period.set_attacking_direction( AttackingDirection.AWAY_HOME ) From a6fe4dc26c8301b22f5d1d2c0f32c60468a955c8 Mon Sep 17 00:00:00 2001 From: Joris Bekkers Date: Mon, 21 Aug 2023 14:08:03 +0200 Subject: [PATCH 5/6] fixed wrong orientation setting, from FIXED_ to HOME/AWAY_TEAM --- kloppy/infra/serializers/event/sportec/deserializer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kloppy/infra/serializers/event/sportec/deserializer.py b/kloppy/infra/serializers/event/sportec/deserializer.py index 0267299a..03278dcf 100644 --- a/kloppy/infra/serializers/event/sportec/deserializer.py +++ b/kloppy/infra/serializers/event/sportec/deserializer.py @@ -411,7 +411,6 @@ def deserialize(self, inputs: SportecEventDataInputs) -> EventDataset: start_timestamp=timestamp, end_timestamp=None, ) - print(event_chain[SPORTEC_EVENT_NAME_KICKOFF]) if period_id == 1: team_left = event_chain[SPORTEC_EVENT_NAME_KICKOFF][ "TeamLeft" From be98ea49554f936ae92e95144c713bc8c4984435 Mon Sep 17 00:00:00 2001 From: Joris Bekkers Date: Mon, 21 Aug 2023 14:29:06 +0200 Subject: [PATCH 6/6] fixed orientation sportec tracking too --- kloppy/infra/serializers/tracking/sportec/deserializer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kloppy/infra/serializers/tracking/sportec/deserializer.py b/kloppy/infra/serializers/tracking/sportec/deserializer.py index 45b05b1f..231dc895 100644 --- a/kloppy/infra/serializers/tracking/sportec/deserializer.py +++ b/kloppy/infra/serializers/tracking/sportec/deserializer.py @@ -209,9 +209,9 @@ def _iter(): break orientation = ( - Orientation.FIXED_HOME_AWAY + Orientation.HOME_TEAM if periods[0].attacking_direction == AttackingDirection.HOME_AWAY - else Orientation.FIXED_AWAY_HOME + else Orientation.AWAY_TEAM ) metadata = Metadata(