fixing some C2 bike erg related stuff
This commit is contained in:
@@ -268,7 +268,8 @@ def c2wc(weightclass):
|
|||||||
# Concept2 logbook sends over split data for each interval
|
# Concept2 logbook sends over split data for each interval
|
||||||
# We use it here to generate a custom summary
|
# We use it here to generate a custom summary
|
||||||
# Some users complained about small differences
|
# Some users complained about small differences
|
||||||
def summaryfromsplitdata(splitdata,data,filename,sep='|'):
|
def summaryfromsplitdata(splitdata,data,filename,sep='|',workouttype='rower'):
|
||||||
|
workouttype = workouttype.lower()
|
||||||
|
|
||||||
totaldist = data['distance']
|
totaldist = data['distance']
|
||||||
totaltime = data['time']/10.
|
totaltime = data['time']/10.
|
||||||
@@ -305,6 +306,11 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
|
|||||||
|
|
||||||
velo = totaldist/totaltime
|
velo = totaldist/totaltime
|
||||||
avgpower = 2.8*velo**(3.0)
|
avgpower = 2.8*velo**(3.0)
|
||||||
|
if workouttype in ['bike','bikeerg']:
|
||||||
|
velo = velo/2.
|
||||||
|
avgpower = 2.8*velo**(3.0)
|
||||||
|
velo = velo*2
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
restvelo = restdistance/resttime
|
restvelo = restdistance/resttime
|
||||||
@@ -312,6 +318,10 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
|
|||||||
restvelo = 0
|
restvelo = 0
|
||||||
|
|
||||||
restpower = 2.8*restvelo**(3.0)
|
restpower = 2.8*restvelo**(3.0)
|
||||||
|
if workouttype in ['bike','bikeerg']:
|
||||||
|
restvelo = restvelo/2.
|
||||||
|
restpower = 2.8*restvelo**(3.0)
|
||||||
|
restvelo = restvelo*2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
avgdps = totaldist/data['stroke_count']
|
avgdps = totaldist/data['stroke_count']
|
||||||
@@ -398,6 +408,8 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
|
|||||||
if itime != 0:
|
if itime != 0:
|
||||||
ivelo = idist/itime
|
ivelo = idist/itime
|
||||||
ipower = 2.8*ivelo**(3.0)
|
ipower = 2.8*ivelo**(3.0)
|
||||||
|
if workouttype in ['bike','bikeerg']:
|
||||||
|
ipower = 2.8*(ivelo/2.)**(3.0)
|
||||||
else:
|
else:
|
||||||
ivelo = 0
|
ivelo = 0
|
||||||
ipower = 0
|
ipower = 0
|
||||||
@@ -961,6 +973,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
thetimezone = 'UTC'
|
thetimezone = 'UTC'
|
||||||
|
|
||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rowdatetime = iso8601.parse_date(data['date_utc'])
|
rowdatetime = iso8601.parse_date(data['date_utc'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -969,6 +982,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
rowdatetime = iso8601.parse_date(data['date'])
|
rowdatetime = iso8601.parse_date(data['date'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
c2intervaltype = data['workout_type']
|
c2intervaltype = data['workout_type']
|
||||||
|
|
||||||
@@ -1090,10 +1104,18 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
dosummary=True,dosmooth=False,
|
dosummary=True,dosmooth=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
|
|
||||||
|
|
||||||
w.duration = dataprep.totaltime_sec_to_string(totaltime)
|
w.duration = dataprep.totaltime_sec_to_string(totaltime)
|
||||||
w.distance = totaldist
|
w.distance = totaldist
|
||||||
|
w.startdatetime = rowdatetime
|
||||||
|
w.starttime = rowdatetime.time()
|
||||||
|
w.date = rowdatetime.date()
|
||||||
|
|
||||||
w.save()
|
w.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return id,message
|
return id,message
|
||||||
|
|||||||
@@ -1129,7 +1129,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
|||||||
|
|
||||||
df = pd.DataFrame({
|
df = pd.DataFrame({
|
||||||
'TimeStamp (sec)': unixtime,
|
'TimeStamp (sec)': unixtime,
|
||||||
' Horizontal (meters)': d,
|
' Horizontal (meters)': d,
|
||||||
' Cadence (stokes/min)': spm,
|
' Cadence (stokes/min)': spm,
|
||||||
' Stroke500mPace (sec/500m)':pace,
|
' Stroke500mPace (sec/500m)':pace,
|
||||||
' ElapsedTime (sec)':elapsed,
|
' ElapsedTime (sec)':elapsed,
|
||||||
|
|||||||
@@ -1651,6 +1651,8 @@ def workout_getimportview(request,externalid,source = 'c2'):
|
|||||||
strokedata = res[1]
|
strokedata = res[1]
|
||||||
data = res[0]
|
data = res[0]
|
||||||
|
|
||||||
|
workouttype = mytypes.c2mappinginv[data['type']]
|
||||||
|
|
||||||
|
|
||||||
# Now works only for C2
|
# Now works only for C2
|
||||||
try:
|
try:
|
||||||
@@ -1736,7 +1738,7 @@ def workout_getimportview(request,externalid,source = 'c2'):
|
|||||||
|
|
||||||
# splitdata (only for C2)
|
# splitdata (only for C2)
|
||||||
if splitdata:
|
if splitdata:
|
||||||
w.summary,sa,results = c2stuff.summaryfromsplitdata(splitdata,data,w.csvfilename)
|
w.summary,sa,results = c2stuff.summaryfromsplitdata(splitdata,data,w.csvfilename,workouttype=workouttype)
|
||||||
w.save()
|
w.save()
|
||||||
|
|
||||||
from rowingdata.trainingparser import getlist
|
from rowingdata.trainingparser import getlist
|
||||||
|
|||||||
Reference in New Issue
Block a user