Skip to content

Commit

Permalink
new monthly jupyter notebook with weight and training load graphs; no…
Browse files Browse the repository at this point in the history
…tebook fixes
  • Loading branch information
tcgoetz committed Feb 21, 2024
1 parent 3f9e2cc commit fe68a4a
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Fit
Submodule Fit updated 1 files
+1 −1 Makefile
2 changes: 1 addition & 1 deletion Jupyter/activities_dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Jupyter/course.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.7"
},
"orig_nbformat": 4
},
Expand Down
14 changes: 7 additions & 7 deletions Jupyter/daily.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"outputs": [],
"source": [
"\n",
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 1))\n"
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 1))"
]
},
{
Expand All @@ -70,7 +70,7 @@
"metadata": {},
"outputs": [],
"source": [
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 3))\n"
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 3))"
]
},
{
Expand All @@ -79,7 +79,7 @@
"metadata": {},
"outputs": [],
"source": [
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 4))\n"
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 4))"
]
},
{
Expand All @@ -88,7 +88,7 @@
"metadata": {},
"outputs": [],
"source": [
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 5))\n"
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 5))"
]
},
{
Expand All @@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 6))\n"
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 6))"
]
},
{
Expand All @@ -106,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 7))\n"
"__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 7))"
]
}
],
Expand All @@ -128,7 +128,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.7"
},
"orig_nbformat": 4
},
Expand Down
180 changes: 174 additions & 6 deletions Jupyter/daily_trends.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "b8aada92",
"metadata": {},
"outputs": [],
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "2d38e0f7-2ee5-40df-9373-b6485798d541",
"metadata": {},
"outputs": [],
Expand All @@ -38,7 +38,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "7353aa53-92a0-44d9-b476-e050295c4748",
"metadata": {},
"outputs": [],
Expand All @@ -59,10 +59,178 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "e41203c2-d435-4045-9c84-3559b4d3b367",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date</th>\n",
" <th>stress_avg</th>\n",
" <th>bb_max</th>\n",
" <th>bb_min</th>\n",
" <th>rem_sleep_max</th>\n",
" <th>deep_sleep</th>\n",
" <th>sleep_avg</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2022-05-02</td>\n",
" <td>18</td>\n",
" <td>80</td>\n",
" <td>23</td>\n",
" <td>13.0</td>\n",
" <td>106.0</td>\n",
" <td>7.616667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2022-05-03</td>\n",
" <td>36</td>\n",
" <td>100</td>\n",
" <td>18</td>\n",
" <td>94.0</td>\n",
" <td>24.0</td>\n",
" <td>8.533333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2022-05-04</td>\n",
" <td>31</td>\n",
" <td>70</td>\n",
" <td>21</td>\n",
" <td>110.0</td>\n",
" <td>0.0</td>\n",
" <td>7.666667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2022-05-05</td>\n",
" <td>32</td>\n",
" <td>63</td>\n",
" <td>18</td>\n",
" <td>74.0</td>\n",
" <td>31.0</td>\n",
" <td>6.416667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2022-05-06</td>\n",
" <td>36</td>\n",
" <td>93</td>\n",
" <td>14</td>\n",
" <td>111.0</td>\n",
" <td>14.0</td>\n",
" <td>8.933333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>653</th>\n",
" <td>2024-02-14</td>\n",
" <td>47</td>\n",
" <td>65</td>\n",
" <td>5</td>\n",
" <td>52.0</td>\n",
" <td>None</td>\n",
" <td>6.183333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>654</th>\n",
" <td>2024-02-15</td>\n",
" <td>41</td>\n",
" <td>20</td>\n",
" <td>5</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>4.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>655</th>\n",
" <td>2024-02-16</td>\n",
" <td>30</td>\n",
" <td>52</td>\n",
" <td>21</td>\n",
" <td>10.0</td>\n",
" <td>None</td>\n",
" <td>7.266667</td>\n",
" </tr>\n",
" <tr>\n",
" <th>656</th>\n",
" <td>2024-02-17</td>\n",
" <td>39</td>\n",
" <td>71</td>\n",
" <td>12</td>\n",
" <td>15.0</td>\n",
" <td>None</td>\n",
" <td>6.333333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>657</th>\n",
" <td>2024-02-18</td>\n",
" <td>45</td>\n",
" <td>34</td>\n",
" <td>5</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>7.15</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>658 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" Date stress_avg bb_max bb_min rem_sleep_max deep_sleep sleep_avg\n",
"0 2022-05-02 18 80 23 13.0 106.0 7.616667\n",
"1 2022-05-03 36 100 18 94.0 24.0 8.533333\n",
"2 2022-05-04 31 70 21 110.0 0.0 7.666667\n",
"3 2022-05-05 32 63 18 74.0 31.0 6.416667\n",
"4 2022-05-06 36 93 14 111.0 14.0 8.933333\n",
".. ... ... ... ... ... ... ...\n",
"653 2024-02-14 47 65 5 52.0 None 6.183333\n",
"654 2024-02-15 41 20 5 0.0 None 4.3\n",
"655 2024-02-16 30 52 21 10.0 None 7.266667\n",
"656 2024-02-17 39 71 12 15.0 None 6.333333\n",
"657 2024-02-18 45 34 5 0.0 None 7.15\n",
"\n",
"[658 rows x 7 columns]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stress_avg = [entry.stress_avg for entry in data]\n",
"bb_max = [entry.bb_max for entry in data]\n",
Expand Down Expand Up @@ -203,7 +371,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Jupyter/garmin.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.7"
},
"orig_nbformat": 4
},
Expand Down
23 changes: 19 additions & 4 deletions Jupyter/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import matplotlib.dates as mdates

