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"
|
||||
|
||||
|
||||
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||
ftime = niceformat(deltas)
|
||||
|
||||
sourcecomplex = ColumnDataSource(
|
||||
data = dict(
|
||||
power = fitpower,
|
||||
duration = fitt
|
||||
CP = fitpower,
|
||||
duration = fitt,
|
||||
ftime = ftime
|
||||
)
|
||||
)
|
||||
|
||||
@@ -671,7 +675,7 @@ def interactive_otwcpchart(powerdf,promember=0):
|
||||
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')
|
||||
plot.xaxis.axis_label = "Duration (seconds)"
|
||||
plot.yaxis.axis_label = "Power (W)"
|
||||
@@ -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)
|
||||
|
||||
@@ -2903,9 +2903,9 @@ def otwrankings_view(request,theuser=0,
|
||||
else:
|
||||
maxt = 1000.
|
||||
|
||||
|
||||
|
||||
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 = pd.Series(logarr)
|
||||
logarr.drop_duplicates(keep='first',inplace=True)
|
||||
@@ -2920,8 +2920,9 @@ def otwrankings_view(request,theuser=0,
|
||||
|
||||
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:
|
||||
@@ -2931,19 +2932,20 @@ 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]
|
||||
if not np.isnan(deltat) and not np.isnan(wmax):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user