Private
Public Access
1
0

added HR drift, normalized power, training score

This commit is contained in:
Sander Roosendaal
2017-05-12 14:19:50 +02:00
parent e1893ab4ff
commit 29f84d6e25
3 changed files with 85 additions and 1 deletions

View File

@@ -4036,6 +4036,9 @@ def cumstats(request,theuser=0,
# Stats page
@login_required()
def workout_stats_view(request,id=0,message="",successmessage=""):
r = Rower.objects.get(user=request.user)
workstrokesonly = True
if request.method == 'POST' and 'workstrokesonly' in request.POST:
workstrokesonly = request.POST['workstrokesonly']
@@ -4093,6 +4096,56 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
cordict[field1] = thedict
# additional non-automated stats
otherstats = {}
# Normalized power & TSS
duration = datadf['time'].max()-datadf['time'].min()
duration /= 1.0e3
pwr4 = datadf['power']**(4)
normp = (pwr4.mean())**(0.25)
if not np.isnan(normp):
intensityfactor = datadf['power'].mean()/float(r.ftp)
intensityfactor = normp/float(r.ftp)
tss = 100.*((duration*normp*intensityfactor)/(3600.*r.ftp))
otherstats['np'] = {
'verbose_name':'rPower',
'value':int(10*normp)/10.,
'unit':'Watt'
}
otherstats['tss'] = {
'verbose_name':'rScore',
'value':int(tss),
'unit':''
}
# HR Drift
tmax = datadf['time'].max()
tmin = datadf['time'].min()
thalf = tmin+0.5*(tmax-tmin)
mask1 = datadf['time'] < thalf
mask2 = datadf['time'] > thalf
hr1 = datadf.loc[mask1,'hr'].mean()
hr2 = datadf.loc[mask2,'hr'].mean()
pwr1 = datadf.loc[mask1,'power'].mean()
pwr2 = datadf.loc[mask2,'power'].mean()
try:
hrdrift = ((pwr1/hr1)-(pwr2/hr2))/(pwr1/hr1)
hrdrift *= 100.
otherstats['hrdrift'] = {
'verbose_name': 'Heart Rate Drift',
'value': int(100*hrdrift)/100.,
'unit': '%',
}
except ZeroDivisionError:
pass
return render(request,
'workoutstats.html',
{
@@ -4101,6 +4154,7 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
'workout':row,
'workstrokesonly':workstrokesonly,
'cordict':cordict,
'otherstats':otherstats,
})
# The Advanced edit page