wblib

Wattbike Hub Workout Analysis


License
MIT
Install
pip install wblib==0.6.0

Documentation

wblib

Wblib offers a set of tools to work with Wattbike data. Wattbike session data can be downloaded directly from the Wattbike Hub.

Installation

The easiest way to install wblib is via pip:

pip install wblib

Otherwise you can clone this repository:

git clone git@github.com:AartGoossens/wblib.git

Example usage

Start with importing WattbikeDataFrame:

from wblib.models import WattbikeDataFrame

If you are running this code from a Jupyter Notebook, run this code to show the plots inline:

%matplotlib inline

Then finally, these lines are all you need to get all data from a Wattbike session:

wdf = WattbikeDataFrame().load('LYPWXEjF9B')

...where LYPWXEjF9B is the session id from a Wattbike session that your can retrieve from the session page on the Wattbike Hub.

wdf is a WattbikeDataFrame, a sub class of Pandas DataFrame so all features of a Pandas DataFrame are available. In addition, some Wattbike specific features are added.

To plot the average polar plot of the session:

wdf.plot.polar()

Image of polar plot

It is also possible to plot all revolutions in the same plot:

wdf.plot.polar(full=True)

Image of polar plot full

...even without the mean polar plot:

wdf.plot.polar(full=True, mean=False)

Image of polar plot full without mean

To plot the power output during the session:

wdf.power.plot()

Image of power plot

To make a scatter plot of e.g. power and right_max_angle:

wdf.plot.scatter(x='power', y='right_max_angle')

Image of scatter polot

To calculate the average power, standard Pandas syntax is used:

wdf.power.mean()
>> 206.10530695107892

It is also possible to do analyses on asubset of the data, again in a Pandas-like way. For example, it is possible to plot the mean polar view for all revolutions over 400 Watt:

wdf.loc[wdf.power > 400].plot.polar()

Image of polar plot over 400 Watt

To retrieve all workouts from an in a certain date range (depending on the number of workouts this can take a while):

import datetime
wdf = WattbikeDataFrame().load_for_user(user_id='u-1756bbba7e2a350', after=datetime.datetime(2017, 1, 1), before=datetime.datetime(2017, 3, 1))

It is also possible to add an extra session to an already existing wdf by using the aforementioned load method:

wdf = wdf.load('Gbf8NgdcjH')

If you are working with a WattbikeDataFrame with multiple sessions you can make your dataset more manageable by averaging all the data per session:

wdf.average_by_session()

License

This library is licensed under a MIT license. See LICENSE.

To do

  • Add support for multiple sessions in a single WattbikeDataFrame
  • Make it possible to plot all revolutions in a single polar plot
  • Add import of .wse files

Feature request? Create an issue!