import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sys
laurie_DIR = ''
sys.path.append(laurie_DIR + '/LaurieOnTracking-master')
import Metrica_Viz as mviz
convert_DIR = ''
sys.path.append(convert_DIR + '/lastrow_to_friendsoftracking-master')
import lastrow_to_friendsoftracking as lrfot
lastrow_DIR = ''
last_row = pd.read_csv(lastrow_DIR + '/Last-Row-master/datasets/positional_data/liverpool_2019.csv', index_col=('play', 'frame'))
data_attack, data_defence = lrfot.lastrow_to_friendsoftracking(last_row)
C:/Users/Ciaran/OneDrive/Documents/Last Man Analytics/20200428 - FoT and Seattle Competition/lastrow_to_friendsoftracking-master\lastrow_to_friendsoftracking.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy data_attack['Time [s]'] = data_attack['frame'] / 20 C:/Users/Ciaran/OneDrive/Documents/Last Man Analytics/20200428 - FoT and Seattle Competition/lastrow_to_friendsoftracking-master\lastrow_to_friendsoftracking.py:71: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy data_defence['Time [s]'] = data_defence['frame'] / 20
data_attack = lrfot.lastrow_to_metric_coordinates(data_attack)
data_defence = lrfot.lastrow_to_metric_coordinates(data_defence)
data_attack, data_defence = lrfot.lastrow_to_single_playing_direction(data_attack, data_defence)
# Single Frame
play = 'Bayern 0 - [1] Liverpool'
frame = 10
fig,ax = mviz.plot_frame( data_attack.loc[(play, frame)], data_defence.loc[(play, frame)],annotate=True )
plt.show()
# Video of Goal
PLOTDIR = ''
mviz.save_match_clip(tracking_liverpool_attack.loc[m],tracking_liverpool_defense.loc[m],PLOTDIR,fname=name,include_player_velocities=False)
# All Videos of Goals
PLOTDIR = ''
for m in tracking_liverpool_goals.index.get_level_values('play').unique():
name = m.split(" ")[0][:3].lower() + m.split(" ")[1] + m.split(" ")[-2] + m.split(" ")[-1][:3].lower()
mviz.save_match_clip(tracking_liverpool_attack.loc[m],tracking_liverpool_defense.loc[m],PLOTDIR,fname=name,include_player_velocities=False)