Private
Public Access
1
0

adding splits to C2 workout export

This commit is contained in:
Sander Roosendaal
2019-10-31 11:45:44 +01:00
parent 102efa2cf2
commit d4f311c612

View File

@@ -467,7 +467,7 @@ def createc2workoutdata_as_splits(w):
def createc2workoutdata(w): def createc2workoutdata(w):
filename = w.csvfilename filename = w.csvfilename
try: try:
row = rowingdata(filename) row = rowingdata(csvfile=filename)
except IOError: except IOError:
return 0 return 0
@@ -478,6 +478,32 @@ def createc2workoutdata(w):
averagehr = 0 averagehr = 0
maxhr = 0 maxhr = 0
# Calculate intervalstats
itime, idist, itype = row.intervalstats_values()
lapnames = row.df[' lapIdx'].unique()
nrintervals = len(itime)
if len(lapnames != nrintervals):
newlapnames = []
for name in lapnames:
newlapnames += [name,name]
lapnames = newlapnames
intervaldata = []
for i in range(nrintervals):
if itime[i]>0:
mask = (row.df[' lapIdx'] == lapnames[i]) & (row.df[' WorkoutState'] == itype[i])
spmav = int(row.df[' Cadence (stokes/min)'][mask].mean().astype(int))
hrav = int(row.df[' HRCur (bpm)'][mask].mean().astype(int))
intervaldict = {
'type': 'distance',
'time': int(10*itime[i]),
'distance': int(idist[i]),
'heart_rate': {
'average':hrav,
},
'stroke_rate': spmav,
}
intervaldata.append(intervaldict)
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
t = 10*row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.loc[:,'TimeStamp (sec)'].iloc[0] t = 10*row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.loc[:,'TimeStamp (sec)'].iloc[0]
try: try:
@@ -547,13 +573,17 @@ def createc2workoutdata(w):
"time": int(10*makeseconds(durationstr)), "time": int(10*makeseconds(durationstr)),
"weight_class": c2wc(w.weightcategory), "weight_class": c2wc(w.weightcategory),
"comments": w.notes, "comments": w.notes,
'stroke_rate': int(row.df[' Cadence (stokes/min)'].mean()),
'drag_factor': int(row.dragfactor),
"heart_rate": { "heart_rate": {
"average": averagehr, "average": averagehr,
"max": maxhr, "max": maxhr,
}, },
"stroke_data": stroke_data, "stroke_data": stroke_data,
'workout': {
'splits': intervaldata,
}
} }
return data return data