Private
Public Access
1
0

added hrScore to stats and plannedsessions

in plannedsessions, if rScore = 0, taking hrScore
This commit is contained in:
Sander Roosendaal
2018-04-09 10:30:55 +02:00
parent 3ec4494342
commit f3ecaab599
4 changed files with 33 additions and 10 deletions

View File

@@ -172,7 +172,7 @@ def workout_summary_to_df(
id=w.id
)
csv_links.append(csv_link)
trimps.append(workout_trimp(w))
trimps.append(workout_trimp(w)[0])
rscore = workout_rscore(w)
rscores.append(int(rscore[0]))
@@ -2302,17 +2302,20 @@ def dataprep(rowdatadf, id=0, bands=True, barchart=True, otwpower=True,
engine.dispose()
return data
def workout_trimp(workout):
r = workout.user
hrftp = (r.an+r.tr)/2.
df,row = getrowdata_db(id=workout.id)
df = clean_df_stats(df,workstrokesonly=False)
if df.empty:
df,row = getrowdata_db(id=workout.id)
df = clean_df_stats(df,workstrokesonly=False)
trimp = calc_trimp(df,r.sex,r.max,r.rest)
trimp,hrtss = calc_trimp(df,r.sex,r.max,r.rest,hrftp)
trimp = int(trimp)
hrtss = int(hrtss)
return trimp
return trimp,hrtss
def workout_rscore(w):
r = w.user

View File

@@ -334,7 +334,7 @@ This value should be fairly constant across all stroke rates.""",
)
def calc_trimp(df,sex,hrmax,hrmin):
def calc_trimp(df,sex,hrmax,hrmin,hrftp):
if sex == 'male':
f = 1.92
else:
@@ -343,10 +343,14 @@ def calc_trimp(df,sex,hrmax,hrmin):
dt = df['time'].diff()/6.e4
hrr = (df['hr']-hrmin)/(hrmax-hrmin)
hrrftp = (hrftp-hrmin)/(hrmax-hrmin)
trimp1hr = 60*hrrftp*0.64*np.exp(f*hrrftp)
trimpdata = dt*hrr*0.64*np.exp(f*hrr)
trimp = trimpdata.sum()
return trimp
hrtss = 100*trimp/trimp1hr
return trimp,hrtss
def getagegrouprecord(age,sex='male',weightcategory='hwt',

View File

@@ -111,8 +111,13 @@ def get_session_metrics(ps):
for w in ws:
distancev += w.distance
durationv += timefield_to_seconds_duration(w.duration)
trimpv += dataprep.workout_trimp(w)
rscorev += dataprep.workout_rscore(w)[0]
thetrimp,hrtss = dataprep.workout_trimp(w)
trimpv += thetrimp
tss = dataprep.workout_rscore(w)[0]
if not np.isnan(tss) and tss != 0:
rscorev += tss
elif tss == 0:
rscorev += hrtss
ratio,statusv,completiondate = is_session_complete_ws(ws,ps)
try:
@@ -181,11 +186,16 @@ def is_session_complete_ws(ws,ps):
durationseconds = timefield_to_seconds_duration(w.duration)
score += durationseconds
elif ps.sessionmode == 'TRIMP':
trimp = dataprep.workout_trimp(w)
trimp,hrtss = dataprep.workout_trimp(w)
score += trimp
elif ps.sessionmode == 'rScore':
rscore = dataprep.workout_rscore(w)[0]
if not np.isnan(rscore) and rscore != 0:
score += rscore
elif rscore == 0:
trimp,hrtss = dataprep.workout_trimp(w)
score += hrtss
if not completiondate and score>=cratiomin*value:
completiondate = w.date

View File

@@ -7832,7 +7832,7 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
pass
# TRIMP
trimp = dataprep.workout_trimp(w)
trimp,hrtss = dataprep.workout_trimp(w)
otherstats['trimp'] = {
'verbose_name': 'TRIMP',
@@ -7840,6 +7840,12 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
'unit': ''
}
otherstats['hrScore'] = {
'verbose_name': 'rScore (HR)',
'value': hrtss,
'unit':''
}
return render(request,
'workoutstats.html',
{