Skip to content

SkillCorner

kloppy.skillcorner

Functions for loading SkillCorner broadcast tracking data.

load

load(meta_data, raw_data, sample_rate=None, limit=None, coordinates=None, include_empty_frames=False, data_version=None, only_alive=True)

Load SkillCorner broadcast tracking data.

PARAMETER DESCRIPTION
meta_data

A json feed containing the meta data.

TYPE: FileLike

raw_data

A json feed containing the raw tracking data.

TYPE: FileLike

sample_rate

Sample the data at a specific rate.

TYPE: Optional[float] DEFAULT: None

limit

Limit the number of frames to load to the first limit frames.

TYPE: Optional[int] DEFAULT: None

coordinates

The coordinate system to use.

TYPE: Optional[str] DEFAULT: None

include_empty_frames

Include frames in which no objects were tracked.

TYPE: Optional[bool] DEFAULT: False

only_alive

Only include frames in which the game is not paused.

TYPE: Optional[bool] DEFAULT: True

data_version

Specify the input data version.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
TrackingDataset

The parsed tracking data.

Source code in kloppy/_providers/skillcorner.py
def load(
    meta_data: FileLike,
    raw_data: FileLike,
    sample_rate: Optional[float] = None,
    limit: Optional[int] = None,
    coordinates: Optional[str] = None,
    include_empty_frames: Optional[bool] = False,
    data_version: Optional[str] = None,
    only_alive: Optional[bool] = True,
) -> TrackingDataset:
    """
    Load SkillCorner broadcast tracking data.

    Args:
        meta_data: A json feed containing the meta data.
        raw_data: A json feed containing the raw tracking data.
        sample_rate: Sample the data at a specific rate.
        limit: Limit the number of frames to load to the first `limit` frames.
        coordinates: The coordinate system to use.
        include_empty_frames: Include frames in which no objects were tracked.
        only_alive: Only include frames in which the game is not paused.
        data_version: Specify the input data version.

    Returns:
        The parsed tracking data.
    """
    if data_version not in ["V2", "V3", None]:
        raise ValueError(
            f"data_version must be either 'V2', 'V3'. Provided: {data_version}"
        )
    if not data_version:
        data_version = identify_data_version(raw_data)
    deserializer = SkillCornerDeserializer(
        sample_rate=sample_rate,
        limit=limit,
        coordinate_system=coordinates,
        include_empty_frames=include_empty_frames,
        data_version=data_version,
        only_alive=only_alive,
    )
    with (
        open_as_file(meta_data) as meta_data_fp,
        open_as_file(raw_data) as raw_data_fp,
    ):
        return deserializer.deserialize(
            inputs=SkillCornerInputs(
                meta_data=meta_data_fp, raw_data=raw_data_fp
            )
        )

load_open_data

load_open_data(match_id='1925299', sample_rate=None, limit=None, coordinates=None, include_empty_frames=False, only_alive=True)

Load SkillCorner open data.

This function loads tracking data directly from the SkillCorner open data GitHub repository.

PARAMETER DESCRIPTION
match_id

The id of the match to load data for.

TYPE: Union[str, int] DEFAULT: '1925299'

sample_rate

Sample the data at a specific rate.

TYPE: Optional[float] DEFAULT: None

limit

Limit the number of frames to load to the first limit frames.

TYPE: Optional[int] DEFAULT: None

coordinates

The coordinate system to use.

TYPE: Optional[str] DEFAULT: None

include_empty_frames

Include frames in which no objects were tracked.

TYPE: Optional[bool] DEFAULT: False

only_alive

Only include frames in which the game is not dead.

TYPE: Optional[bool] DEFAULT: True

RETURNS DESCRIPTION
TrackingDataset

The parsed tracking data.

Source code in kloppy/_providers/skillcorner.py
def load_open_data(
    match_id: Union[str, int] = "1925299",
    sample_rate: Optional[float] = None,
    limit: Optional[int] = None,
    coordinates: Optional[str] = None,
    include_empty_frames: Optional[bool] = False,
    only_alive: Optional[bool] = True,
) -> TrackingDataset:
    """
    Load SkillCorner open data.

    This function loads tracking data directly from the SkillCorner open data
    GitHub repository.

    Args:
        match_id: The id of the match to load data for.
        sample_rate: Sample the data at a specific rate.
        limit: Limit the number of frames to load to the first `limit` frames.
        coordinates: The coordinate system to use.
        include_empty_frames: Include frames in which no objects were tracked.
        only_alive: Only include frames in which the game is not dead.

    Returns:
        The parsed tracking data.
    """
    return load(
        meta_data=github_resolve_raw_data_url(
            repository="SkillCorner/opendata",
            branch="master",
            file=f"data/matches/{match_id}/{match_id}_match.json",
        ),
        raw_data=github_resolve_raw_data_url(
            repository="SkillCorner/opendata",
            branch="master",
            file=f"data/matches/{match_id}/{match_id}_tracking_extrapolated.jsonl",
        ),
        sample_rate=sample_rate,
        limit=limit,
        coordinates=coordinates,
        include_empty_frames=include_empty_frames,
        only_alive=only_alive,
    )