smoothing=True) metrica_defence = pvm.lastrow_calc_player_velocities(data_defence, smoothing=True) print('converted to metrica') # Read in Events events_dict, events_df = create.create_events(metrica_attack) print('events imported') # Real Shirt Mapping shirt_mapping = sm.create_consistent_shirt_mapping(last_row) events_df = sm.real_shirt_mapping(events_df, shirt_mapping) print('shirts mapped') # to Bokeh Format bokeh_attack = mtb.tracking_to_bokeh_format(metrica_attack) bokeh_defence = mtb.tracking_to_bokeh_format(metrica_defence) print('converted to bokeh') # List of available Matches match_list = events_df.index.get_level_values(level=0).unique().tolist() # Surface Colour Map m_coolwarm_rgb = (255 * cm.coolwarm(range(256))).astype('int') bokehpalette = [RGB(*tuple(rgb)).to_hex() for rgb in m_coolwarm_rgb] # Create each of the tabs #tab1 = goals_overview_tab(events_df, match_list, bokeh_attack, bokeh_defence, shirt_mapping) #print('tab1 completed') #tab2 = pitch_surfaces_tab(events_df, metrica_attack, metrica_defence, bokeh_attack, bokeh_defence, shirt_mapping, match_list) #print('tab2 completed')
def recalculate(event): match_selection = match_select.value event_selection = event_select.value player_selection = int(player_select.value) team_selection = team_select.value if team_selection == 'attack': player = att_src.data['player'][player_selection] shirt = att_src.data['Shirt Number'][player_selection] # attack selected_att_x = att_src.data['x'][player_selection] selected_att_y = att_src.data['y'][player_selection] og_selected_att_x = og_att_src.data['x'][player_selection] og_selected_att_y = og_att_src.data['y'][player_selection] x_displacement = selected_att_x - og_selected_att_x y_displacement = selected_att_y - og_selected_att_y metrica_attack_new = mtb.player_displacement( match_selection, event_selection, events_df, metrica_attack, metrica_defence, 'attack', player, x_displacement, y_displacement) bokeh_attack_new = mtb.tracking_to_bokeh_format(metrica_attack_new) new_event_src, new_att_src, new_def_src, new_ball_src, new_PPCF_src, new_PT_src, new_PS_src, new_PPV_src, new_RPPV_src, xgrid, ygrid = make_dataset( match_selection, event_selection, metrica_attack_new, metrica_defence, bokeh_attack_new, bokeh_defence) print('calculating..') event_src.data.update(new_event_src.data) att_src.data.update(new_att_src.data) def_src.data.update(new_def_src.data) ball_src.data.update(new_ball_src.data) PPCF_src.data.update(new_PPCF_src.data) PT_src.data.update(new_PT_src.data) PT_src.data.update(new_PS_src.data) PPV_src.data.update(new_PPV_src.data) RPPV_src.data.update(new_RPPV_src.data) pitch_value = make_plot(event_src, att_src, def_src, ball_src, PPV_src, bokeh_attack, bokeh_defence, xgrid, ygrid, field_dimen=( 106., 68., ), new_grid_size=500) relative_pitch_value = make_plot(event_src, att_src, def_src, ball_src, RPPV_src, bokeh_attack, bokeh_defence, xgrid, ygrid, field_dimen=( 106., 68., ), new_grid_size=500) elif team_selection == 'defence': player = def_src.data['player'][player_selection] shirt = def_src.data['Shirt Number'][player_selection] # defence selected_def_x = def_src.data['x'][player_selection] selected_def_y = def_src.data['y'][player_selection] og_selected_def_x = og_def_src.data['x'][player_selection] og_selected_def_y = og_def_src.data['y'][player_selection] x_displacement = selected_def_x - og_selected_def_x y_displacement = selected_def_y - og_selected_def_y metrica_defence_new = mtb.player_displacement( match_selection, event_selection, events_df, metrica_attack, metrica_defence, 'defence', player, x_displacement, y_displacement) bokeh_defence_new = mtb.tracking_to_bokeh_format( metrica_defence_new) new_event_src, new_att_src, new_def_src, new_ball_src, new_PPCF_src, new_PT_src, new_PS_src, new_PPV_src, new_RPPV_src, xgrid, ygrid = make_dataset( match_selection, event_selection, metrica_attack, metrica_defence_new, bokeh_attack, bokeh_defence_new) print('calculating..') event_src.data.update(new_event_src.data) att_src.data.update(new_att_src.data) def_src.data.update(new_def_src.data) ball_src.data.update(new_ball_src.data) PPCF_src.data.update(new_PPCF_src.data) PT_src.data.update(new_PT_src.data) PT_src.data.update(new_PS_src.data) PPV_src.data.update(new_PPV_src.data) RPPV_src.data.update(new_RPPV_src.data) pitch_value = make_plot(event_src, att_src, def_src, ball_src, PPV_src, bokeh_attack, bokeh_defence, xgrid, ygrid, field_dimen=( 106., 68., ), new_grid_size=500) relative_pitch_value = make_plot(event_src, att_src, def_src, ball_src, RPPV_src, bokeh_attack, bokeh_defence, xgrid, ygrid, field_dimen=( 106., 68., ), new_grid_size=500)