Merge branch 'release/v3.10'
This commit is contained in:
@@ -645,10 +645,14 @@ def interactive_otwcpchart(powerdf,promember=0):
|
||||
# message = "CP model fit didn't give correct results"
|
||||
|
||||
|
||||
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||
ftime = niceformat(deltas)
|
||||
|
||||
sourcecomplex = ColumnDataSource(
|
||||
data = dict(
|
||||
power = fitpower,
|
||||
duration = fitt
|
||||
CP = fitpower,
|
||||
duration = fitt,
|
||||
ftime = ftime
|
||||
)
|
||||
)
|
||||
|
||||
@@ -689,7 +693,7 @@ def interactive_otwcpchart(powerdf,promember=0):
|
||||
|
||||
hover.mode = 'mouse'
|
||||
|
||||
plot.line('duration','power',source=sourcecomplex,legend="CP Model",
|
||||
plot.line('duration','CP',source=sourcecomplex,legend="CP Model",
|
||||
color='green')
|
||||
|
||||
script, div = components(plot)
|
||||
|
||||
@@ -2897,26 +2897,32 @@ def otwrankings_view(request,theuser=0,
|
||||
|
||||
thesecs.append(timesecs)
|
||||
|
||||
|
||||
if len(thesecs) != 0:
|
||||
maxt = pd.Series(thesecs).max()
|
||||
maxt = 2*pd.Series(thesecs).max()
|
||||
else:
|
||||
maxt = 1000.
|
||||
|
||||
|
||||
maxlog10 = np.log10(maxt)
|
||||
logarr = np.arange(100)*maxlog10/100.
|
||||
logarr = [int(10.**(la)) for la in logarr]
|
||||
logarr = pd.Series(logarr)
|
||||
logarr.drop_duplicates(keep='first',inplace=True)
|
||||
|
||||
logarr = logarr.values
|
||||
|
||||
|
||||
|
||||
delta = []
|
||||
cpvalue = []
|
||||
avgpower = {}
|
||||
|
||||
dfgrouped = df.groupby(['workoutid'])
|
||||
for id,group in dfgrouped:
|
||||
tt = group['time']
|
||||
ww = group['power']
|
||||
tt = group['time'].copy()
|
||||
ww = group['power'].copy()
|
||||
|
||||
try:
|
||||
avgpower[id] = int(ww.mean())
|
||||
except ValueError:
|
||||
@@ -2926,40 +2932,44 @@ def otwrankings_view(request,theuser=0,
|
||||
dt = []
|
||||
cpw = []
|
||||
for i in range(length-2):
|
||||
w_roll = ww.rolling(i+2,min_periods=2).mean()
|
||||
# now goes with # data points - should be fixed seconds
|
||||
indexmax = w_roll.idxmax(axis=1)
|
||||
try:
|
||||
t_0 = tt.ix[indexmax]
|
||||
t_1 = tt.ix[indexmax-i-2]
|
||||
deltat = 1.0e-3*(t_0-t_1)
|
||||
wmax = w_roll.ix[indexmax]
|
||||
dt.append(deltat)
|
||||
cpw.append(wmax)
|
||||
except KeyError:
|
||||
pass
|
||||
w_roll = ww.rolling(i+2).mean().dropna()
|
||||
if len(w_roll):
|
||||
# now goes with # data points - should be fixed seconds
|
||||
indexmax = w_roll.idxmax(axis=1)
|
||||
try:
|
||||
t_0 = tt.ix[indexmax]
|
||||
t_1 = tt.ix[indexmax-i-2]
|
||||
deltat = 1.0e-3*(t_0-t_1)
|
||||
wmax = w_roll.ix[indexmax]
|
||||
if not np.isnan(deltat) and not np.isnan(wmax):
|
||||
dt.append(deltat)
|
||||
cpw.append(wmax)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
dt = pd.Series(dt)
|
||||
cpw = pd.Series(cpw)
|
||||
|
||||
cpvalues = griddata(dt.values,
|
||||
cpw.values,
|
||||
logarr,method='linear',fill_value=0)
|
||||
logarr,method='linear',
|
||||
rescale=True)
|
||||
|
||||
for cpv in cpvalues:
|
||||
cpvalue.append(cpv)
|
||||
for d in logarr:
|
||||
delta.append(d)
|
||||
|
||||
print avgpower
|
||||
dt = pd.Series(delta,name='Delta')
|
||||
delta = pd.Series(delta,name='Delta')
|
||||
cpvalue = pd.Series(cpvalue,name='CP')
|
||||
|
||||
|
||||
powerdf = pd.DataFrame({
|
||||
'Delta':delta,
|
||||
'CP':cpvalue,
|
||||
})
|
||||
|
||||
|
||||
powerdf = powerdf[powerdf['CP']>0]
|
||||
powerdf.dropna(axis=0,inplace=True)
|
||||
powerdf.sort_values(['Delta','CP'],ascending=[1,0],inplace=True)
|
||||
|
||||
Reference in New Issue
Block a user