otwpower untested, unfinished
This commit is contained in:
@@ -138,6 +138,8 @@ from scipy.special import lambertw
|
|||||||
|
|
||||||
from dataprep import timedeltaconv
|
from dataprep import timedeltaconv
|
||||||
|
|
||||||
|
from scipy.interpolate import griddata
|
||||||
|
|
||||||
LOCALTIMEZONE = tz('Etc/UTC')
|
LOCALTIMEZONE = tz('Etc/UTC')
|
||||||
USER_LANGUAGE = 'en-US'
|
USER_LANGUAGE = 'en-US'
|
||||||
|
|
||||||
@@ -2873,15 +2875,10 @@ def otwrankings_view(request,theuser=0,
|
|||||||
columns = ['power','workoutid','time']
|
columns = ['power','workoutid','time']
|
||||||
df = dataprep.getsmallrowdata_db(columns,ids=theids)
|
df = dataprep.getsmallrowdata_db(columns,ids=theids)
|
||||||
|
|
||||||
dfgrouped = df.groupby(['workoutid'])
|
thesecs = []
|
||||||
for id in theids:
|
|
||||||
tt = df['time']
|
|
||||||
|
|
||||||
for w in theworkouts:
|
for w in theworkouts:
|
||||||
|
timesecs = 3600*workouts[0].duration.hour
|
||||||
thedistances.append(w.distance)
|
|
||||||
|
|
||||||
timesecs = 3600*workouts[0].duration.hour
|
|
||||||
timesecs += 60*workouts[0].duration.minute
|
timesecs += 60*workouts[0].duration.minute
|
||||||
timesecs += workouts[0].duration.second
|
timesecs += workouts[0].duration.second
|
||||||
timesecs += 1.e-5*workouts[0].duration.microsecond
|
timesecs += 1.e-5*workouts[0].duration.microsecond
|
||||||
@@ -2889,11 +2886,51 @@ def otwrankings_view(request,theuser=0,
|
|||||||
thesecs.append(timesecs)
|
thesecs.append(timesecs)
|
||||||
|
|
||||||
|
|
||||||
|
maxt = pd.Series(thesecs).max()
|
||||||
|
|
||||||
thesecs = np.array(thesecs)
|
maxlog10 = np.log10(maxt)
|
||||||
|
logarr = np.arange(100)*maxlog10/100.
|
||||||
|
logarr = 10.**(logarr)
|
||||||
|
|
||||||
theavpower = 2.8*(thevelos**3)
|
delta = []
|
||||||
|
cpvalue = []
|
||||||
|
|
||||||
|
dfgrouped = df.groupby(['workoutid'])
|
||||||
|
for id,group in dfgrouped:
|
||||||
|
tt = group['time']
|
||||||
|
ww = group['power']
|
||||||
|
length = len(ww)
|
||||||
|
dt = []
|
||||||
|
cpw = []
|
||||||
|
for i in range(length):
|
||||||
|
w_roll = ww.rolling(i)
|
||||||
|
# now goes with # data points - should be fixed seconds
|
||||||
|
t_0 = tt.ix[w_roll.idxmax(axis=1)]
|
||||||
|
t_1 = tt.ix[w_roll.idxmax(axis=1)-i]
|
||||||
|
deltat = t_1-t_0
|
||||||
|
wmax = w_roll.ix[w_roll.idxmax(axis=1)]
|
||||||
|
dt.append(deltat)
|
||||||
|
cpw.append(wmax)
|
||||||
|
|
||||||
|
cpvalues = griddata(dt,cpw,logarr,method='linear',fill_value=0)
|
||||||
|
|
||||||
|
for cpv in cpvalues:
|
||||||
|
cpvalue.append(cpv)
|
||||||
|
for d in logarr:
|
||||||
|
delta.append(d)
|
||||||
|
|
||||||
|
dt = pd.Series(delta,name='Delta')
|
||||||
|
cpvalue = pd.Series(cpvalue,name='CP')
|
||||||
|
|
||||||
|
|
||||||
|
powerdf = pd.DataFrame({
|
||||||
|
'Delta':delta,
|
||||||
|
'CP':cpvalue,
|
||||||
|
})
|
||||||
|
|
||||||
|
powerdf.sort_value(['Delta','CP'],ascending=[1,0]
|
||||||
|
powerdf.drop_duplicates(subset='Delta',keep='first')
|
||||||
|
|
||||||
|
|
||||||
# create interactive plot
|
# create interactive plot
|
||||||
if len(thedistances) !=0 :
|
if len(thedistances) !=0 :
|
||||||
|
|||||||
Reference in New Issue
Block a user