Private
Public Access
1
0

added stayer score

This commit is contained in:
Sander Roosendaal
2017-12-20 17:01:47 +01:00
parent afdee332da
commit 136440f8fb
3 changed files with 665 additions and 3 deletions

View File

@@ -45,10 +45,11 @@ from django.utils import timezone
activate(settings.TIME_ZONE)
thetimezone = get_current_timezone()
from scipy.stats import linregress
from scipy.stats import linregress,percentileofscore
from scipy import optimize
from scipy.signal import savgol_filter
import stravastuff
from rowers.dataprep import rdata
@@ -1478,6 +1479,26 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
p1 = [p0[0]/factor,p0[1]/factor,p0[2],p0[3]]
# Get stayer score
if success == 1:
power4min = fitfunc(p1,240.)
power1h = fitfunc(p1,3600.)
power10sec = fitfunc(p1,10.)
r10sec4min = 100.*power10sec/power4min
r1h4min = 100.*power1h/power4min
print r1h4min,'1h/4min'
print r10sec4min,'10sec/4min'
combined = r1h4min-0.2*(r10sec4min-100)
dataset = pd.read_csv('static/stats/combined_set.csv')
stayerscore = int(percentileofscore(dataset['combined'],combined))
else:
stayerscore = None
fitt = pd.Series(10**(4*np.arange(100)/100.))
fitpower = fitfunc(p1,fitt)
@@ -1550,7 +1571,15 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
plot.xaxis.axis_label = "Duration (seconds)"
plot.yaxis.axis_label = "Power (W)"
if stayerscore is not None:
plot.add_layout(
Label(x=100,y=100,x_units='screen',y_units='screen',
text='Stayer Score '+str(stayerscore)+'%',
background_fill_alpha=0.7,
background_fill_color='white',
text_color='black')
)
cpdata = dataprep.fetchcperg(rower, theworkouts)
if cpdata.empty:

View File

@@ -167,7 +167,7 @@ urlpatterns = [
url(r'^ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
url(r'^ote-bests/$',views.rankings_view),
url(r'^(?P<theuser>\d+)/ote-bests/$',views.rankings_view),
url(r'^(?P<theuser>\d+)/ote-bests2/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view),
url(r'^(?P<theuser>\d+)/ote-bests2/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view2),
url(r'^(?P<theuser>\d+)/ote-bests2/(?P<deltadays>\d+)$',views.rankings_view2),
url(r'^ote-bests2/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view2),
url(r'^ote-bests2/(?P<deltadays>\d+)$',views.rankings_view2),