From 75ddb92349f084c8f99baacbf3da3c28a061aab5 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 27 Nov 2016 20:18:11 +0100 Subject: [PATCH] Fixed dataprep --- rowers/dataprep.py | 17 +++-------------- rowers/interactiveplots.py | 11 +++++------ rowers/models.py | 6 ++---- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 663abb26..04bef03e 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -85,7 +85,7 @@ def rdata(file,rower=rrower()): return res def delete_strokedata(id): - query = sa.text('DELETE FROM strokedata WHERE workoutid={id};'.format( + query = sa.text('DELETE FROM strokedata * WHERE workoutid={id};'.format( id=id, )) with engine.connect() as conn, conn.begin(): @@ -108,8 +108,6 @@ def getrowdata_db(id=0): # data['ergpace'] = data['ergpace']/1.0e6 # data['nowindpace'] = data['nowindpace']/1.0e6 # data['time'] = data['time']/1.0e6 - data['pace'] = data['pseconds']*1.0e3 - data['time'] = data['timesecs']*1.0e3 data['x_right'] = data['x_right']/1.0e6 if data.empty: rowdata,row = getrowdata(id=id) @@ -126,13 +124,6 @@ def getsmallrowdata_db(columns,ids=[]): prepmultipledata(ids) data = read_cols_df_sql(ids,columns) print columns - for column in columns: - if column == 'time': - data['time'] = data['timesecs']*1.0e3 - # data['time'] = data['time']/1.0e6 - if column == 'pace': - # data['pace'] = data['pace']/1.0e6 - data['pace'] = data['pseconds']*1.0e3 return data @@ -293,11 +284,9 @@ def dataprep(rowdatadf,id=0,bands=False,barchart=False,otwpower=False): data = DataFrame( dict( - time = t2, - timesecs = t, + time = t*1e3, hr = hr, - pace = p2, - pseconds=p, + pace = p*1e3, spm = spm, cumdist = cumdist, ftime = niceformat(t2), diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 2fce9318..fdb04045 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -929,10 +929,9 @@ def interactive_flex_chart2(id=0,promember=0, pass rowdata['x1'] = rowdata.ix[:,xparam] - rowdata['y1'] = rowdata.ix[:,yparam1] - - tseconds = rowdata.ix[:,'timesecs'] + + tseconds = rowdata.ix[:,'time'] if yparam2 != 'None': rowdata['y2'] = rowdata.ix[:,yparam2] @@ -940,8 +939,8 @@ def interactive_flex_chart2(id=0,promember=0, rowdata['y2'] = rowdata['y1'] if xparam=='time': - xaxmax = 1.0e3*tseconds.max() - xaxmin = 1.0e3*tseconds.min() + xaxmax = tseconds.max() + xaxmin = tseconds.min() elif xparam=='distance': xaxmax = rowdata['x1'].max() xaxmin = rowdata['x1'].min() @@ -975,7 +974,7 @@ def interactive_flex_chart2(id=0,promember=0, if yparam1 == 'pace': y_axis_type = 'datetime' - y1mean = rowdata.ix[:,'pseconds'].mean() + y1mean = rowdata.ix[:,'pace'].mean() rowdata['xname'] = xparam diff --git a/rowers/models.py b/rowers/models.py index 552d6440..d4c0c7d3 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -160,12 +160,10 @@ class StrokeData(models.Model): db_table = 'strokedata' workoutid = models.IntegerField(null=True) - time = models.TimeField(null=True) - timesecs = models.FloatField(null=True) + time = models.FloatField(null=True) hr = models.IntegerField(null=True) - pace = models.TimeField(null=True) + pace = models.FloatField(null=True) workoutstate = models.IntegerField(null=True,default=1) - pseconds = models.FloatField(null=True) spm = models.FloatField(null=True) cumdist = models.FloatField(null=True) ftime = models.CharField(max_length=30)