Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2022-02-15 08:05:12 +01:00
parent 5b3d7fcf2c
commit 8af7ac8af4
71 changed files with 19992 additions and 19476 deletions

View File

@@ -3,7 +3,7 @@ from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from matplotlib.ticker import MultipleLocator,FuncFormatter,NullFormatter
from matplotlib.ticker import MultipleLocator, FuncFormatter, NullFormatter
import matplotlib.pyplot as plt
import numpy as np
@@ -11,7 +11,7 @@ from rowers.rows import format_pace_tick, format_pace, format_time, format_time_
# Formatting the distance tick marks
#def format_dist_tick(x,pos=None):
# def format_dist_tick(x,pos=None):
# km = x/1000.
# template='%6.3f'
# return template % (km)
@@ -22,21 +22,18 @@ from rowers.rows import format_pace_tick, format_pace, format_time, format_time_
# you can set the slowest paces to fall off the axis.
# Useful for OTW rowing where you sometimes stops and pace runs out of
# the boundaries
def y_axis_range(ydata,miny=0,padding=.1,ultimate=[-1e9,1e9]):
def y_axis_range(ydata, miny=0, padding=.1, ultimate=[-1e9, 1e9]):
# ydata must by a numpy array
ymin = np.ma.masked_invalid(ydata).min()
ymax = np.ma.masked_invalid(ydata).max()
yrange = ymax-ymin
yrangemin = ymin
yrangemax = ymax
if (yrange == 0): # pragma: no cover
if (yrange == 0): # pragma: no cover
if ymin == 0:
yrangemin = -padding
else:
@@ -49,37 +46,37 @@ def y_axis_range(ydata,miny=0,padding=.1,ultimate=[-1e9,1e9]):
yrangemin = ymin-padding*yrange
yrangemax = ymax+padding*yrange
if (yrangemin < ultimate[0]): # pragma: no cover
if (yrangemin < ultimate[0]): # pragma: no cover
yrangemin = ultimate[0]
if (yrangemax > ultimate[1]):
yrangemax = ultimate[1]
return [yrangemin,yrangemax]
return [yrangemin, yrangemax]
# Make a plot (this one is only used for testing)
def mkplot(row,title):
def mkplot(row, title):
df = row.df
t = df.loc[:,' ElapsedTime (sec)'].values
p = df.loc[:,' Stroke500mPace (sec/500m)'].values
hr = df.loc[:,' HRCur (bpm)'].values
end_time = int(df.loc[:,'TimeStamp (sec)'].iloc[df.shape[0]-1])
t = df.loc[:, ' ElapsedTime (sec)'].values
p = df.loc[:, ' Stroke500mPace (sec/500m)'].values
hr = df.loc[:, ' HRCur (bpm)'].values
end_time = int(df.loc[:, 'TimeStamp (sec)'].iloc[df.shape[0]-1])
fig, ax1 = plt.subplots(figsize=(5,4))
fig, ax1 = plt.subplots(figsize=(5, 4))
ax1.plot(t,p,'b-')
ax1.plot(t, p, 'b-')
ax1.set_xlabel('Time (h:m)')
ax1.set_ylabel('(sec/500)')
yrange = y_axis_range(df.loc[:,' Stroke500mPace (sec/500m)'],
ultimate = [85,190])
plt.axis([0,end_time,yrange[1],yrange[0]])
yrange = y_axis_range(df.loc[:, ' Stroke500mPace (sec/500m)'],
ultimate=[85, 190])
plt.axis([0, end_time, yrange[1], yrange[0]])
ax1.set_xticks(range(1000,end_time,1000))
ax1.set_yticks(range(185,90,-10))
ax1.set_xticks(range(1000, end_time, 1000))
ax1.set_yticks(range(185, 90, -10))
ax1.set_title(title)
plt.grid(True)
majorFormatter = FuncFormatter(format_pace_tick)
@@ -92,8 +89,8 @@ def mkplot(row,title):
tl.set_color('b')
ax2 = ax1.twinx()
ax2.plot(t,hr,'r-')
ax2.set_ylabel('Heart Rate',color='r')
ax2.plot(t, hr, 'r-')
ax2.set_ylabel('Heart Rate', color='r')
majorTimeFormatter = FuncFormatter(format_time_tick)
majorLocator = (15*60)
ax2.xaxis.set_major_formatter(majorTimeFormatter)