Private
Public Access
1
0

Finished improving cum_flex chart

This commit is contained in:
sanderroosendaal
2016-11-01 22:08:33 +01:00
parent 01ea80c539
commit 9d2633bfde
4 changed files with 41 additions and 68 deletions

View File

@@ -624,53 +624,60 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
datadf = dataprep.dataprep(thedata)
# thedata['driveenergy'] = thedata[' DriveLength (meters)']*thedata[' AverageDriveForce (lbs)']*4.44822
# throw out zeros from dataframe
#thedata = thedata[thedata[csvcolumns[yparam1]] > 0]
#thedata = thedata[thedata[csvcolumns[xparam]] > 0]
datadf = datadf[datadf[yparam1] > 0]
datadf = datadf[datadf[xparam] > 0]
if yparam1 != 'pace' and yparam1 != 'time':
datadf = datadf[datadf[yparam1] > 0]
elif yparam1 == 'time':
datadf = datadf[datadf['timesecs'] > 0]
else:
datadf = datadf[datadf['pseconds']>0]
if xparam != 'time' and xparam != 'pace':
datadf = datadf[datadf[xparam] > 0]
elif xparam == 'time':
datadf = datadf[datadf['timesecs']>0]
else:
datadf = datadf[datadf['pseconds']>0]
if yparam2 != 'None':
#thedata = thedata[thedata[csvcolumns[yparam2]] > 0]
datadf = datadf[thedata[yparam2] > 0]
datadf = datadf[datadf[yparam2] > 0]
# check if dataframe not empty
if datadf.empty:
return ['','<p>No non-zero data in selection</p>','','']
x1 = datadf.ix[:,xparam]
datadf['x1'] = datadf.ix[:,xparam]
tseconds = datadf.ix[:,'timesecs']
y1 = datadf.ix[:,yparam1]
datadf['y1'] = datadf.ix[:,yparam1]
if yparam2 != 'None':
y2 = datadf.ix[:,yparam2]
datadf['y2'] = datadf.ix[:,yparam2]
else:
y2 = y1
datadf['y2'] = datadf['y1']
if xparam=='time':
xaxmax = x1.max()
xaxmin = x1.min()
xaxmax = tseconds.max()
xaxmin = tseconds.min()
xaxmax = 1.0e3*xaxmax
xaxmin = 1.0e3*xaxmin
x1 = x1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
elif xparam=='distance':
xaxmax = x1.max()
xaxmin = x1.min()
xaxmax = datadf['x1'].max()
xaxmin = datadf['x1'].min()
else:
xaxmax = yaxmaxima[xparam]
xaxmin = yaxminima[xparam]
# average values
if xparam != 'time':
x1mean = x1.mean()
x1mean = datadf['x1'].mean()
else:
x1mean = 0
y1mean = y1.mean()
y2mean = y2.mean()
y1mean = datadf['y1'].mean()
y2mean = datadf['y2'].mean()
if xparam != 'time':
xvals = pd.Series(xaxmin+np.arange(100)*(xaxmax-xaxmin)/100.)
@@ -684,18 +691,16 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
if yparam1 == 'pace':
y_axis_type = 'datetime'
y1 = y1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
y1mean = datadf.ix[:,'pseconds'].mean()
time = datadf.ix[:,'time']
hr = datadf.ix[:,'hr']
pace = datadf.ix[:,'pace']
distance = datadf.ix[:,'distance']
power = datadf.ix[:,'power']
ftime = datadf.ix[:,'ftime']
fpace = datadf.ix[:,'fpace']
spm = datadf.ix[:,'spm']
source = ColumnDataSource(
datadf
)
source2 = ColumnDataSource(
datadf.copy()
)
# Add hover to this comma-separated string and see what changes
if (promember==1):
@@ -720,37 +725,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
plot.add_layout(y1means)
source = ColumnDataSource(
data = dict(
x1=x1,
y1=y1,
y2=y2,
time=ftime,
pace=fpace,
hr = hr,
spm = spm,
distance=distance,
power=power,
)
)
source2 = ColumnDataSource(
data = dict(
x1=x1,
y1=y1,
y2=y2,
time=ftime,
pace=fpace,
hr = hr,
spm = spm,
distance=distance,
power=power,
)
)
# plot.circle('x1','y1',source=source,legend=yparam1,size=3)
plot.circle('x1','y1',source=source2,fill_alpha=0.3,line_color=None,
legend=yparamname1,
)
@@ -900,7 +875,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
title="Max SPM",callback=callback)
callback.args["maxspm"] = slider_spm_max
distmax = 100+100*int(distance.max()/100.)
distmax = 100+100*int(datadf['distance'].max()/100.)
slider_dist_min = Slider(start=0,end=distmax,value=0,step=1,
title="Min Distance",callback=callback)
@@ -1070,7 +1045,7 @@ def interactive_flex_chart2(id=0,promember=0,
# constant power plot
if yparam1 == 'driveenergy':
if xparam == 'spm':
yconstantpower = y1.median()*x1.median()/xvals
yconstantpower = y1.mean()*x1.mean()/xvals
x_axis_type = 'linear'
y_axis_type = 'linear'