Private
Public Access
1
0

changed to exponential function

This commit is contained in:
Sander Roosendaal
2017-12-14 15:41:01 +01:00
parent 6b7207321c
commit 03eec117a6
3 changed files with 39 additions and 9 deletions

View File

@@ -53,6 +53,7 @@ import stravastuff
from rowers.dataprep import rdata
import rowers.dataprep as dataprep
import rowers.metrics as metrics
from rowers.metrics import axes,axlabels,yaxminima,yaxmaxima
@@ -1069,24 +1070,38 @@ def interactive_otwcpchart(powerdf,promember=0):
return [script,div,p1,ratio,message]
def interactive_agegroup_plot(df):
def interactive_agegroup_plot(df,distance=2000,duration=None,
sex='male',weightcategory='hwt'):
age = df['age']
power = df['power']
name = df['name']
season = df['season']
poly_coefficients = np.polyfit(age,power,6)
# poly_coefficients = np.polyfit(age,power,6)
age2 = np.linspace(11,95)
poly_vals = np.polyval(poly_coefficients,age2)
# poly_vals = np.polyval(poly_coefficients,age2)
# poly_vals = 0.5*(np.abs(poly_vals)+poly_vals)
fitfunc = lambda pars, x: np.abs(pars[0])*(1-x/max(120,pars[1]))-np.abs(pars[2])*np.exp(-x/np.abs(pars[3]))+np.abs(pars[4])*(np.sin(np.pi*x/max(50,pars[5])))
errfunc = lambda pars, x,y: fitfunc(pars,x)-y
p0 = [700,120,700,10,100,100]
p1, success = optimize.leastsq(errfunc,p0[:],
args = (age,power))
expo_vals = fitfunc(p1, age2)
expo_vals = 0.5*(np.abs(expo_vals)+expo_vals)
source = ColumnDataSource(
data = dict(
age = age,
power = power,
age2 = age2,
poly_vals = poly_vals,
expo_vals = expo_vals,
season = season,
name=name,
)
@@ -1097,9 +1112,10 @@ def interactive_agegroup_plot(df):
plot = Figure(tools=TOOLS,plot_width=900)
plot.circle('age','power',source=source,fill_color='red',size=15,
legend='World Record')
plot.line(age2,poly_vals)
plot.line(age2,expo_vals)
plot.xaxis.axis_label = "Age"
plot.yaxis.axis_label = "Concept2 2k power"
plot.yaxis.axis_label = "Concept2 power"
hover = plot.select(dict(type=HoverTool))