Skip to content

SkillCorner

kloppy.skillcorner

Functions for loading SkillCorner broadcast tracking data.

load

1
2
3
4
5
6
7
8
9
load(
    meta_data,
    raw_data,
    sample_rate=None,
    limit=None,
    coordinates=None,
    include_empty_frames=False,
    data_version=None,
)

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

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,
) -> 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.
        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,
    )
    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

1
2
3
4
5
6
7
load_open_data(
    match_id="4039",
    sample_rate=None,
    limit=None,
    coordinates=None,
    include_empty_frames=False,
)

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: '4039'

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

RETURNS DESCRIPTION
TrackingDataset

The parsed tracking data.

Source code in kloppy/_providers/skillcorner.py
def load_open_data(
    match_id: Union[str, int] = "4039",
    sample_rate: Optional[float] = None,
    limit: Optional[int] = None,
    coordinates: Optional[str] = None,
    include_empty_frames: Optional[bool] = False,
) -> 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.

    Returns:
        The parsed tracking data.
    """
    return load(
        meta_data=f"https://raw.githubusercontent.com/SkillCorner/opendata/master/data/matches/{match_id}/match_data.json",
        raw_data=f"https://raw.githubusercontent.com/SkillCorner/opendata/master/data/matches/{match_id}/structured_data.json",
        sample_rate=sample_rate,
        limit=limit,
        coordinates=coordinates,
        include_empty_frames=include_empty_frames,
    )