floodlight.io.tracab
- floodlight.io.tracab.read_position_data_dat(filepath_dat, filepath_metadata, teamsheet_home=None, teamsheet_away=None)[source]
Parse TRACAB .dat-files (ASCII) and metadata (xml or json) and extract position data, possession and ballstatus codes, teamsheets as well as pitch information.
ChyronHego’s TRACAB system delivers two separate files, a .dat file containing the actual data as well as a metadata.xml containing information about pitch size, framerate and start- and endframes of match periods. This function provides a high-level access to TRACAB data by parsing “the full match” given both files.
- Parameters
filepath_dat (str or pathlib.Path) – Full path to dat-file.
filepath_metadata (str or pathlib.Path) – Full path to metadata.xml file.
teamsheet_home (Teamsheet, optional) – Teamsheet object for the home team used to create link dictionaries of the form links[team][jID] = xID. The links are used to map players to a specific xID in the respective XY objects. Should be supplied for custom ordering. If given as None (default), teamsheet is extracted from the .dat or .json file (see Notes) and xIDs are assigned to the player’s jersey numbers ascendingly (dat case) or in order of appearance (json case).
teamsheet_away (Teamsheet, optional) – Teamsheet object for the away team. If given as None (default), teamsheet is extracted from the .dat or -json file. See teamsheet_home for details.
- Returns
data_objects – Tuple of (nested) floodlight core objects with shape (xy_objects, possession_objects, ballstatus_objects, teamsheets, pitch).
xy_objects
is a nested dictionary containingXY
objects for each team and segment of the formxy_objects[segment][team] = XY
. For a typical league match with two halves and teams this dictionary looks like:{'HT1': {'Home': XY, 'Away': XY}, 'HT2': {'Home': XY, 'Away': XY}}
.possession_objects
is a dictionary containingCode
objects with possession information (home or away) for each segment of the formpossession_objects[segment] = Code
.ballstatus_objects
is a dictionary containingCode
objects with ballstatus information (dead or alive) for each segment of the formballstatus_objects[segment] = Code
.teamsheets
is a dictionary containingTeamsheet
objects for each team of the formteamsheets[team] = Teamsheet
.pitch
is aPitch
object corresponding to the data.- Return type
Tuple[Dict[str, Dict[str, XY]], Dict[str, Code], Dict[str, Code], Dict[str, Teamsheet], Pitch]
Notes
Tracab provides metadata in two file types: xml and json. The json metadata files typically include player information whereas the xml files do not. The dat file storing tracking data (e.g. from an ASCII stream) contain only player jersey numbers, but no additional player information.
This function will check whether the provided
filepath_metadata
points to a xml or json file. If it’s a json, teamsheets are generated from this source. If it’s a xml, teamsheets are generated from the dat file and players are named ‘Player i’ with i starting at 1. To identify players in this case, use the jersey numbers or provide custom teamsheets generated by a different parser if additional data is available.
- floodlight.io.tracab.read_teamsheets_from_dat(filepath_dat)[source]
Parses the entire TRACAB .dat file for unique jIDs (jerseynumbers) and creates respective teamsheets for the home and the away team.
- Parameters
filepath_dat (str or pathlib.Path) – Full path to .dat file.
- Returns
teamsheets – Dictionary with teamsheets for the home team and the away team.
- Return type
Dict[str, Teamsheet]
- floodlight.io.tracab.read_teamsheets_from_meta_json(filepath_metadata)[source]
Reads TRACAB’s metadata file (json format) and creates respective teamsheets for the home and the away team.
- Parameters
filepath_metadata (str or pathlib.Path) – Full path to _metadata.json file.
- Returns
teamsheets – Dictionary with teamsheets for the home team and the away team.
- Return type
Dict[str, Teamsheet]