Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2017-06-17 20:27:18 +02:00
parent 87222b88c4
commit b03d88ba64
3 changed files with 66 additions and 38 deletions

View File

@@ -55,6 +55,7 @@ import rowers.dataprep as dataprep
from rowers.metrics import axes,axlabels,yaxminima,yaxmaxima
from utils import lbstoN
import datautils
watermarkurl = "/static/img/logo7.png"
watermarksource = ColumnDataSource(dict(
@@ -618,29 +619,11 @@ def interactive_otwcpchart(powerdf,promember=0):
# there is no Paul's law for OTW
# Fit the data to thee parameter CP model
fitfunc = lambda pars,x: abs(pars[0])/(1+(x/abs(pars[2]))) + abs(pars[1])/(1+(x/abs(pars[3])))
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
p0 = [500,350,10,8000]
p1 = p0
thesecs = powerdf['Delta']
theavpower = powerdf['CP']
if len(thesecs)>=4:
p1, success = optimize.leastsq(errfunc, p0[:], args = (thesecs,theavpower))
else:
factor = fitfunc(p0,thesecs.mean())/theavpower.mean()
p1 = [p0[0]/factor,p0[1]/factor,p0[2],p0[3]]
p1 = [abs(p) for p in p1]
fitt = pd.Series(10**(4*np.arange(100)/100.))
fitpower = fitfunc(p1,fitt)
p1,fitt,fitpower,ratio = datautils.cpfit(powerdf)
message = ""
#if len(fitpower[fitpower<0]) > 0:
# message = "CP model fit didn't give correct results"
@@ -652,6 +635,7 @@ def interactive_otwcpchart(powerdf,promember=0):
sourcecomplex = ColumnDataSource(
data = dict(
CP = fitpower,
CPmax = ratio*fitpower,
duration = fitt,
ftime = ftime
)
@@ -690,6 +674,7 @@ def interactive_otwcpchart(powerdf,promember=0):
hover.tooltips = OrderedDict([
('Duration ','@ftime'),
('Power (W)','@CP{int}'),
('Power (W) upper','@CPmax{int}'),
])
hover.mode = 'mouse'
@@ -697,6 +682,9 @@ def interactive_otwcpchart(powerdf,promember=0):
plot.line('duration','CP',source=sourcecomplex,legend="CP Model",
color='green')
plot.line('duration','CPmax',source=sourcecomplex,legend="CP Model",
color='red')
script, div = components(plot)
return [script,div,p1,message]