retiring agegroupcpchart
This commit is contained in:
@@ -991,284 +991,6 @@ def leaflet_chart_compare(course, workoutids, labeldict={}, startenddict={}):
|
|||||||
|
|
||||||
return script, div
|
return script, div
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def interactive_agegroupcpchart(age, normalized=False):
|
|
||||||
durations = [1, 4, 30, 60]
|
|
||||||
distances = [100, 500, 1000, 2000, 5000, 6000, 10000, 21097, 42195]
|
|
||||||
|
|
||||||
fhduration = []
|
|
||||||
fhpower = []
|
|
||||||
|
|
||||||
for distance in distances:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='female',
|
|
||||||
distance=distance,
|
|
||||||
weightcategory='hwt'
|
|
||||||
)
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
try: # pragma: no cover
|
|
||||||
duration = distance/velo
|
|
||||||
fhduration.append(duration)
|
|
||||||
fhpower.append(worldclasspower)
|
|
||||||
except ZeroDivisionError:
|
|
||||||
pass
|
|
||||||
for duration in durations:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='female',
|
|
||||||
duration=duration,
|
|
||||||
weightcategory='hwt'
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
distance = int(60*duration*velo)
|
|
||||||
fhduration.append(60.*duration)
|
|
||||||
fhpower.append(worldclasspower)
|
|
||||||
except ValueError: # pragma: no cover
|
|
||||||
pass
|
|
||||||
|
|
||||||
flduration = []
|
|
||||||
flpower = []
|
|
||||||
|
|
||||||
for distance in distances:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='female',
|
|
||||||
distance=distance,
|
|
||||||
weightcategory='lwt'
|
|
||||||
)
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
try: # pragma: no cover
|
|
||||||
duration = distance/velo
|
|
||||||
flduration.append(duration)
|
|
||||||
flpower.append(worldclasspower)
|
|
||||||
except ZeroDivisionError:
|
|
||||||
pass
|
|
||||||
for duration in durations:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='female',
|
|
||||||
duration=duration,
|
|
||||||
weightcategory='lwt'
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
distance = int(60*duration*velo)
|
|
||||||
flduration.append(60.*duration)
|
|
||||||
flpower.append(worldclasspower)
|
|
||||||
except ValueError: # pragma: no cover
|
|
||||||
pass
|
|
||||||
|
|
||||||
mlduration = []
|
|
||||||
mlpower = []
|
|
||||||
|
|
||||||
for distance in distances:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='male',
|
|
||||||
distance=distance,
|
|
||||||
weightcategory='lwt'
|
|
||||||
)
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
try: # pragma: no cover
|
|
||||||
duration = distance/velo
|
|
||||||
mlduration.append(duration)
|
|
||||||
mlpower.append(worldclasspower)
|
|
||||||
except ZeroDivisionError:
|
|
||||||
mlduration.append(duration)
|
|
||||||
mlpower.append(np.nan)
|
|
||||||
for duration in durations:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='male',
|
|
||||||
duration=duration,
|
|
||||||
weightcategory='lwt'
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
distance = int(60*duration*velo)
|
|
||||||
mlduration.append(60.*duration)
|
|
||||||
mlpower.append(worldclasspower)
|
|
||||||
except ValueError: # pragma: no cover
|
|
||||||
mlduration.append(60.*duration)
|
|
||||||
mlpower.append(np.nan)
|
|
||||||
|
|
||||||
mhduration = []
|
|
||||||
mhpower = []
|
|
||||||
|
|
||||||
for distance in distances:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='male',
|
|
||||||
distance=distance,
|
|
||||||
weightcategory='hwt'
|
|
||||||
)
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
try: # pragma: no cover
|
|
||||||
duration = distance/velo
|
|
||||||
mhduration.append(duration)
|
|
||||||
mhpower.append(worldclasspower)
|
|
||||||
except ZeroDivisionError:
|
|
||||||
mhduration.append(duration)
|
|
||||||
mhpower.append(np.nan)
|
|
||||||
for duration in durations:
|
|
||||||
worldclasspower = c2stuff.getagegrouprecord(
|
|
||||||
age,
|
|
||||||
sex='male',
|
|
||||||
duration=duration,
|
|
||||||
weightcategory='hwt'
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
velo = (worldclasspower/2.8)**(1./3.)
|
|
||||||
distance = int(60*duration*velo)
|
|
||||||
mhduration.append(60.*duration)
|
|
||||||
mhpower.append(worldclasspower)
|
|
||||||
except ValueError: # pragma: no cover
|
|
||||||
mhduration.append(60.*duration)
|
|
||||||
mhpower.append(np.nan)
|
|
||||||
|
|
||||||
def fitfunc(pars, x):
|
|
||||||
return pars[0] / (1+(x/pars[2])) + pars[1]/(1+(x/pars[3]))
|
|
||||||
|
|
||||||
def errfunc(pars, x, y):
|
|
||||||
return fitfunc(pars, x)-y
|
|
||||||
|
|
||||||
# p0 = [500,350,10,8000]
|
|
||||||
|
|
||||||
# fitting WC data to three parameter CP model
|
|
||||||
if len(fhduration) >= 4:
|
|
||||||
p1fh, success = optimize.leastsq(errfunc, p0[:],
|
|
||||||
args=(fhduration, fhpower))
|
|
||||||
else: # pragma: no cover
|
|
||||||
p1fh = None
|
|
||||||
|
|
||||||
# fitting WC data to three parameter CP model
|
|
||||||
if len(flduration) >= 4:
|
|
||||||
p1fl, success = optimize.leastsq(errfunc, p0[:],
|
|
||||||
args=(flduration, flpower))
|
|
||||||
else: # pragma: no cover
|
|
||||||
p1fl = None
|
|
||||||
|
|
||||||
# fitting WC data to three parameter CP model
|
|
||||||
if len(mlduration) >= 4:
|
|
||||||
p1ml, success = optimize.leastsq(errfunc, p0[:],
|
|
||||||
args=(mlduration, mlpower))
|
|
||||||
else: # pragma: no cover
|
|
||||||
p1ml = None
|
|
||||||
|
|
||||||
if len(mhduration) >= 4:
|
|
||||||
p1mh, success = optimize.leastsq(errfunc, p0[:],
|
|
||||||
args=(mhduration, mhpower))
|
|
||||||
else: # pragma: no cover
|
|
||||||
p1mh = None
|
|
||||||
|
|
||||||
fitt = pd.Series(10**(4*np.arange(100)/100.))
|
|
||||||
|
|
||||||
fitpowerfh = fitfunc(p1fh, fitt)
|
|
||||||
fitpowerfl = fitfunc(p1fl, fitt)
|
|
||||||
fitpowerml = fitfunc(p1ml, fitt)
|
|
||||||
fitpowermh = fitfunc(p1mh, fitt)
|
|
||||||
|
|
||||||
if normalized:
|
|
||||||
facfh = fitfunc(p1fh, 60)
|
|
||||||
facfl = fitfunc(p1fl, 60)
|
|
||||||
facml = fitfunc(p1ml, 60)
|
|
||||||
facmh = fitfunc(p1mh, 60)
|
|
||||||
fitpowerfh /= facfh
|
|
||||||
fitpowerfl /= facfl
|
|
||||||
fitpowermh /= facmh
|
|
||||||
fitpowerml /= facml
|
|
||||||
fhpower /= facfh
|
|
||||||
flpower /= facfl
|
|
||||||
mlpower /= facml
|
|
||||||
mhpower /= facmh
|
|
||||||
|
|
||||||
sourcemh = ColumnDataSource(
|
|
||||||
data=dict(
|
|
||||||
mhduration=mhduration,
|
|
||||||
mhpower=mhpower,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
sourcefl = ColumnDataSource(
|
|
||||||
data=dict(
|
|
||||||
flduration=flduration,
|
|
||||||
flpower=flpower,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
sourcefh = ColumnDataSource(
|
|
||||||
data=dict(
|
|
||||||
fhduration=fhduration,
|
|
||||||
fhpower=fhpower,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
sourceml = ColumnDataSource(
|
|
||||||
data=dict(
|
|
||||||
mlduration=mlduration,
|
|
||||||
mlpower=mlpower,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
sourcefit = ColumnDataSource(
|
|
||||||
data=dict(
|
|
||||||
duration=fitt,
|
|
||||||
fitpowerfh=fitpowerfh,
|
|
||||||
fitpowerfl=fitpowerfl,
|
|
||||||
fitpowerml=fitpowerml,
|
|
||||||
fitpowermh=fitpowermh,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
x_axis_type = 'log'
|
|
||||||
|
|
||||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
|
||||||
|
|
||||||
plot = figure(width=900, x_axis_type=x_axis_type,
|
|
||||||
tools=TOOLS)
|
|
||||||
#plot.sizing_mode = 'stretch_both'
|
|
||||||
|
|
||||||
plot.line('duration', 'fitpowerfh', source=sourcefit,
|
|
||||||
legend_label='Female HW', color='blue')
|
|
||||||
plot.line('duration', 'fitpowerfl', source=sourcefit,
|
|
||||||
legend_label='Female LW', color='red')
|
|
||||||
|
|
||||||
plot.line('duration', 'fitpowerml', source=sourcefit,
|
|
||||||
legend_label='Male LW', color='green')
|
|
||||||
|
|
||||||
plot.line('duration', 'fitpowermh', source=sourcefit,
|
|
||||||
legend_label='Male HW', color='orange')
|
|
||||||
|
|
||||||
plot.circle('flduration', 'flpower', source=sourcefl,
|
|
||||||
fill_color='red', size=15)
|
|
||||||
|
|
||||||
plot.circle('fhduration', 'fhpower', source=sourcefh,
|
|
||||||
fill_color='blue', size=15)
|
|
||||||
|
|
||||||
plot.circle('mlduration', 'mlpower', source=sourceml,
|
|
||||||
fill_color='green', size=15)
|
|
||||||
|
|
||||||
plot.circle('mhduration', 'mhpower', source=sourcemh,
|
|
||||||
fill_color='orange', size=15)
|
|
||||||
|
|
||||||
plot.title.text = 'age '+str(age)
|
|
||||||
|
|
||||||
plot.xaxis.axis_label = "Duration (seconds)"
|
|
||||||
if normalized:
|
|
||||||
plot.yaxis.axis_label = "Power (normalized)"
|
|
||||||
else:
|
|
||||||
plot.yaxis.axis_label = "Power (W)"
|
|
||||||
|
|
||||||
script, div = components(plot)
|
|
||||||
|
|
||||||
return script, div
|
|
||||||
|
|
||||||
|
|
||||||
def interactive_otwcpchart(powerdf, promember=0, rowername="", r=None,
|
def interactive_otwcpchart(powerdf, promember=0, rowername="", r=None,
|
||||||
cpfit='data',
|
cpfit='data',
|
||||||
title='', type='water',
|
title='', type='water',
|
||||||
|
|||||||
@@ -280,14 +280,6 @@ urlpatterns = [
|
|||||||
views.failed_job_view, name='failed_job_view'),
|
views.failed_job_view, name='failed_job_view'),
|
||||||
re_path(r'^update_empower/$', views.rower_update_empower_view,
|
re_path(r'^update_empower/$', views.rower_update_empower_view,
|
||||||
name='rower_update_empower_view'),
|
name='rower_update_empower_view'),
|
||||||
re_path(r'^agegroupcp/(?P<age>\d+)/$',
|
|
||||||
views.agegroupcpview, name='agegroupcpview'),
|
|
||||||
re_path(r'^agegroupcp/(?P<age>\d+)/user/(?P<userid>\d+)/$',
|
|
||||||
views.agegroupcpview, name='agegroupcpview'),
|
|
||||||
re_path(r'^agegroupcp/(?P<age>\d+)/(?P<normalize>\d+)/$',
|
|
||||||
views.agegroupcpview, name='agegroupcpview'),
|
|
||||||
re_path(r'^agegroupcp/(?P<age>\d+)/(?P<normalize>\d+)/user/(?P<userid>\d+)/$',
|
|
||||||
views.agegroupcpview, name='agegroupcpview'),
|
|
||||||
re_path(r'^ajax_agegroup/(?P<age>\d+)/(?P<weightcategory>\w+.*)/(?P<sex>\w+.*)/(?P<userid>\d+)/$',
|
re_path(r'^ajax_agegroup/(?P<age>\d+)/(?P<weightcategory>\w+.*)/(?P<sex>\w+.*)/(?P<userid>\d+)/$',
|
||||||
views.ajax_agegrouprecords, name='ajax_agegrouprecords'),
|
views.ajax_agegrouprecords, name='ajax_agegrouprecords'),
|
||||||
re_path(r'^agegrouprecords/(?P<sex>\w+.*)/(?P<weightcategory>\w+.*)/(?P<distance>\d+)m/$',
|
re_path(r'^agegrouprecords/(?P<sex>\w+.*)/(?P<weightcategory>\w+.*)/(?P<distance>\d+)m/$',
|
||||||
|
|||||||
Reference in New Issue
Block a user