[StatsBomb] Freeze Frame parsing and transforming#481
[StatsBomb] Freeze Frame parsing and transforming#481UnravelSports wants to merge 5 commits intoPySport:masterfrom
Conversation
|
I have added a fix for the second point from Issue (#483). The main problem, besides the earlier identified incorrect indent in the freeze frame parsing is that inside the StatsBomb parser we first loop over the events and potentially transform them in orientation or coordinate system. Then, we loop over all events again and parse the freeze frames. While doing this we call transform on the whole freeze frame again, including the ball coordinates. However, in This means we would transform the ball coordinates twice. This was identified by @jan-swiatek in Issue #464 (comment). I've added a parameter for event in dataset:
if "freeze_frame" in event.raw_event.get("shot", {}):
event.freeze_frame = self.transformer.transform_frame(
parse_freeze_frame(
freeze_frame=event.raw_event["shot"]["freeze_frame"],
home_team=teams[0],
away_team=teams[1],
event=event,
fidelity_version=data_version.shot_fidelity_version,
),
transform_ball_coordinates=False,
)
if not event.freeze_frame and event.event_id in three_sixty_data:
freeze_frame = three_sixty_data[event.event_id]
event.freeze_frame = self.transformer.transform_frame(
parse_freeze_frame(
freeze_frame=freeze_frame["freeze_frame"],
home_team=teams[0],
away_team=teams[1],
event=event,
fidelity_version=data_version.xy_fidelity_version,
visible_area=freeze_frame["visible_area"],
),
transform_ball_coordinates=False,
)This means we now skip transforming the ball coordinates for a second time when parsing the freeze frames. Obligatory: This is not a very clean fix, but I don't see an easier way to untangle this mess. |
As discussed here #464
@probberechts not sure if this is the only thing that needs fixing