got to point where chart is generated (L2936)
This commit is contained in:
@@ -135,6 +135,12 @@ urlpatterns = [
|
|||||||
url(r'^ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
url(r'^ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
||||||
url(r'^ote-bests/$',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-bests/$',views.rankings_view),
|
||||||
|
url(r'^(?P<theuser>\d+)/otw-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.otwrankings_view),
|
||||||
|
url(r'^(?P<theuser>\d+)/otw-bests/(?P<deltadays>\d+)$',views.otwrankings_view),
|
||||||
|
url(r'^otw-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.otwrankings_view),
|
||||||
|
url(r'^otw-bests/(?P<deltadays>\d+)$',views.otwrankings_view),
|
||||||
|
url(r'^otw-bests/$',views.otwrankings_view),
|
||||||
|
url(r'^(?P<theuser>\d+)/otw-bests/$',views.otwrankings_view),
|
||||||
url(r'^(?P<theuser>\d+)/flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.cum_flex),
|
url(r'^(?P<theuser>\d+)/flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.cum_flex),
|
||||||
url(r'^flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.cum_flex),
|
url(r'^flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.cum_flex),
|
||||||
url(r'^flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)$',views.cum_flex),
|
url(r'^flexall/(?P<xparam>\w+.*)/(?P<yparam1>\w+.*)/(?P<yparam2>\w+.*)$',views.cum_flex),
|
||||||
|
|||||||
117
rowers/views.py
117
rowers/views.py
@@ -2856,13 +2856,6 @@ def otwrankings_view(request,theuser=0,
|
|||||||
thedistances = []
|
thedistances = []
|
||||||
theworkouts = []
|
theworkouts = []
|
||||||
thesecs = []
|
thesecs = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rankingdistances.sort()
|
|
||||||
rankingdurations.sort()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
theworkouts = Workout.objects.filter(user=r,rankingpiece=True,
|
theworkouts = Workout.objects.filter(user=r,rankingpiece=True,
|
||||||
workouttype='water',
|
workouttype='water',
|
||||||
@@ -2878,10 +2871,10 @@ def otwrankings_view(request,theuser=0,
|
|||||||
thesecs = []
|
thesecs = []
|
||||||
|
|
||||||
for w in theworkouts:
|
for w in theworkouts:
|
||||||
timesecs = 3600*workouts[0].duration.hour
|
timesecs = 3600*w.duration.hour
|
||||||
timesecs += 60*workouts[0].duration.minute
|
timesecs += 60*w.duration.minute
|
||||||
timesecs += workouts[0].duration.second
|
timesecs += w.duration.second
|
||||||
timesecs += 1.e-5*workouts[0].duration.microsecond
|
timesecs += 1.e-5*w.duration.microsecond
|
||||||
|
|
||||||
thesecs.append(timesecs)
|
thesecs.append(timesecs)
|
||||||
|
|
||||||
@@ -2890,7 +2883,10 @@ def otwrankings_view(request,theuser=0,
|
|||||||
|
|
||||||
maxlog10 = np.log10(maxt)
|
maxlog10 = np.log10(maxt)
|
||||||
logarr = np.arange(100)*maxlog10/100.
|
logarr = np.arange(100)*maxlog10/100.
|
||||||
logarr = 10.**(logarr)
|
logarr = [int(10.**(la)) for la in logarr]
|
||||||
|
logarr = pd.Series(logarr)
|
||||||
|
logarr.drop_duplicates(keep='first',inplace=True)
|
||||||
|
logarr = logarr.values
|
||||||
|
|
||||||
delta = []
|
delta = []
|
||||||
cpvalue = []
|
cpvalue = []
|
||||||
@@ -2899,25 +2895,34 @@ def otwrankings_view(request,theuser=0,
|
|||||||
for id,group in dfgrouped:
|
for id,group in dfgrouped:
|
||||||
tt = group['time']
|
tt = group['time']
|
||||||
ww = group['power']
|
ww = group['power']
|
||||||
length = len(ww)
|
if not np.isnan(ww.mean()):
|
||||||
dt = []
|
length = len(ww)
|
||||||
cpw = []
|
dt = []
|
||||||
for i in range(length):
|
cpw = []
|
||||||
w_roll = ww.rolling(i)
|
for i in range(length-2):
|
||||||
# now goes with # data points - should be fixed seconds
|
w_roll = ww.rolling(i+2,min_periods=2).mean()
|
||||||
t_0 = tt.ix[w_roll.idxmax(axis=1)]
|
# now goes with # data points - should be fixed seconds
|
||||||
t_1 = tt.ix[w_roll.idxmax(axis=1)-i]
|
indexmax = w_roll.idxmax(axis=1)
|
||||||
deltat = t_1-t_0
|
try:
|
||||||
wmax = w_roll.ix[w_roll.idxmax(axis=1)]
|
t_0 = tt.ix[indexmax]
|
||||||
dt.append(deltat)
|
t_1 = tt.ix[indexmax-i-2]
|
||||||
cpw.append(wmax)
|
deltat = 1.0e-3*(t_0-t_1)
|
||||||
|
wmax = w_roll.ix[indexmax]
|
||||||
|
dt.append(deltat)
|
||||||
|
cpw.append(wmax)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
cpvalues = griddata(dt,cpw,logarr,method='linear',fill_value=0)
|
dt = pd.Series(dt)
|
||||||
|
cpw = pd.Series(cpw)
|
||||||
|
cpvalues = griddata(dt.values,
|
||||||
|
cpw.values,
|
||||||
|
logarr,method='linear',fill_value=0)
|
||||||
|
|
||||||
for cpv in cpvalues:
|
for cpv in cpvalues:
|
||||||
cpvalue.append(cpv)
|
cpvalue.append(cpv)
|
||||||
for d in logarr:
|
for d in logarr:
|
||||||
delta.append(d)
|
delta.append(d)
|
||||||
|
|
||||||
dt = pd.Series(delta,name='Delta')
|
dt = pd.Series(delta,name='Delta')
|
||||||
cpvalue = pd.Series(cpvalue,name='CP')
|
cpvalue = pd.Series(cpvalue,name='CP')
|
||||||
@@ -2928,9 +2933,9 @@ def otwrankings_view(request,theuser=0,
|
|||||||
'CP':cpvalue,
|
'CP':cpvalue,
|
||||||
})
|
})
|
||||||
|
|
||||||
powerdf.sort_value(['Delta','CP'],ascending=[1,0]
|
powerdf.sort_values(['Delta','CP'],ascending=[1,0])
|
||||||
powerdf.drop_duplicates(subset='Delta',keep='first')
|
powerdf.drop_duplicates(subset='Delta',keep='first')
|
||||||
|
|
||||||
|
|
||||||
# create interactive plot
|
# create interactive plot
|
||||||
if len(thedistances) !=0 :
|
if len(thedistances) !=0 :
|
||||||
@@ -2966,61 +2971,11 @@ def otwrankings_view(request,theuser=0,
|
|||||||
else:
|
else:
|
||||||
form = PredictedPieceForm()
|
form = PredictedPieceForm()
|
||||||
|
|
||||||
rankingdistances.sort()
|
|
||||||
rankingdurations.sort()
|
|
||||||
|
|
||||||
|
|
||||||
predictions = []
|
predictions = []
|
||||||
cpredictions = []
|
cpredictions = []
|
||||||
|
|
||||||
|
|
||||||
for rankingdistance in rankingdistances:
|
|
||||||
# Paul's model
|
|
||||||
p = paulslope*np.log10(rankingdistance)+paulintercept
|
|
||||||
velo = 500./p
|
|
||||||
t = rankingdistance/velo
|
|
||||||
pwr = 2.8*(velo**3)
|
|
||||||
a = {'distance':rankingdistance,
|
|
||||||
'duration':timedeltaconv(t),
|
|
||||||
'pace':timedeltaconv(p),
|
|
||||||
'power':int(pwr)}
|
|
||||||
predictions.append(a)
|
|
||||||
|
|
||||||
# CP model -
|
|
||||||
pwr2 = p1[0]/(1+t/p1[2])
|
|
||||||
pwr2 += p1[1]/(1+t/p1[3])
|
|
||||||
|
|
||||||
if pwr2 <= 0:
|
|
||||||
pwr2 = 50.
|
|
||||||
|
|
||||||
velo2 = (pwr2/2.8)**(1./3.)
|
|
||||||
|
|
||||||
if np.isnan(velo2) or velo2 <= 0:
|
|
||||||
velo2 = 1.0
|
|
||||||
|
|
||||||
t2 = rankingdistance/velo2
|
|
||||||
|
|
||||||
pwr3 = p1[0]/(1+t2/p1[2])
|
|
||||||
pwr3 += p1[1]/(1+t2/p1[3])
|
|
||||||
|
|
||||||
if pwr3 <= 0:
|
|
||||||
pwr3 = 50.
|
|
||||||
|
|
||||||
velo3 = (pwr3/2.8)**(1./3.)
|
|
||||||
if np.isnan(velo3) or velo3 <= 0:
|
|
||||||
velo3 = 1.0
|
|
||||||
|
|
||||||
t3 = rankingdistance/velo3
|
|
||||||
p3 = 500./velo3
|
|
||||||
|
|
||||||
a = {'distance':rankingdistance,
|
|
||||||
'duration':timedeltaconv(t3),
|
|
||||||
'pace':timedeltaconv(p3),
|
|
||||||
'power':int(pwr3)}
|
|
||||||
cpredictions.append(a)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for rankingduration in rankingdurations:
|
for rankingduration in rankingdurations:
|
||||||
t = 3600.*rankingduration.hour
|
t = 3600.*rankingduration.hour
|
||||||
|
|||||||
Reference in New Issue
Block a user