Merge branch 'release/v2.95'
This commit is contained in:
+8
-2
@@ -104,8 +104,14 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
|
|||||||
totaldist = data['distance']
|
totaldist = data['distance']
|
||||||
totaltime = data['time']/10.
|
totaltime = data['time']/10.
|
||||||
spm = data['stroke_rate']
|
spm = data['stroke_rate']
|
||||||
resttime = data['rest_time']/10.
|
try:
|
||||||
restdistance = data['rest_distance']
|
resttime = data['rest_time']/10.
|
||||||
|
except KeyError:
|
||||||
|
resttime = 0
|
||||||
|
try:
|
||||||
|
restdistance = data['rest_distance']
|
||||||
|
except keyError:
|
||||||
|
restdistance = 0
|
||||||
try:
|
try:
|
||||||
avghr = data['heart_rate']['average']
|
avghr = data['heart_rate']['average']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
+62
-36
@@ -730,11 +730,11 @@ def new_workout_from_df(r,df,
|
|||||||
|
|
||||||
csvfilename ='media/Fusion_'+timestr+'.csv'
|
csvfilename ='media/Fusion_'+timestr+'.csv'
|
||||||
|
|
||||||
|
|
||||||
df.rename(columns = columndict,inplace=True)
|
df.rename(columns = columndict,inplace=True)
|
||||||
starttimeunix = mktime(startdatetime.utctimetuple())
|
starttimeunix = mktime(startdatetime.utctimetuple())
|
||||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
||||||
df['TimeStamp (sec)'] = df['TimeStamp (sec)']+starttimeunix
|
df['TimeStamp (sec)'] = df['TimeStamp (sec)']+starttimeunix
|
||||||
print df.info()
|
|
||||||
|
|
||||||
row = rrdata(df=df)
|
row = rrdata(df=df)
|
||||||
row.write_csv(csvfilename,gzip=True)
|
row.write_csv(csvfilename,gzip=True)
|
||||||
@@ -888,8 +888,9 @@ def getrowdata_db(id=0,doclean=False):
|
|||||||
if doclean:
|
if doclean:
|
||||||
data = clean_df_stats(data,ignorehr=True)
|
data = clean_df_stats(data,ignorehr=True)
|
||||||
|
|
||||||
data['averageforce'] = data['averageforce']
|
# these two lines seem redundant ??
|
||||||
data['peakforce'] = data['peakforce']
|
#data['averageforce'] = data['averageforce']
|
||||||
|
#data['peakforce'] = data['peakforce']
|
||||||
|
|
||||||
return data,row
|
return data,row
|
||||||
|
|
||||||
@@ -1106,10 +1107,13 @@ def datafusion(id1,id2,columns,offset):
|
|||||||
offsetmillisecs += offset.days*(3600*24*1000)
|
offsetmillisecs += offset.days*(3600*24*1000)
|
||||||
df2['time'] = df2['time']+offsetmillisecs
|
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')
|
||||||
@@ -1246,40 +1250,62 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
if empower:
|
if empower:
|
||||||
try:
|
try:
|
||||||
wash = rowdatadf.ix[:,'wash']
|
wash = rowdatadf.ix[:,'wash']
|
||||||
catch = rowdatadf.ix[:,'catch']
|
|
||||||
finish = rowdatadf.ix[:,'finish']
|
|
||||||
peakforceangle = rowdatadf.ix[:,'peakforceangle']
|
|
||||||
driveenergy = rowdatadf.ix[:,'driveenergy']
|
|
||||||
arclength = (inboard-0.05)*(np.radians(finish)-np.radians(catch))
|
|
||||||
if arclength.mean()>0:
|
|
||||||
drivelength = arclength
|
|
||||||
else:
|
|
||||||
drivelength = driveenergy/(averageforce*4.44822)
|
|
||||||
|
|
||||||
slip = rowdatadf.ix[:,'slip']
|
|
||||||
totalangle = finish-catch
|
|
||||||
effectiveangle = finish-wash-catch-slip
|
|
||||||
if windowsize > 3 and windowsize<len(slip):
|
|
||||||
wash = savgol_filter(wash,windowsize,3)
|
|
||||||
slip = savgol_filter(slip,windowsize,3)
|
|
||||||
catch = savgol_filter(catch,windowsize,3)
|
|
||||||
finish = savgol_filter(finish,windowsize,3)
|
|
||||||
peakforceangle = savgol_filter(peakforceangle,windowsize,3)
|
|
||||||
driveenergy = savgol_filter(driveenergy,windowsize,3)
|
|
||||||
drivelength = savgol_filter(drivelength,windowsize,3)
|
|
||||||
totalangle = savgol_filter(totalangle,windowsize,3)
|
|
||||||
effectiveangle = savgol_filter(effectiveangle,windowsize,3)
|
|
||||||
data['wash'] = wash
|
|
||||||
data['catch'] = catch
|
|
||||||
data['slip'] = slip
|
|
||||||
data['finish'] = finish
|
|
||||||
data['peakforceangle'] = peakforceangle
|
|
||||||
data['driveenergy'] = driveenergy
|
|
||||||
data['drivelength'] = drivelength
|
|
||||||
data['totalangle'] = totalangle
|
|
||||||
data['effectiveangle'] = effectiveangle
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
wash = 0*power
|
||||||
|
|
||||||
|
try:
|
||||||
|
catch = rowdatadf.ix[:,'catch']
|
||||||
|
except KeyError:
|
||||||
|
catch = 0*power
|
||||||
|
|
||||||
|
try:
|
||||||
|
finish = rowdatadf.ix[:,'finish']
|
||||||
|
except KeyError:
|
||||||
|
finish = 0*power
|
||||||
|
|
||||||
|
try:
|
||||||
|
peakforceangle = rowdatadf.ix[:,'peakforceangle']
|
||||||
|
except KeyError:
|
||||||
|
peakforceangle = 0*power
|
||||||
|
|
||||||
|
try:
|
||||||
|
driveenergy = rowdatadf.ix[:,'driveenergy']
|
||||||
|
except KeyError:
|
||||||
|
driveenergy = 0*power
|
||||||
|
|
||||||
|
arclength = (inboard-0.05)*(np.radians(finish)-np.radians(catch))
|
||||||
|
if arclength.mean()>0:
|
||||||
|
drivelength = arclength
|
||||||
|
else:
|
||||||
|
drivelength = driveenergy/(averageforce*4.44822)
|
||||||
|
|
||||||
|
try:
|
||||||
|
slip = rowdatadf.ix[:,'slip']
|
||||||
|
except KeyError:
|
||||||
|
slip = 0*power
|
||||||
|
|
||||||
|
totalangle = finish-catch
|
||||||
|
effectiveangle = finish-wash-catch-slip
|
||||||
|
if windowsize > 3 and windowsize<len(slip):
|
||||||
|
wash = savgol_filter(wash,windowsize,3)
|
||||||
|
slip = savgol_filter(slip,windowsize,3)
|
||||||
|
catch = savgol_filter(catch,windowsize,3)
|
||||||
|
finish = savgol_filter(finish,windowsize,3)
|
||||||
|
peakforceangle = savgol_filter(peakforceangle,windowsize,3)
|
||||||
|
driveenergy = savgol_filter(driveenergy,windowsize,3)
|
||||||
|
drivelength = savgol_filter(drivelength,windowsize,3)
|
||||||
|
totalangle = savgol_filter(totalangle,windowsize,3)
|
||||||
|
effectiveangle = savgol_filter(effectiveangle,windowsize,3)
|
||||||
|
|
||||||
|
data['wash'] = wash
|
||||||
|
data['catch'] = catch
|
||||||
|
data['slip'] = slip
|
||||||
|
data['finish'] = finish
|
||||||
|
data['peakforceangle'] = peakforceangle
|
||||||
|
data['driveenergy'] = driveenergy
|
||||||
|
data['drivelength'] = drivelength
|
||||||
|
data['totalangle'] = totalangle
|
||||||
|
data['effectiveangle'] = effectiveangle
|
||||||
|
|
||||||
if otwpower:
|
if otwpower:
|
||||||
try:
|
try:
|
||||||
|
|||||||
+3
-2
@@ -343,6 +343,7 @@ class FusionMetricChoiceForm(ModelForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(FusionMetricChoiceForm, self).__init__(*args, **kwargs)
|
super(FusionMetricChoiceForm, self).__init__(*args, **kwargs)
|
||||||
|
formaxlabels2 = formaxlabels.copy()
|
||||||
# need to add code to remove "empty" fields
|
# need to add code to remove "empty" fields
|
||||||
|
|
||||||
if self.instance.id is not None:
|
if self.instance.id is not None:
|
||||||
@@ -354,10 +355,10 @@ class FusionMetricChoiceForm(ModelForm):
|
|||||||
for label in labeldict:
|
for label in labeldict:
|
||||||
if df.ix[:,label].std() == 0:
|
if df.ix[:,label].std() == 0:
|
||||||
try:
|
try:
|
||||||
formaxlabels.pop(label)
|
formaxlabels2.pop(label)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
|
metricchoices = list(sorted(formaxlabels2.items(), key = lambda x:x[1]))
|
||||||
self.fields['columns'].choices = metricchoices
|
self.fields['columns'].choices = metricchoices
|
||||||
|
|
||||||
|
|||||||
@@ -315,7 +315,6 @@ def get_userid(access_token):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
res = ''
|
res = ''
|
||||||
|
|
||||||
print res,'userID'
|
|
||||||
return str(res)
|
return str(res)
|
||||||
|
|
||||||
def workout_runkeeper_upload(user,w):
|
def workout_runkeeper_upload(user,w):
|
||||||
|
|||||||
@@ -257,11 +257,12 @@ def createstravaworkoutdata(w):
|
|||||||
with gzip.GzipFile(gzfilename,'wb') as outF:
|
with gzip.GzipFile(gzfilename,'wb') as outF:
|
||||||
outF.write(s)
|
outF.write(s)
|
||||||
os.remove(tcxfilename)
|
os.remove(tcxfilename)
|
||||||
return gzfilename
|
return gzfilename,""
|
||||||
except:
|
except:
|
||||||
|
message = str(sys.exc_info()[0])
|
||||||
tcxfilename = 0
|
tcxfilename = 0
|
||||||
|
|
||||||
return tcxfilename
|
return tcxfilename,message
|
||||||
|
|
||||||
# Upload the TCX file to Strava and set the workout activity type
|
# Upload the TCX file to Strava and set the workout activity type
|
||||||
# to rowing on Strava
|
# to rowing on Strava
|
||||||
@@ -282,8 +283,8 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
|||||||
if res:
|
if res:
|
||||||
act = client.update_activity(res.id,activity_type='Rowing',description=description,device_name='Rowsandall.com')
|
act = client.update_activity(res.id,activity_type='Rowing',description=description,device_name='Rowsandall.com')
|
||||||
else:
|
else:
|
||||||
message = 'Strava upload timed out.'
|
message = 'Strava activity update timed out.'
|
||||||
return (0,message)
|
return (res.id,message)
|
||||||
|
|
||||||
return (res.id,message)
|
return (res.id,message)
|
||||||
|
|
||||||
@@ -299,7 +300,7 @@ def workout_strava_upload(user,w):
|
|||||||
else:
|
else:
|
||||||
if (checkworkoutuser(user,w)):
|
if (checkworkoutuser(user,w)):
|
||||||
try:
|
try:
|
||||||
tcxfile = createstravaworkoutdata(w)
|
tcxfile,tcxmesg = createstravaworkoutdata(w)
|
||||||
if tcxfile:
|
if tcxfile:
|
||||||
with open(tcxfile,'rb') as f:
|
with open(tcxfile,'rb') as f:
|
||||||
res,mes = handle_stravaexport(f,w.name,
|
res,mes = handle_stravaexport(f,w.name,
|
||||||
@@ -326,7 +327,7 @@ def workout_strava_upload(user,w):
|
|||||||
stravaid = res
|
stravaid = res
|
||||||
return message,stravaid
|
return message,stravaid
|
||||||
else:
|
else:
|
||||||
message = "Strava Upload error"
|
message = "Strava TCX data error "+tcxmesg
|
||||||
w.uploadedtostrava = -1
|
w.uploadedtostrava = -1
|
||||||
stravaid = -1
|
stravaid = -1
|
||||||
w.save()
|
w.save()
|
||||||
|
|||||||
+13
-9
@@ -925,8 +925,6 @@ def add_workout_from_underarmourdata(user,importid,data):
|
|||||||
|
|
||||||
times_distance = res[0]
|
times_distance = res[0]
|
||||||
|
|
||||||
print distance[0:5]
|
|
||||||
print times_distance[0:5]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
l = timeseries['position']
|
l = timeseries['position']
|
||||||
@@ -1062,9 +1060,9 @@ def workout_tcxemail_view(request,id=0):
|
|||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
try:
|
try:
|
||||||
tcxfile = stravastuff.createstravaworkoutdata(w)
|
tcxfile,tcxmessg = stravastuff.createstravaworkoutdata(w)
|
||||||
if tcxfile == 0:
|
if tcxfile == 0:
|
||||||
message = "Something went wrong (TCX export)"
|
message = "Something went wrong (TCX export) "+tcxmessg
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
url = reverse(workout_export_view,
|
url = reverse(workout_export_view,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
@@ -1181,7 +1179,7 @@ def workout_csvtoadmin_view(request,id=0):
|
|||||||
|
|
||||||
successmessage = "The CSV file was sent to the site admin per email"
|
successmessage = "The CSV file was sent to the site admin per email"
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
url = reverse(workout_export_view,
|
url = reverse(workout_view,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'id':str(w.id),
|
'id':str(w.id),
|
||||||
})
|
})
|
||||||
@@ -1265,7 +1263,7 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
if (checkworkoutuser(request.user,w)):
|
if (checkworkoutuser(request.user,w)):
|
||||||
try:
|
try:
|
||||||
tcxfile = stravastuff.createstravaworkoutdata(w)
|
tcxfile,tcxmessg = stravastuff.createstravaworkoutdata(w)
|
||||||
if tcxfile:
|
if tcxfile:
|
||||||
with open(tcxfile,'rb') as f:
|
with open(tcxfile,'rb') as f:
|
||||||
res,mes = stravastuff.handle_stravaexport(f,w.name,
|
res,mes = stravastuff.handle_stravaexport(f,w.name,
|
||||||
@@ -1289,7 +1287,11 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
try:
|
try:
|
||||||
w.uploadedtostrava = res
|
w.uploadedtostrava = res
|
||||||
w.save()
|
w.save()
|
||||||
os.remove(tcxfile)
|
try:
|
||||||
|
os.remove(tcxfile)
|
||||||
|
except WindowsError:
|
||||||
|
print tcxfile
|
||||||
|
pass
|
||||||
url = "/rowers/workout/"+str(w.id)+"/edit"
|
url = "/rowers/workout/"+str(w.id)+"/edit"
|
||||||
|
|
||||||
messages.info(request,mes)
|
messages.info(request,mes)
|
||||||
@@ -1301,8 +1303,8 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
errorlog.write("views.py line 826\r\n")
|
errorlog.write("views.py line 826\r\n")
|
||||||
message = 'Error: '+errorstring
|
message = 'Error: '+errorstring
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
else:
|
else: # No tcxfile
|
||||||
message = "Strava Upload error"
|
message = "Strava Data error "+tcxmessg
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
w.uploadedtostrava = -1
|
w.uploadedtostrava = -1
|
||||||
w.save()
|
w.save()
|
||||||
@@ -6941,7 +6943,9 @@ def workout_fusion_view(request,id1=0,id2=1):
|
|||||||
posneg = cd['posneg']
|
posneg = cd['posneg']
|
||||||
if posneg == 'neg':
|
if posneg == 'neg':
|
||||||
timeoffset = -timeoffset
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user