Finished improving cum_flex chart
This commit is contained in:
@@ -123,8 +123,10 @@ def dataprep(rowdatadf):
|
|||||||
data = DataFrame(
|
data = DataFrame(
|
||||||
dict(
|
dict(
|
||||||
time = t2,
|
time = t2,
|
||||||
|
timesecs = t,
|
||||||
hr = hr,
|
hr = hr,
|
||||||
pace = p2,
|
pace = p2,
|
||||||
|
pseconds=p,
|
||||||
spm = spm,
|
spm = spm,
|
||||||
cumdist = cumdist,
|
cumdist = cumdist,
|
||||||
ftime = niceformat(t2),
|
ftime = niceformat(t2),
|
||||||
|
|||||||
@@ -624,53 +624,60 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
|
|||||||
|
|
||||||
|
|
||||||
datadf = dataprep.dataprep(thedata)
|
datadf = dataprep.dataprep(thedata)
|
||||||
# thedata['driveenergy'] = thedata[' DriveLength (meters)']*thedata[' AverageDriveForce (lbs)']*4.44822
|
|
||||||
|
|
||||||
|
if yparam1 != 'pace' and yparam1 != 'time':
|
||||||
# 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[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]
|
datadf = datadf[datadf[xparam] > 0]
|
||||||
|
elif xparam == 'time':
|
||||||
|
datadf = datadf[datadf['timesecs']>0]
|
||||||
|
else:
|
||||||
|
datadf = datadf[datadf['pseconds']>0]
|
||||||
|
|
||||||
if yparam2 != 'None':
|
if yparam2 != 'None':
|
||||||
#thedata = thedata[thedata[csvcolumns[yparam2]] > 0]
|
datadf = datadf[datadf[yparam2] > 0]
|
||||||
datadf = datadf[thedata[yparam2] > 0]
|
|
||||||
|
|
||||||
# check if dataframe not empty
|
# check if dataframe not empty
|
||||||
if datadf.empty:
|
if datadf.empty:
|
||||||
return ['','<p>No non-zero data in selection</p>','','']
|
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':
|
if yparam2 != 'None':
|
||||||
y2 = datadf.ix[:,yparam2]
|
datadf['y2'] = datadf.ix[:,yparam2]
|
||||||
else:
|
else:
|
||||||
y2 = y1
|
datadf['y2'] = datadf['y1']
|
||||||
|
|
||||||
|
|
||||||
if xparam=='time':
|
if xparam=='time':
|
||||||
xaxmax = x1.max()
|
xaxmax = tseconds.max()
|
||||||
xaxmin = x1.min()
|
xaxmin = tseconds.min()
|
||||||
xaxmax = 1.0e3*xaxmax
|
xaxmax = 1.0e3*xaxmax
|
||||||
xaxmin = 1.0e3*xaxmin
|
xaxmin = 1.0e3*xaxmin
|
||||||
x1 = x1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
|
|
||||||
elif xparam=='distance':
|
elif xparam=='distance':
|
||||||
xaxmax = x1.max()
|
xaxmax = datadf['x1'].max()
|
||||||
xaxmin = x1.min()
|
xaxmin = datadf['x1'].min()
|
||||||
else:
|
else:
|
||||||
xaxmax = yaxmaxima[xparam]
|
xaxmax = yaxmaxima[xparam]
|
||||||
xaxmin = yaxminima[xparam]
|
xaxmin = yaxminima[xparam]
|
||||||
|
|
||||||
# average values
|
# average values
|
||||||
if xparam != 'time':
|
if xparam != 'time':
|
||||||
x1mean = x1.mean()
|
x1mean = datadf['x1'].mean()
|
||||||
else:
|
else:
|
||||||
x1mean = 0
|
x1mean = 0
|
||||||
|
|
||||||
y1mean = y1.mean()
|
y1mean = datadf['y1'].mean()
|
||||||
y2mean = y2.mean()
|
y2mean = datadf['y2'].mean()
|
||||||
|
|
||||||
if xparam != 'time':
|
if xparam != 'time':
|
||||||
xvals = pd.Series(xaxmin+np.arange(100)*(xaxmax-xaxmin)/100.)
|
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':
|
if yparam1 == 'pace':
|
||||||
y_axis_type = 'datetime'
|
y_axis_type = 'datetime'
|
||||||
y1 = y1.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
|
y1mean = datadf.ix[:,'pseconds'].mean()
|
||||||
|
|
||||||
|
|
||||||
time = datadf.ix[:,'time']
|
source = ColumnDataSource(
|
||||||
hr = datadf.ix[:,'hr']
|
datadf
|
||||||
pace = datadf.ix[:,'pace']
|
)
|
||||||
distance = datadf.ix[:,'distance']
|
|
||||||
power = datadf.ix[:,'power']
|
|
||||||
ftime = datadf.ix[:,'ftime']
|
|
||||||
fpace = datadf.ix[:,'fpace']
|
|
||||||
spm = datadf.ix[:,'spm']
|
|
||||||
|
|
||||||
|
source2 = ColumnDataSource(
|
||||||
|
datadf.copy()
|
||||||
|
)
|
||||||
|
|
||||||
# Add hover to this comma-separated string and see what changes
|
# Add hover to this comma-separated string and see what changes
|
||||||
if (promember==1):
|
if (promember==1):
|
||||||
@@ -720,37 +725,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
|
|||||||
|
|
||||||
plot.add_layout(y1means)
|
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,
|
plot.circle('x1','y1',source=source2,fill_alpha=0.3,line_color=None,
|
||||||
legend=yparamname1,
|
legend=yparamname1,
|
||||||
)
|
)
|
||||||
@@ -900,7 +875,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
|
|||||||
title="Max SPM",callback=callback)
|
title="Max SPM",callback=callback)
|
||||||
callback.args["maxspm"] = slider_spm_max
|
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,
|
slider_dist_min = Slider(start=0,end=distmax,value=0,step=1,
|
||||||
title="Min Distance",callback=callback)
|
title="Min Distance",callback=callback)
|
||||||
@@ -1070,7 +1045,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
# constant power plot
|
# constant power plot
|
||||||
if yparam1 == 'driveenergy':
|
if yparam1 == 'driveenergy':
|
||||||
if xparam == 'spm':
|
if xparam == 'spm':
|
||||||
yconstantpower = y1.median()*x1.median()/xvals
|
yconstantpower = y1.mean()*x1.mean()/xvals
|
||||||
|
|
||||||
x_axis_type = 'linear'
|
x_axis_type = 'linear'
|
||||||
y_axis_type = 'linear'
|
y_axis_type = 'linear'
|
||||||
|
|||||||
@@ -793,10 +793,6 @@ class subroutinetests(TestCase):
|
|||||||
duration="0:55:00",distance=8000,
|
duration="0:55:00",distance=8000,
|
||||||
csvfilename=filename)
|
csvfilename=filename)
|
||||||
|
|
||||||
def test_seconds(self):
|
|
||||||
seconds = [30.3,75.8,3900.3,104670.2]
|
|
||||||
res = iplots.get_datetimes(seconds)
|
|
||||||
|
|
||||||
|
|
||||||
def c2stuff(self):
|
def c2stuff(self):
|
||||||
data = c2stuff.createc2workoutdata(self.w)
|
data = c2stuff.createc2workoutdata(self.w)
|
||||||
|
|||||||
@@ -1204,8 +1204,8 @@ def cum_flex(request,theuser=0,
|
|||||||
xparam='spm',
|
xparam='spm',
|
||||||
yparam1='power',
|
yparam1='power',
|
||||||
yparam2='None',
|
yparam2='None',
|
||||||
startdate=timezone.now()-datetime.timedelta(days=30),
|
startdate=timezone.now()-datetime.timedelta(days=10),
|
||||||
enddate=timezone.now(),
|
enddate=timezone.now()+datetime.timedelta(days=1),
|
||||||
deltadays=-1,
|
deltadays=-1,
|
||||||
startdatestring="",
|
startdatestring="",
|
||||||
enddatestring=""):
|
enddatestring=""):
|
||||||
|
|||||||
Reference in New Issue
Block a user