import without stroke data now works
This commit is contained in:
@@ -131,6 +131,102 @@ def rdata(file,rower=rrower()):
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def totaltime_sec_to_string(totaltime):
|
||||
hours = int(totaltime / 3600.)
|
||||
if hours > 23:
|
||||
message = 'Warning: The workout duration was longer than 23 hours. '
|
||||
hours = 23
|
||||
|
||||
minutes = int((totaltime - 3600. * hours) / 60.)
|
||||
if minutes > 59:
|
||||
minutes = 59
|
||||
if not message:
|
||||
message = 'Warning: there is something wrong with the workout duration'
|
||||
|
||||
seconds = int(totaltime - 3600. * hours - 60. * minutes)
|
||||
if seconds > 59:
|
||||
seconds = 59
|
||||
if not message:
|
||||
message = 'Warning: there is something wrong with the workout duration'
|
||||
|
||||
tenths = int(10 * (totaltime - 3600. * hours - 60. * minutes - seconds))
|
||||
if tenths > 9:
|
||||
tenths = 9
|
||||
if not message:
|
||||
message = 'Warning: there is something wrong with the workout duration'
|
||||
|
||||
duration = "%s:%s:%s.%s" % (hours, minutes, seconds, tenths)
|
||||
|
||||
return duration
|
||||
|
||||
# Creates C2 stroke data
|
||||
def create_c2_stroke_data_db(
|
||||
distance,duration,workouttype,
|
||||
workoutid,starttimeunix,csvfilename,debug=False):
|
||||
|
||||
nr_strokes = int(distance/10.)
|
||||
|
||||
|
||||
totalseconds = duration.hour*3600.
|
||||
totalseconds += duration.minute*60.
|
||||
totalseconds += duration.second
|
||||
totalseconds += duration.microsecond/1.e6
|
||||
|
||||
|
||||
spm = 60.*nr_strokes/totalseconds
|
||||
|
||||
step = totalseconds/float(nr_strokes)
|
||||
|
||||
elapsed = np.arange(nr_strokes)*totalseconds/(float(nr_strokes-1))
|
||||
|
||||
dstep = distance/float(nr_strokes)
|
||||
|
||||
d = np.arange(nr_strokes)*distance/(float(nr_strokes-1))
|
||||
|
||||
unixtime = starttimeunix + elapsed
|
||||
|
||||
pace = 500.*totalseconds/distance
|
||||
|
||||
if workouttype in ['rower','slides','dynamic']:
|
||||
velo = distance/totalseconds
|
||||
power = 2.8*velo**3
|
||||
else:
|
||||
power = 0
|
||||
|
||||
|
||||
df = pd.DataFrame({
|
||||
'TimeStamp (sec)': unixtime,
|
||||
' Horizontal (meters)': d,
|
||||
' Cadence (stokes/min)': spm,
|
||||
' Stroke500mPace (sec/500m)':pace,
|
||||
' ElapsedTime (sec)':elapsed,
|
||||
' Power (watts)':power,
|
||||
' HRCur (bpm)':np.zeros(nr_strokes),
|
||||
' longitude':np.zeros(nr_strokes),
|
||||
' latitude':np.zeros(nr_strokes),
|
||||
' DragFactor':np.zeros(nr_strokes),
|
||||
' DriveLength (meters)':np.zeros(nr_strokes),
|
||||
' StrokeDistance (meters)':np.zeros(nr_strokes),
|
||||
' DriveTime (ms)':np.zeros(nr_strokes),
|
||||
' StrokeRecoveryTime (ms)':np.zeros(nr_strokes),
|
||||
' AverageDriveForce (lbs)':np.zeros(nr_strokes),
|
||||
' PeakDriveForce (lbs)':np.zeros(nr_strokes),
|
||||
' lapIdx':np.zeros(nr_strokes),
|
||||
'cum_dist': d
|
||||
})
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
||||
|
||||
res = df.to_csv(csvfilename,index_label='index',
|
||||
compression='gzip')
|
||||
|
||||
data = dataprep(df,id=workoutid,bands=False,debug=debug)
|
||||
|
||||
return data
|
||||
|
||||
# Saves C2 stroke data to CSV and database
|
||||
def add_c2_stroke_data_db(strokedata,workoutid,starttimeunix,csvfilename,
|
||||
debug=False):
|
||||
|
||||
Reference in New Issue
Block a user