updated OTW CP plot
This commit is contained in:
@@ -645,10 +645,14 @@ def interactive_otwcpchart(powerdf,promember=0):
|
|||||||
# message = "CP model fit didn't give correct results"
|
# message = "CP model fit didn't give correct results"
|
||||||
|
|
||||||
|
|
||||||
|
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||||
|
ftime = niceformat(deltas)
|
||||||
|
|
||||||
sourcecomplex = ColumnDataSource(
|
sourcecomplex = ColumnDataSource(
|
||||||
data = dict(
|
data = dict(
|
||||||
power = fitpower,
|
CP = fitpower,
|
||||||
duration = fitt
|
duration = fitt,
|
||||||
|
ftime = ftime
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -671,7 +675,7 @@ def interactive_otwcpchart(powerdf,promember=0):
|
|||||||
y_range_name = "watermark",
|
y_range_name = "watermark",
|
||||||
)
|
)
|
||||||
|
|
||||||
plot.line('Delta','CP',source=source,color='red',line_width=5,
|
plot.circle('Delta','CP',source=source,fill_color='red',size=15,
|
||||||
legend='Power Data')
|
legend='Power Data')
|
||||||
plot.xaxis.axis_label = "Duration (seconds)"
|
plot.xaxis.axis_label = "Duration (seconds)"
|
||||||
plot.yaxis.axis_label = "Power (W)"
|
plot.yaxis.axis_label = "Power (W)"
|
||||||
@@ -689,7 +693,7 @@ def interactive_otwcpchart(powerdf,promember=0):
|
|||||||
|
|
||||||
hover.mode = 'mouse'
|
hover.mode = 'mouse'
|
||||||
|
|
||||||
plot.line('duration','power',source=sourcecomplex,legend="CP Model",
|
plot.line('duration','CP',source=sourcecomplex,legend="CP Model",
|
||||||
color='green')
|
color='green')
|
||||||
|
|
||||||
script, div = components(plot)
|
script, div = components(plot)
|
||||||
|
|||||||
@@ -2903,9 +2903,9 @@ def otwrankings_view(request,theuser=0,
|
|||||||
else:
|
else:
|
||||||
maxt = 1000.
|
maxt = 1000.
|
||||||
|
|
||||||
|
|
||||||
maxlog10 = np.log10(maxt)
|
maxlog10 = np.log10(maxt)
|
||||||
logarr = np.arange(500)*maxlog10/500.
|
logarr = np.arange(100)*maxlog10/100.
|
||||||
logarr = [int(10.**(la)) for la in logarr]
|
logarr = [int(10.**(la)) for la in logarr]
|
||||||
logarr = pd.Series(logarr)
|
logarr = pd.Series(logarr)
|
||||||
logarr.drop_duplicates(keep='first',inplace=True)
|
logarr.drop_duplicates(keep='first',inplace=True)
|
||||||
@@ -2920,8 +2920,9 @@ def otwrankings_view(request,theuser=0,
|
|||||||
|
|
||||||
dfgrouped = df.groupby(['workoutid'])
|
dfgrouped = df.groupby(['workoutid'])
|
||||||
for id,group in dfgrouped:
|
for id,group in dfgrouped:
|
||||||
tt = group['time']
|
tt = group['time'].copy()
|
||||||
ww = group['power']
|
ww = group['power'].copy()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
avgpower[id] = int(ww.mean())
|
avgpower[id] = int(ww.mean())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@@ -2931,19 +2932,20 @@ def otwrankings_view(request,theuser=0,
|
|||||||
dt = []
|
dt = []
|
||||||
cpw = []
|
cpw = []
|
||||||
for i in range(length-2):
|
for i in range(length-2):
|
||||||
w_roll = ww.rolling(i+2,min_periods=2).mean()
|
w_roll = ww.rolling(i+2).mean().dropna()
|
||||||
# now goes with # data points - should be fixed seconds
|
if len(w_roll):
|
||||||
indexmax = w_roll.idxmax(axis=1)
|
# now goes with # data points - should be fixed seconds
|
||||||
try:
|
indexmax = w_roll.idxmax(axis=1)
|
||||||
t_0 = tt.ix[indexmax]
|
try:
|
||||||
t_1 = tt.ix[indexmax-i-2]
|
t_0 = tt.ix[indexmax]
|
||||||
deltat = 1.0e-3*(t_0-t_1)
|
t_1 = tt.ix[indexmax-i-2]
|
||||||
wmax = w_roll.ix[indexmax]
|
deltat = 1.0e-3*(t_0-t_1)
|
||||||
if not np.isnan(deltat) and not np.isnan(wmax):
|
wmax = w_roll.ix[indexmax]
|
||||||
dt.append(deltat)
|
if not np.isnan(deltat) and not np.isnan(wmax):
|
||||||
cpw.append(wmax)
|
dt.append(deltat)
|
||||||
except KeyError:
|
cpw.append(wmax)
|
||||||
pass
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
dt = pd.Series(dt)
|
dt = pd.Series(dt)
|
||||||
|
|||||||
Reference in New Issue
Block a user