Private
Public Access
1
0

all forces now in newton

This commit is contained in:
Sander Roosendaal
2017-04-26 11:26:04 +02:00
parent c2264857b5
commit a6cb3d5140
5 changed files with 34 additions and 9 deletions

View File

@@ -43,12 +43,15 @@ from sqlalchemy import create_engine
import sqlalchemy as sa import sqlalchemy as sa
import sys import sys
from utils import lbstoN
import django_rq import django_rq
queue = django_rq.get_queue('default') queue = django_rq.get_queue('default')
queuelow = django_rq.get_queue('low') queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('default') queuehigh = django_rq.get_queue('default')
user = settings.DATABASES['default']['USER'] user = settings.DATABASES['default']['USER']
password = settings.DATABASES['default']['PASSWORD'] password = settings.DATABASES['default']['PASSWORD']
database_name = settings.DATABASES['default']['NAME'] database_name = settings.DATABASES['default']['NAME']
@@ -825,6 +828,7 @@ def testdata(time,distance,pace,spm):
def getrowdata_db(id=0,doclean=False): def getrowdata_db(id=0,doclean=False):
data = read_df_sql(id) data = read_df_sql(id)
data['x_right'] = data['x_right']/1.0e6 data['x_right'] = data['x_right']/1.0e6
if data.empty: if data.empty:
rowdata,row = getrowdata(id=id) rowdata,row = getrowdata(id=id)
if rowdata: if rowdata:
@@ -837,12 +841,21 @@ 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']*lbstoN
data['peakforce'] = data['peakforce']*lbstoN
return data,row return data,row
# Fetch a subset of the data from the DB # Fetch a subset of the data from the DB
def getsmallrowdata_db(columns,ids=[],doclean=True,workstrokesonly=True): def getsmallrowdata_db(columns,ids=[],doclean=True,workstrokesonly=True):
prepmultipledata(ids) prepmultipledata(ids)
data = read_cols_df_sql(ids,columns) data = read_cols_df_sql(ids,columns)
if 'peakforce' in columns:
data['peakforce'] = data['peakforce']*lbstoN
if 'averageforce' in columns:
data['averageforce'] = data['averageforce']*lbstoN
if doclean: if doclean:
data = clean_df_stats(data,ignorehr=True, data = clean_df_stats(data,ignorehr=True,
workstrokesonly=workstrokesonly) workstrokesonly=workstrokesonly)
@@ -990,6 +1003,12 @@ def smalldataprep(therows,xparam,yparam1,yparam2):
except IOError: except IOError:
pass pass
try:
df['peakforce'] = df['peakforce']*lbstoN
df['averageforce'] = df['averageforce']*lbstoN
except KeyError:
pass
return df return df
# data fusion # data fusion
@@ -1100,7 +1119,7 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
drivespeed = 0.0*rowdatadf['TimeStamp (sec)'] drivespeed = 0.0*rowdatadf['TimeStamp (sec)']
drivespeed = drivespeed.fillna(value=0) drivespeed = drivespeed.fillna(value=0)
driveenergy = drivelength*averageforce*4.44822 driveenergy = drivelength*averageforce*lbstoN
distance = rowdatadf.ix[:,'cum_dist'] distance = rowdatadf.ix[:,'cum_dist']

View File

@@ -16,6 +16,8 @@ import sqlalchemy as sa
from rowsandall_app.settings import DATABASES from rowsandall_app.settings import DATABASES
from utils import lbstoN
user = DATABASES['default']['USER'] user = DATABASES['default']['USER']
password = DATABASES['default']['PASSWORD'] password = DATABASES['default']['PASSWORD']
database_name = DATABASES['default']['NAME'] database_name = DATABASES['default']['NAME']
@@ -595,7 +597,7 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
drivespeed = drivelength/rowdatadf[' DriveTime (ms)']*1.0e3 drivespeed = drivelength/rowdatadf[' DriveTime (ms)']*1.0e3
drivespeed = drivespeed.fillna(value=0) drivespeed = drivespeed.fillna(value=0)
driveenergy = drivelength*averageforce*4.44822 driveenergy = drivelength*averageforce*lbstoN
distance = rowdatadf.ix[:,'cum_dist'] distance = rowdatadf.ix[:,'cum_dist']

