data fusion now working ...
This commit is contained in:
@@ -959,35 +959,41 @@ def smalldataprep(therows,xparam,yparam1,yparam2):
|
|||||||
# data fusion
|
# data fusion
|
||||||
def datafusion(id1,id2,columns,offset):
|
def datafusion(id1,id2,columns,offset):
|
||||||
df1,w1 = getrowdata_db(id=id1)
|
df1,w1 = getrowdata_db(id=id1)
|
||||||
df1 = df1.drop(['cumdist',
|
df1 = df1.drop([#'cumdist',
|
||||||
'hr_ut2',
|
'hr_ut2',
|
||||||
'hr_ut1',
|
'hr_ut1',
|
||||||
'hr_at',
|
'hr_at',
|
||||||
'hr_tr',
|
'hr_tr',
|
||||||
'hr_an',
|
'hr_an',
|
||||||
'hr_max',],
|
'hr_max',
|
||||||
|
'ftime',
|
||||||
|
'fpace',
|
||||||
|
'workoutid',
|
||||||
|
'id'],
|
||||||
1,errors='ignore')
|
1,errors='ignore')
|
||||||
columns = ['time']+columns
|
|
||||||
df2 = getsmallrowdata_db(columns,ids=[id2],doclean=False)
|
|
||||||
|
|
||||||
print df1['pace'].mean()/1000.,'mies'
|
df2 = getsmallrowdata_db(['time']+columns,ids=[id2],doclean=False)
|
||||||
|
offsetmillisecs = offset.seconds*1000+offset.microseconds/1000.
|
||||||
|
offsetmillisecs += offset.days*(3600*24*1000)
|
||||||
|
df2['time'] = df2['time']+offsetmillisecs
|
||||||
|
|
||||||
keep1 = {c:c for c in set(df1.columns)}
|
keep1 = {c:c for c in set(df1.columns)}
|
||||||
for c in columns:
|
for c in columns:
|
||||||
keep1.pop(c)
|
keep1.pop(c)
|
||||||
|
|
||||||
for c in df1.columns:
|
for c in df1.columns:
|
||||||
if not c in keep1:
|
if not c in keep1:
|
||||||
df1 = df1.drop(c,1,errors='ignore')
|
df1 = df1.drop(c,1,errors='ignore')
|
||||||
|
|
||||||
df = pd.concat([df1,df2],ignore_index=True)
|
df = pd.concat([df1,df2],ignore_index=True)
|
||||||
df = df.sort_values(['time'])
|
df = df.sort_values(['time'])
|
||||||
df = df.interpolate(method='linear',axis=0,limit_direction='both')
|
df = df.interpolate(method='linear',axis=0,limit_direction='both',
|
||||||
|
limit=10)
|
||||||
df.fillna(method='bfill',inplace=True)
|
df.fillna(method='bfill',inplace=True)
|
||||||
|
|
||||||
df['time'] = df['time']/1000.
|
df['time'] = df['time']/1000.
|
||||||
df['pace'] = df['pace']/1000.
|
df['pace'] = df['pace']/1000.
|
||||||
print df['pace'].mean(),'noot'
|
df['cum_dist'] = df['cumdist']
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
@@ -1005,7 +1011,6 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
rowdatadf.loc[row_index,' Stroke500mPace (sec/500m)'] = 3000.
|
rowdatadf.loc[row_index,' Stroke500mPace (sec/500m)'] = 3000.
|
||||||
|
|
||||||
p = rowdatadf.ix[:,' Stroke500mPace (sec/500m)']
|
p = rowdatadf.ix[:,' Stroke500mPace (sec/500m)']
|
||||||
print p.mean(),'aap'
|
|
||||||
hr = rowdatadf.ix[:,' HRCur (bpm)']
|
hr = rowdatadf.ix[:,' HRCur (bpm)']
|
||||||
spm = rowdatadf.ix[:,' Cadence (stokes/min)']
|
spm = rowdatadf.ix[:,' Cadence (stokes/min)']
|
||||||
cumdist = rowdatadf.ix[:,'cum_dist']
|
cumdist = rowdatadf.ix[:,'cum_dist']
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ class WorkoutMultipleCompareForm(forms.Form):
|
|||||||
|
|
||||||
from rowers.interactiveplots import axlabels
|
from rowers.interactiveplots import axlabels
|
||||||
|
|
||||||
axlabels.pop('None')
|
formaxlabels = axlabels.copy()
|
||||||
|
formaxlabels.pop('None')
|
||||||
parchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
parchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
||||||
|
|
||||||
|
|
||||||
@@ -273,10 +274,16 @@ class ChartParamChoiceForm(forms.Form):
|
|||||||
plottype = forms.ChoiceField(choices=plotchoices,initial='scatter')
|
plottype = forms.ChoiceField(choices=plotchoices,initial='scatter')
|
||||||
teamid = forms.IntegerField(widget=forms.HiddenInput())
|
teamid = forms.IntegerField(widget=forms.HiddenInput())
|
||||||
|
|
||||||
axlabels.pop('time')
|
formaxlabels.pop('time')
|
||||||
metricchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
metricchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
||||||
|
|
||||||
class FusionMetricChoiceForm(forms.Form):
|
class FusionMetricChoiceForm(forms.Form):
|
||||||
|
posneg = (
|
||||||
|
('pos','Workout 2 starts after Workout 1'),
|
||||||
|
('neg','Workout 2 starts before Workout 1'),
|
||||||
|
)
|
||||||
columns = forms.MultipleChoiceField(choices=metricchoices,
|
columns = forms.MultipleChoiceField(choices=metricchoices,
|
||||||
initial=[],
|
initial=[],
|
||||||
widget=forms.CheckboxSelectMultiple())
|
widget=forms.CheckboxSelectMultiple())
|
||||||
|
posneg = forms.ChoiceField(choices=posneg,initial='pos')
|
||||||
|
offset = forms.DurationField(label='Time Offset',initial=datetime.timedelta())
|
||||||
|
|||||||
@@ -1291,10 +1291,10 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
y2means = y1means
|
y2means = y1means
|
||||||
|
|
||||||
xlabel = Label(x=100,y=130,x_units='screen',y_units='screen',
|
xlabel = Label(x=100,y=130,x_units='screen',y_units='screen',
|
||||||
text=axlabels[xparam]+": {x1mean:6.2f}".format(x1mean=x1mean),
|
text=axlabels[xparam]+": {x1mean:6.2f}".format(x1mean=x1mean),
|
||||||
background_fill_alpha=.7,
|
background_fill_alpha=.7,
|
||||||
text_color='green',
|
text_color='green',
|
||||||
)
|
)
|
||||||
|
|
||||||
if (xparam != 'time') and (xparam != 'distance') and (xparam != 'cumdist'):
|
if (xparam != 'time') and (xparam != 'distance') and (xparam != 'cumdist'):
|
||||||
plot.add_layout(x1means)
|
plot.add_layout(x1means)
|
||||||
@@ -1325,6 +1325,7 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
|
|
||||||
plot.title.text = row.name
|
plot.title.text = row.name
|
||||||
plot.title.text_font_size=value("1.0em")
|
plot.title.text_font_size=value("1.0em")
|
||||||
|
|
||||||
plot.xaxis.axis_label = axlabels[xparam]
|
plot.xaxis.axis_label = axlabels[xparam]
|
||||||
plot.yaxis.axis_label = axlabels[yparam1]
|
plot.yaxis.axis_label = axlabels[yparam1]
|
||||||
|
|
||||||
|
|||||||
@@ -5017,15 +5017,27 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|||||||
form = FusionMetricChoiceForm(request.POST)
|
form = FusionMetricChoiceForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
columns = cd['columns']
|
columns = cd['columns']
|
||||||
|
timeoffset = cd['offset']
|
||||||
|
posneg = cd['posneg']
|
||||||
|
if posneg == 'neg':
|
||||||
|
timeoffset = -timeoffset
|
||||||
df = dataprep.datafusion(id1,id2,columns,timeoffset)
|
df = dataprep.datafusion(id1,id2,columns,timeoffset)
|
||||||
idnew,message = dataprep.new_workout_from_df(r,df,
|
idnew,message = dataprep.new_workout_from_df(r,df,
|
||||||
title='Fused data',
|
title='Fused data',
|
||||||
parent=w1)
|
parent=w1)
|
||||||
url = reverse(workout_edit_view,
|
if message != None:
|
||||||
kwargs={
|
url = reverse(workout_edit_view,
|
||||||
'message':message,
|
kwargs={
|
||||||
'id':idnew,
|
'message':message,
|
||||||
|
'id':idnew,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
successmessage = 'Data fused'
|
||||||
|
url = reverse(workout_edit_view,
|
||||||
|
kwargs={
|
||||||
|
'successmessage':successmessage,
|
||||||
|
'id':idnew,
|
||||||
})
|
})
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|||||||
Reference in New Issue
Block a user