from garmindb import ConfigManager
from garmindb.garmindb import MonitoringDb, Monitoring, MonitoringHeartRate
from garmindb.garmindb import MonitoringDb, Monitoring, MonitoringHeartRate, ActivitiesDb
from garmindb.summarydb import DaysSummary, WeeksSummary, MonthsSummary, SummaryDb


config = {
'size' : [16.0, 12.0],
'size' : [8.0, 6.0],
'steps' : {'period' : 'weeks', 'days' : 730},
'hr' : {'period' : 'weeks', 'days' : 730},
'itime' : {'period' : 'weeks', 'days' : 730},
Expand Down Expand Up @@ -88,7 +88,21 @@ def __remove_discontinuities(cls, data):
return data

@classmethod
def __graph_multiple_single_axes(cls, time, data_list, stat_name, ylabel, save, geometry=111):
def _graph_scatter(cls, time, data, stat_name, ylabel, save=False, geometry=111):
title = f'{stat_name} Over Time'
figure = plt.figure(figsize=config.get('size'))
color = Colors.from_integer(0).name
axes = figure.add_subplot(geometry, frame_on=True)
axes.scatter(time, data, color=color)
axes.grid()
axes.set_title(title)
axes.set_xlabel('Time')
axes.set_ylabel(ylabel)
if save:
figure.savefig(stat_name + ".png")

@classmethod
def _graph_multiple_single_axes(cls, time, data_list, stat_name, ylabel, save=False, geometry=111):
title = f'{stat_name} Over Time'
figure = plt.figure(figsize=config.get('size'))
for index, data in enumerate(data_list):
Expand Down Expand Up @@ -182,8 +196,9 @@ def _graph_itime(self, time, data, period, geometry=111):
yrange_list, self.save, geometry)

def _graph_weight(self, time, data, period, geometry=111):
"""Generate a graph weight"""
weight = [entry.weight_avg for entry in data]
self.__graph_multiple_single_axes(time, [weight], 'Weight', 'weight', self.save, geometry)
self._graph_multiple_single_axes(time, [weight], 'Weight', 'weight', self.save, geometry)

def graph_activity(self, activity, period=None, days=None, geometry=111):
"""Generate a graph for the given activity with points every period spanning days."""
Expand Down
Loading

0 comments on commit fe68a4a

Please sign in to comment.