View File

@@ -52,6 +52,8 @@ import rowers.dataprep as dataprep
from rowers.metrics import axes,axlabels,yaxminima,yaxmaxima from rowers.metrics import axes,axlabels,yaxminima,yaxmaxima
from utils import lbstoN
def tailwind(bearing,vwind,winddir): def tailwind(bearing,vwind,winddir):
""" Calculates head-on head/tailwind in direction of rowing """ Calculates head-on head/tailwind in direction of rowing
@@ -140,7 +142,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
finishav] finishav]
thresholdforce = 100 if 'x' in boattype else 200 thresholdforce = 100 if 'x' in boattype else 200
thresholdforce /= 4.45 # N to lbs #thresholdforce /= 4.45 # N to lbs
y = [0,thresholdforce, y = [0,thresholdforce,
peakforceav, peakforceav,
thresholdforce,0] thresholdforce,0]
@@ -217,11 +219,11 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
plot.add_layout(finishlabel) plot.add_layout(finishlabel)
plot.xaxis.axis_label = "Angle" plot.xaxis.axis_label = "Angle"
plot.yaxis.axis_label = "Force (lbs)" plot.yaxis.axis_label = "Force (N)"
plot.title.text = theworkouts[0].name plot.title.text = theworkouts[0].name
plot.title.text_font_size=value("1.0em") plot.title.text_font_size=value("1.0em")
yrange1 = Range1d(start=0,end=200) yrange1 = Range1d(start=0,end=900)
plot.y_range = yrange1 plot.y_range = yrange1
xrange1 = Range1d(start=yaxmaxima['catch'],end=yaxmaxima['finish']) xrange1 = Range1d(start=yaxmaxima['catch'],end=yaxmaxima['finish'])

View File

@@ -1,3 +1,5 @@
from utils import lbstoN
axes = ( axes = (
('time','Time',0,1e5,'basic'), ('time','Time',0,1e5,'basic'),
('distance', 'Distance (m)',0,1e5,'basic'), ('distance', 'Distance (m)',0,1e5,'basic'),
@@ -6,9 +8,9 @@ axes = (
('spm', 'Stroke Rate (spm)',15,45,'basic'), ('spm', 'Stroke Rate (spm)',15,45,'basic'),
('pace', 'Pace (/500m)',1.0e3*210,1.0e3*75,'basic'), ('pace', 'Pace (/500m)',1.0e3*210,1.0e3*75,'basic'),
('power', 'Power (Watt)',0,600,'basic'), ('power', 'Power (Watt)',0,600,'basic'),
('averageforce', 'Average Drive Force (lbs)',0,200,'pro'), ('averageforce', 'Average Drive Force (N)',0,900,'pro'),
('drivelength', 'Drive Length (m)',0.5,2.0,'pro'), ('drivelength', 'Drive Length (m)',0.5,2.0,'pro'),
('peakforce', 'Peak Drive Force (lbs)',0,400,'pro'), ('peakforce', 'Peak Drive Force (N)',0,900,'pro'),
('forceratio', 'Average/Peak Force Ratio',0,1,'pro'), ('forceratio', 'Average/Peak Force Ratio',0,1,'pro'),
('driveenergy', 'Work per Stroke (J)',0,1000,'pro'), ('driveenergy', 'Work per Stroke (J)',0,1000,'pro'),
('drivespeed', 'Drive Speed (m/s)',0,4,'pro'), ('drivespeed', 'Drive Speed (m/s)',0,4,'pro'),

View File

@@ -1,7 +1,7 @@
import math import math
import numpy as np import numpy as np
lbstoN = 4.44822
def serialize_list(value,token=','): def serialize_list(value,token=','):
assert(isinstance(value, list) or isinstance(value, tuple) or isinstance(value,np.ndarray)) assert(isinstance(value, list) or isinstance(value, tuple) or isinstance(value,np.ndarray))