Private
Public Access
1
0

videodata working

This commit is contained in:
Sander Roosendaal
2019-11-13 21:42:29 +01:00
parent 6a597e43b3
commit c8d84c4aab
3 changed files with 50 additions and 31 deletions

View File

@@ -10,6 +10,7 @@ from __future__ import unicode_literals, absolute_import
from rowers.models import Workout, Team
import pytz
import collections
from rowingdata import rowingdata as rrdata
@@ -122,24 +123,35 @@ from scipy.signal import savgol_filter
import datetime
def get_video_data(w):
df = getsmallrowdata_db(['time','velo','spm','catch'],ids=[w.id],
workstrokesonly=False,doclean=False,compute=False)
def get_video_data(w,groups=['basic']):
columns = ['time','velo','spm']
columns += [name for name,d in rowingmetrics if d['group'] in groups]
columns = list(set(columns))
df = getsmallrowdata_db(columns,ids=[w.id],
workstrokesonly=False,doclean=False,compute=False)
df['time'] = (df['time']-df['time'].min())/1000.
df.sort_values(by='time',inplace=True)
df.set_index(pd.to_timedelta(df['time'],unit='s'),inplace=True)
df2 = df.resample('1s').mean().interpolate()
if 'pace' in columns:
df2['pace'] = df2['pace']/1000.
p = df2['pace']
p = p.apply(lambda x:timedeltaconv(x))
p = nicepaceformat(p)
df2['pace'] = p
#mask = df2['time'] < delay
#df2 = df2.mask(mask).dropna()
df2['time'] = (df2['time']-df2['time'].min())
df2 = df2.round(decimals=2)
boatspeed = (100*df2['velo']).astype(int)/100.
spm = (10*df2['spm']).astype(int)/10.
catch = (10*df2['catch']).astype(int)/10.
coordinates = get_latlon_time(w.id)
@@ -155,32 +167,36 @@ def get_video_data(w):
# bundle data
data = {
'boatspeed':[ v for v in boatspeed.values],
'latitude':[ l for l in latitude.values],
'longitude':[ l for l in longitude.values],
'spm':[ s for s in spm.values ],
'catch': [c for c in catch.values]
'boatspeed':boatspeed.values.tolist(),
'latitude':latitude.values.tolist(),
'longitude':longitude.values.tolist(),
}
# metrics = {
# 'boatspeed': {
# 'unit': 'm/s',
# 'metric': 'boatspeed',
# 'name': 'Boat Speed'
# },
# }
metrics = {}
for c in columns:
if c != 'time':
data[c] = df2[c].values.tolist()
metrics[c] = {
'name': dict(rowingmetrics)[c]['verbose_name'],
'metric': c,
'unit': ''
}
metrics['boatspeed'] = metrics.pop('velo')
# metrics['workperstroke'] = metrics.pop('driveenergy')
metrics = collections.OrderedDict(sorted(metrics.items()))
maxtime = coordinates['time'].max()
metrics = {
'spm': {
'unit': '',
'metric': 'spm',
'name': 'SPM',
},
'boatspeed': {
'unit': 'm/s',
'metric': 'boatspeed',
'name': 'Boat Speed'
},
'catch': {
'unit': 'degrees',
'metric': 'catch',
'name': 'Catch Angle'
}
}
return data, metrics, maxtime