commit
This commit is contained in:
@@ -11,17 +11,17 @@ import pandas as pd
|
||||
from scipy import optimize
|
||||
from django.utils import timezone
|
||||
|
||||
from math import log10,log2
|
||||
from rowers.mytypes import otwtypes,otetypes
|
||||
from math import log10, log2
|
||||
from rowers.mytypes import otwtypes, otetypes
|
||||
|
||||
nometrics = [
|
||||
'originalvelo',
|
||||
# 'cumdist',
|
||||
# 'cumdist',
|
||||
'strokes_slsh_min',
|
||||
' WorkPerStroke (joules)',
|
||||
' activityIdx',
|
||||
' lapIdx',
|
||||
# ' pointIdx',
|
||||
# ' pointIdx',
|
||||
' WorkoutType',
|
||||
' IntervalType',
|
||||
' WorkoutState',
|
||||
@@ -46,353 +46,353 @@ nometrics = [
|
||||
'Distance (IMP)',
|
||||
'equivergpower',
|
||||
'cum_dist.1'
|
||||
]
|
||||
]
|
||||
|
||||
rowingmetrics = (
|
||||
('time',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('time', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Time',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1e5,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'type': 'basic',
|
||||
'group':'basic',
|
||||
'group': 'basic',
|
||||
'maysmooth': False,
|
||||
'sigfigs': -1}),
|
||||
|
||||
('hr',{
|
||||
'numtype':'integer',
|
||||
'null':True,
|
||||
('hr', {
|
||||
'numtype': 'integer',
|
||||
'null': True,
|
||||
'verbose_name': 'Heart Rate (bpm)',
|
||||
'ax_min': 100,
|
||||
'ax_max': 200,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'type': 'basic',
|
||||
'maysmooth': False,
|
||||
'group':'athlete',
|
||||
'sigfigs':0,}),
|
||||
'group': 'athlete',
|
||||
'sigfigs': 0, }),
|
||||
|
||||
('pace',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('pace', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Pace (/500m)',
|
||||
'ax_min': 1.0e3*210,
|
||||
'ax_max': 1.0e3*75,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'type': 'basic',
|
||||
'sigfigs': 1,
|
||||
'maysmooth': True,
|
||||
'group': 'basic'}),
|
||||
|
||||
('velo',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('velo', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Boat Speed (m/s)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 8,
|
||||
'default': 0,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'sigfigs': 1,
|
||||
'maysmooth': True,
|
||||
'type':'pro',
|
||||
'type': 'pro',
|
||||
'group': 'basic'}),
|
||||
|
||||
# ('powerhr',{
|
||||
# 'numtype':'float',
|
||||
# 'null':True,
|
||||
# 'verbose_name': 'Power Heart Rate Efficiency (J/beat)',
|
||||
# 'ax_min':0,
|
||||
# 'ax_max':300,
|
||||
# 'mode':'both',
|
||||
# 'type':'pro',
|
||||
# 'group':'athlete'}),
|
||||
# ('powerhr',{
|
||||
# 'numtype':'float',
|
||||
# 'null':True,
|
||||
# 'verbose_name': 'Power Heart Rate Efficiency (J/beat)',
|
||||
# 'ax_min':0,
|
||||
# 'ax_max':300,
|
||||
# 'mode':'both',
|
||||
# 'type':'pro',
|
||||
# 'group':'athlete'}),
|
||||
|
||||
('spm',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('spm', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Stroke Rate (spm)',
|
||||
'ax_min': 15,
|
||||
'ax_max': 45,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'sigfigs': 1,
|
||||
'type': 'basic',
|
||||
'maysmooth': True,
|
||||
'group':'basic'}),
|
||||
'group': 'basic'}),
|
||||
|
||||
('driveenergy',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('driveenergy', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Work Per Stroke (J)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1000,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'sigfigs': 0,
|
||||
'type': 'pro',
|
||||
'maysmooth': True,
|
||||
'group':'forcepower'}),
|
||||
'group': 'forcepower'}),
|
||||
|
||||
('power',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('power', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Power (W)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 600,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'sigfigs': 0,
|
||||
'type': 'basic',
|
||||
'maysmooth': True,
|
||||
'group':'forcepower'}),
|
||||
'group': 'forcepower'}),
|
||||
|
||||
('averageforce',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('averageforce', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Average Drive Force (N)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1200,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'sigfigs': 0,
|
||||
'maysmooth': True,
|
||||
'type': 'pro',
|
||||
'group':'forcepower'}),
|
||||
'group': 'forcepower'}),
|
||||
|
||||
('peakforce',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('peakforce', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Peak Drive Force (N)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1500,
|
||||
'sigfigs': 0,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'maysmooth': True,
|
||||
'type': 'pro',
|
||||
'group':'forcepower'}),
|
||||
'group': 'forcepower'}),
|
||||
|
||||
('drivelength',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('drivelength', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Drive Length (m)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 2.5,
|
||||
'mode':'rower',
|
||||
'mode': 'rower',
|
||||
'sigfigs': 2,
|
||||
'maysmooth': False,
|
||||
'type': 'pro',
|
||||
'group':'stroke'}),
|
||||
'group': 'stroke'}),
|
||||
|
||||
('forceratio',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('forceratio', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Average/Peak Force Ratio',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1,
|
||||
'sigfigs': 2,
|
||||
'maysmooth': True,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'type': 'pro',
|
||||
'group': 'forcepower'}),
|
||||
|
||||
('distance',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('distance', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Interval Distance (m)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1e5,
|
||||
'sigfigs': 0,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'maysmooth': False,
|
||||
'type': 'basic',
|
||||
'group':'basic'}),
|
||||
'group': 'basic'}),
|
||||
|
||||
('cumdist',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('cumdist', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Cumulative Distance (m)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 1e5,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'sigfigs': 0,
|
||||
'maysmooth': False,
|
||||
'type': 'basic',
|
||||
'group':'basic'}),
|
||||
'group': 'basic'}),
|
||||
|
||||
('drivespeed',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('drivespeed', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Drive Speed (m/s)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 4,
|
||||
'default': 0,
|
||||
'sigfigs': 2,
|
||||
'maysmooth': True,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'type': 'pro',
|
||||
'group': 'stroke'}),
|
||||
|
||||
|
||||
('catch',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('catch', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Catch Angle (degrees)',
|
||||
'ax_min': -40,
|
||||
'ax_max': -75,
|
||||
'default': 0,
|
||||
'sigfigs': 0,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'maysmooth': True,
|
||||
'type': 'pro',
|
||||
'group': 'stroke'}),
|
||||
|
||||
('slip',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('slip', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Slip (degrees)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 20,
|
||||
'default': 0,
|
||||
'sigfigs': 1,
|
||||
'maysmooth': True,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'type': 'pro',
|
||||
'group': 'stroke'}),
|
||||
|
||||
('finish',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('finish', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Finish Angle (degrees)',
|
||||
'ax_min': 20,
|
||||
'ax_max': 55,
|
||||
'default': 0,
|
||||
'sigfigs': 0,
|
||||
'maysmooth': True,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'type': 'pro',
|
||||
'group': 'stroke'}),
|
||||
|
||||
('wash',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('wash', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Wash (degrees)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 30,
|
||||
'default': 0,
|
||||
'sigfigs': 1,
|
||||
'maysmooth': True,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'type': 'pro',
|
||||
'group': 'stroke'}),
|
||||
|
||||
('peakforceangle',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('peakforceangle', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Peak Force Angle',
|
||||
'ax_min': -50,
|
||||
'ax_max': 50,
|
||||
'default': 0,
|
||||
'sigfigs': 0,
|
||||
'maysmooth': True,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'type': 'pro',
|
||||
'group':'stroke'}),
|
||||
'group': 'stroke'}),
|
||||
|
||||
|
||||
('totalangle',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('totalangle', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Drive Length (deg)',
|
||||
'ax_min': 40,
|
||||
'ax_max': 140,
|
||||
'default': 0,
|
||||
'sigfigs': 0,
|
||||
'maysmooth': True,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'type': 'pro',
|
||||
'group':'stroke'}),
|
||||
'group': 'stroke'}),
|
||||
|
||||
|
||||
('effectiveangle',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('effectiveangle', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Effective Drive Length (deg)',
|
||||
'ax_min': 40,
|
||||
'ax_max': 140,
|
||||
'default': 0,
|
||||
'sigfigs': 0,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'maysmooth': True,
|
||||
'type': 'pro',
|
||||
'group':'stroke'}),
|
||||
'group': 'stroke'}),
|
||||
|
||||
('rhythm',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('rhythm', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Stroke Rhythm',
|
||||
'ax_min': 20,
|
||||
'ax_max': 55,
|
||||
'default': 1.0,
|
||||
'sigfigs': 0,
|
||||
'mode':'erg',
|
||||
'mode': 'erg',
|
||||
'maysmooth': True,
|
||||
'type': 'pro',
|
||||
'group':'stroke'}),
|
||||
'group': 'stroke'}),
|
||||
|
||||
('efficiency',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('efficiency', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'OTW Efficiency (%)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 110,
|
||||
'default': 0,
|
||||
'sigfigs': 0,
|
||||
'mode':'water',
|
||||
'mode': 'water',
|
||||
'maysmooth': True,
|
||||
'type': 'pro',
|
||||
'group':'forcepower'}),
|
||||
'group': 'forcepower'}),
|
||||
|
||||
('distanceperstroke',{
|
||||
'numtype':'float',
|
||||
'null':True,
|
||||
('distanceperstroke', {
|
||||
'numtype': 'float',
|
||||
'null': True,
|
||||
'verbose_name': 'Distance per Stroke (m)',
|
||||
'ax_min': 0,
|
||||
'ax_max': 15,
|
||||
'default': 0,
|
||||
'sigfigs': 1,
|
||||
'maysmooth': True,
|
||||
'mode':'both',
|
||||
'mode': 'both',
|
||||
'type': 'basic',
|
||||
'group':'basic'}),
|
||||
'group': 'basic'}),
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
metricsdicts = {}
|
||||
for key,dict in rowingmetrics:
|
||||
for key, dict in rowingmetrics:
|
||||
metricsdicts[key] = dict
|
||||
|
||||
|
||||
|
||||
metricsgroups = list(set([d['group'] for n,d in rowingmetrics]))
|
||||
metricsgroups = list(set([d['group'] for n, d in rowingmetrics]))
|
||||
|
||||
dtypes = {}
|
||||
|
||||
for name,d in rowingmetrics:
|
||||
for name, d in rowingmetrics:
|
||||
if d['numtype'] == 'float':
|
||||
dtypes[name] = float
|
||||
elif d['numtype'] == 'int': # pragma: no cover
|
||||
elif d['numtype'] == 'int': # pragma: no cover
|
||||
dtypes[name] = int
|
||||
|
||||
axesnew = [
|
||||
(name,d['verbose_name'],d['ax_min'],d['ax_max'],d['type']) for name,d in rowingmetrics
|
||||
]
|
||||
(name, d['verbose_name'], d['ax_min'], d['ax_max'], d['type']) for name, d in rowingmetrics
|
||||
]
|
||||
|
||||
axes = tuple(axesnew+[('None','<None>',0,1,'basic')])
|
||||
axes = tuple(axesnew+[('None', '<None>', 0, 1, 'basic')])
|
||||
|
||||
axlabels = {ax[0]:ax[1] for ax in axes}
|
||||
axlabels = {ax[0]: ax[1] for ax in axes}
|
||||
|
||||
yaxminima = {ax[0]:ax[2] for ax in axes}
|
||||
yaxminima = {ax[0]: ax[2] for ax in axes}
|
||||
|
||||
yaxmaxima = {ax[0]:ax[3] for ax in axes}
|
||||
yaxmaxima = {ax[0]: ax[3] for ax in axes}
|
||||
|
||||
def get_yaxminima(r,metric,mode):
|
||||
|
||||
def get_yaxminima(r, metric, mode):
|
||||
if metric == 'pace':
|
||||
if mode in otetypes:
|
||||
return r.slowpaceerg
|
||||
@@ -401,7 +401,8 @@ def get_yaxminima(r,metric,mode):
|
||||
|
||||
return yaxminima[metric]
|
||||
|
||||
def get_yaxmaxima(r,metric,mode):
|
||||
|
||||
def get_yaxmaxima(r, metric, mode):
|
||||
if metric == 'pace':
|
||||
if mode in otetypes:
|
||||
return r.fastpaceerg
|
||||
@@ -411,75 +412,73 @@ def get_yaxmaxima(r,metric,mode):
|
||||
return yaxmaxima[metric]
|
||||
|
||||
|
||||
|
||||
defaultfavoritecharts = (
|
||||
{
|
||||
'yparam1':'pace',
|
||||
'yparam2':'spm',
|
||||
'xparam':'time',
|
||||
'plottype':'line',
|
||||
'workouttype':'both',
|
||||
'reststrokes':True,
|
||||
'notes':"""This chart shows your pace and stroke rate versus time. """,
|
||||
},
|
||||
'yparam1': 'pace',
|
||||
'yparam2': 'spm',
|
||||
'xparam': 'time',
|
||||
'plottype': 'line',
|
||||
'workouttype': 'both',
|
||||
'reststrokes': True,
|
||||
'notes': """This chart shows your pace and stroke rate versus time. """,
|
||||
},
|
||||
{
|
||||
'yparam1':'pace',
|
||||
'yparam2':'hr',
|
||||
'xparam':'time',
|
||||
'plottype':'line',
|
||||
'workouttype':'both',
|
||||
'reststrokes':True,
|
||||
'notes':"""This chart shows your pace and heart rate versus time.
|
||||
'yparam1': 'pace',
|
||||
'yparam2': 'hr',
|
||||
'xparam': 'time',
|
||||
'plottype': 'line',
|
||||
'workouttype': 'both',
|
||||
'reststrokes': True,
|
||||
'notes': """This chart shows your pace and heart rate versus time.
|
||||
Heart rate values will be shown only when it is in your data, i.e.
|
||||
in case you recorded your heart rate during your workout""",
|
||||
},
|
||||
},
|
||||
{
|
||||
'yparam1':'distanceperstroke',
|
||||
'yparam2':'hr',
|
||||
'xparam':'time',
|
||||
'plottype':'line',
|
||||
'workouttype':'otw',
|
||||
'reststrokes':True,
|
||||
'notes':"""This chart shows the Distance covered per stroke, and your
|
||||
'yparam1': 'distanceperstroke',
|
||||
'yparam2': 'hr',
|
||||
'xparam': 'time',
|
||||
'plottype': 'line',
|
||||
'workouttype': 'otw',
|
||||
'reststrokes': True,
|
||||
'notes': """This chart shows the Distance covered per stroke, and your
|
||||
heart rate versus time. """,
|
||||
},
|
||||
},
|
||||
{
|
||||
'yparam1':'driveenergy',
|
||||
'yparam2':'hr',
|
||||
'xparam':'time',
|
||||
'plottype':'line',
|
||||
'workouttype':'ote',
|
||||
'reststrokes':True,
|
||||
'notes':"""This chart shows the Work per Stroke and your heart rate
|
||||
'yparam1': 'driveenergy',
|
||||
'yparam2': 'hr',
|
||||
'xparam': 'time',
|
||||
'plottype': 'line',
|
||||
'workouttype': 'ote',
|
||||
'reststrokes': True,
|
||||
'notes': """This chart shows the Work per Stroke and your heart rate
|
||||
plotted versus time. """,
|
||||
},
|
||||
},
|
||||
{
|
||||
'yparam1':'distanceperstroke',
|
||||
'yparam2':'None',
|
||||
'xparam':'spm',
|
||||
'plottype':'scatter',
|
||||
'workouttype':'otw',
|
||||
'reststrokes':True,
|
||||
'notes':"""This chart shows the Distance per Stroke versus stroke
|
||||
'yparam1': 'distanceperstroke',
|
||||
'yparam2': 'None',
|
||||
'xparam': 'spm',
|
||||
'plottype': 'scatter',
|
||||
'workouttype': 'otw',
|
||||
'reststrokes': True,
|
||||
'notes': """This chart shows the Distance per Stroke versus stroke
|
||||
stroke rate. You should see a steady decline of the Distance per Stroke
|
||||
as you increase stroke rate. Typical values are > 10m for steady state
|
||||
dropping to 8m for race pace in the single.""",
|
||||
},
|
||||
},
|
||||
{
|
||||
'yparam1':'driveenergy',
|
||||
'yparam2':'None',
|
||||
'xparam':'spm',
|
||||
'plottype':'scatter',
|
||||
'workouttype':'ote',
|
||||
'reststrokes':True,
|
||||
'notes':"""This chart shows the Work per Stroke versus Stroke Rate.
|
||||
'yparam1': 'driveenergy',
|
||||
'yparam2': 'None',
|
||||
'xparam': 'spm',
|
||||
'plottype': 'scatter',
|
||||
'workouttype': 'ote',
|
||||
'reststrokes': True,
|
||||
'notes': """This chart shows the Work per Stroke versus Stroke Rate.
|
||||
This value should be fairly constant across all stroke rates.""",
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
def calc_trimp(df,sex,hrmax,hrmin,hrftp): # pragma: no cover
|
||||
def calc_trimp(df, sex, hrmax, hrmin, hrftp): # pragma: no cover
|
||||
if sex == 'male':
|
||||
f = 1.92
|
||||
else:
|
||||
@@ -496,4 +495,4 @@ def calc_trimp(df,sex,hrmax,hrmin,hrftp): # pragma: no cover
|
||||
|
||||
hrtss = 100*trimp/trimp1hr
|
||||
|
||||
return trimp,hrtss
|
||||
return trimp, hrtss
|
||||
|
||||
Reference in New Issue
Block a user