Private
Public Access
1
0

adding automatic cp calculation for ote

This commit is contained in:
Sander Roosendaal
2020-10-01 08:51:37 +02:00
parent 287d2da73f
commit 52725cb593
2 changed files with 36 additions and 13 deletions

View File

@@ -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()