adding automatic cp calculation for ote
This commit is contained in:
@@ -96,7 +96,7 @@ queuelow = django_rq.get_queue('low')
|
||||
queuehigh = django_rq.get_queue('default')
|
||||
|
||||
from rowsandall_app.settings import SITE_URL
|
||||
from rowers.mytypes import otwtypes,otetypes
|
||||
from rowers.mytypes import otwtypes,otetypes,rowtypes
|
||||
from rowers import mytypes
|
||||
|
||||
from rowers.database import *
|
||||
@@ -1434,7 +1434,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
|
||||
isbreakthrough = False
|
||||
ishard = False
|
||||
if workouttype == 'water':
|
||||
if workouttype in rowtypes:
|
||||
df = getsmallrowdata_db(['power', 'workoutid', 'time'], ids=[w.id])
|
||||
try:
|
||||
powermean = df['power'].mean()
|
||||
@@ -1451,14 +1451,18 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
filename = 'media/cpdata_{id}.parquet.gz'.format(id=w.id)
|
||||
df.to_parquet(filename,engine='fastparquet',compression='GZIP')
|
||||
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.p0, r.p1, r.p2, r.p3, r.cpratio)
|
||||
if workouttype in otwtypes:
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.p0, r.p1, r.p2, r.p3, r.cpratio)
|
||||
elif workouttype in otetypes:
|
||||
res, btvalues, res2 = utils.isbreakthrough(
|
||||
delta, cpvalues, r.ep0, r.ep1, r.ep2, r.ep3, r.ecpratio)
|
||||
else:
|
||||
res = 0
|
||||
res2 = 0
|
||||
if res:
|
||||
isbreakthrough = True
|
||||
res = datautils.updatecp(delta, cpvalues, r)
|
||||
res = datautils.updatecp(delta, cpvalues, r,workouttype=workouttype)
|
||||
if res2 and not isbreakthrough:
|
||||
ishard = True
|
||||
|
||||
|
||||
@@ -8,12 +8,24 @@ import numpy as np
|
||||
from scipy.interpolate import griddata
|
||||
from scipy import optimize
|
||||
|
||||
from rowers.mytypes import otwtypes,otetypes,rowtypes
|
||||
|
||||
#p0 = [500,350,10,8000]
|
||||
p0 = [190,200,33,16000]
|
||||
|
||||
def updatecp(delta,cpvalues,r):
|
||||
cp2 = r.p0/(1+delta/r.p2)
|
||||
cp2 += r.p1/(1+delta/r.p3)
|
||||
def updatecp(delta,cpvalues,r,workouttype='water'):
|
||||
if workouttype in otwtypes:
|
||||
p0 = r.p0
|
||||
p1 = r.p1
|
||||
p2 = r.p2
|
||||
p3 = r.p3
|
||||
else:
|
||||
p0 = r.ep0
|
||||
p1 = r.ep1
|
||||
p2 = r.ep2
|
||||
p3 = r.ep3
|
||||
cp2 = p0/(1+delta/p2)
|
||||
cp2 += p1/(1+delta/p3)
|
||||
|
||||
delta = delta.append(delta)
|
||||
cp = cpvalues.append(cp2)
|
||||
@@ -31,11 +43,18 @@ def updatecp(delta,cpvalues,r):
|
||||
res = cpfit(powerdf)
|
||||
p1 = res[0]
|
||||
|
||||
r.p0 = p1[0]
|
||||
r.p1 = p1[1]
|
||||
r.p2 = p1[2]
|
||||
r.p3 = p1[3]
|
||||
r.cpratio = res[3]
|
||||
if workouttype in otwtypes:
|
||||
r.p0 = p1[0]
|
||||
r.p1 = p1[1]
|
||||
r.p2 = p1[2]
|
||||
r.p3 = p1[3]
|
||||
r.cpratio = res[3]
|
||||
else:
|
||||
r.ep0 = p1[0]
|
||||
r.ep1 = p1[1]
|
||||
r.ep2 = p1[2]
|
||||
r.ep3 = p1[3]
|
||||
r.ecpratio = res[3]
|
||||
|
||||
r.save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user