# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import logging

import pandas as pd
import matplotlib.pyplot as plt

from world_rowing import api, livetracker, utils, dashboard

logging.basicConfig(level=logging.INFO)
logging.getLogger().setLevel(logging.INFO)
# -

# # Live tracking
#
# Running the cell below will automatically update the graph with the livetracking data and predictions for the end of the race. 

dash = dashboard.Dashboard.load_last_race(figsize=(14, 10))
dash.update()

# # Viewing livetracking data for previous races
#
# You can view the livetracking data for previous races as well

races = api.get_competition_races()
races.iloc[:10]

race = races.iloc[8]
dash = dashboard.Dashboard.from_race_id(
    race.name, figsize=(14, 10))
dash.update()

# # Viewing competition PGMTs
#
# Unfortunately doesn't work for the Olympics

comp_pgmts = api.get_competition_pgmts()
group_boat_pgmts = comp_pgmts.groupby('Boat')
boat_pgmts = group_boat_pgmts\
    .first()\
    .sort_values('PGMT', ascending=False)
boat_pgmts

# +
f, ax = plt.subplots(figsize=(12, 8))

for boat in boat_pgmts.index:
    pgmt = group_boat_pgmts.get_group(boat).PGMT.sort_values(ascending=False)
    ax.step(range(pgmt.size), pgmt.values, label=boat, where='post')
    
ax.set_xlim(0, 10)
ax.set_ylim(0.9, comp_pgmts.PGMT.max() + .01)
ax.legend();

StarcoderdataJupyterScriptsDedupFiltered