Merge branch 'release/v7.49'
This commit is contained in:
+10
-3
@@ -56,7 +56,8 @@ def c2_open(user):
|
|||||||
|
|
||||||
return thetoken
|
return thetoken
|
||||||
|
|
||||||
def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename):
|
def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename,
|
||||||
|
workouttype='rower'):
|
||||||
r = Rower.objects.get(user=user)
|
r = Rower.objects.get(user=user)
|
||||||
if (r.c2token == '') or (r.c2token is None):
|
if (r.c2token == '') or (r.c2token is None):
|
||||||
return custom_exception_handler(401,s)
|
return custom_exception_handler(401,s)
|
||||||
@@ -73,7 +74,7 @@ def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename):
|
|||||||
c2id,
|
c2id,
|
||||||
workoutid,
|
workoutid,
|
||||||
starttimeunix,
|
starttimeunix,
|
||||||
csvfilename)
|
csvfilename,workouttype=workouttype)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -164,7 +165,8 @@ def create_async_workout(alldata,user,c2id):
|
|||||||
|
|
||||||
# Check if workout has stroke data, and get the stroke data
|
# Check if workout has stroke data, and get the stroke data
|
||||||
|
|
||||||
result = add_stroke_data(user,c2id,w.id,startdatetime,csvfilename)
|
result = add_stroke_data(user,c2id,w.id,startdatetime,csvfilename,
|
||||||
|
workouttype = w.workouttype)
|
||||||
|
|
||||||
return w.id
|
return w.id
|
||||||
|
|
||||||
@@ -392,6 +394,8 @@ def createc2workoutdata(w):
|
|||||||
d[0] = d[1]
|
d[0] = d[1]
|
||||||
p = abs(10*row.df.ix[:,' Stroke500mPace (sec/500m)'].values)
|
p = abs(10*row.df.ix[:,' Stroke500mPace (sec/500m)'].values)
|
||||||
p = np.clip(p,0,3600)
|
p = np.clip(p,0,3600)
|
||||||
|
if w.workouttype == 'bike':
|
||||||
|
p = 2.0*p
|
||||||
t = t.astype(int)
|
t = t.astype(int)
|
||||||
d = d.astype(int)
|
d = d.astype(int)
|
||||||
p = p.astype(int)
|
p = p.astype(int)
|
||||||
@@ -830,6 +834,9 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
pace = pace.replace(0,300)
|
pace = pace.replace(0,300)
|
||||||
|
|
||||||
velo = 500./pace
|
velo = 500./pace
|
||||||
|
if workouttype == 'bike':
|
||||||
|
velo = 1000./pace
|
||||||
|
pace = 500./velo
|
||||||
|
|
||||||
power = 2.8*velo**3
|
power = 2.8*velo**3
|
||||||
|
|
||||||
|
|||||||
@@ -871,8 +871,6 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
# auto smoothing
|
# auto smoothing
|
||||||
pace = row.df[' Stroke500mPace (sec/500m)'].values
|
pace = row.df[' Stroke500mPace (sec/500m)'].values
|
||||||
velo = 500. / pace
|
velo = 500. / pace
|
||||||
if workouttype == 'bikeerg':
|
|
||||||
velo = 1000. / pace
|
|
||||||
|
|
||||||
f = row.df['TimeStamp (sec)'].diff().mean()
|
f = row.df['TimeStamp (sec)'].diff().mean()
|
||||||
if f != 0 and not np.isnan(f):
|
if f != 0 and not np.isnan(f):
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ def create_c2_stroke_data_db(
|
|||||||
|
|
||||||
# Saves C2 stroke data to CSV and database
|
# Saves C2 stroke data to CSV and database
|
||||||
def add_c2_stroke_data_db(strokedata,workoutid,starttimeunix,csvfilename,
|
def add_c2_stroke_data_db(strokedata,workoutid,starttimeunix,csvfilename,
|
||||||
debug=False):
|
debug=False,workouttype='rower'):
|
||||||
|
|
||||||
res = make_cumvalues(0.1*strokedata['t'])
|
res = make_cumvalues(0.1*strokedata['t'])
|
||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
@@ -246,7 +246,10 @@ def add_c2_stroke_data_db(strokedata,workoutid,starttimeunix,csvfilename,
|
|||||||
pace = pace.replace(0,300)
|
pace = pace.replace(0,300)
|
||||||
|
|
||||||
velo = 500./pace
|
velo = 500./pace
|
||||||
|
if workouttype == 'bike':
|
||||||
|
velo = 1000./pace
|
||||||
|
|
||||||
|
# This may be wrong for the bike erg
|
||||||
power = 2.8*velo**3
|
power = 2.8*velo**3
|
||||||
|
|
||||||
# save csv
|
# save csv
|
||||||
|
|||||||
+3
-1
@@ -3,6 +3,9 @@ import numpy as np
|
|||||||
from scipy.interpolate import griddata
|
from scipy.interpolate import griddata
|
||||||
from scipy import optimize
|
from scipy import optimize
|
||||||
|
|
||||||
|
#p0 = [500,350,10,8000]
|
||||||
|
p0 = [190,200,33,16000]
|
||||||
|
|
||||||
def updatecp(delta,cpvalues,r):
|
def updatecp(delta,cpvalues,r):
|
||||||
cp2 = r.p0/(1+delta/r.p2)
|
cp2 = r.p0/(1+delta/r.p2)
|
||||||
cp2 += r.p1/(1+delta/r.p3)
|
cp2 += r.p1/(1+delta/r.p3)
|
||||||
@@ -38,7 +41,6 @@ def cpfit(powerdf):
|
|||||||
fitfunc = lambda pars,x: abs(pars[0])/(1+(x/abs(pars[2]))) + abs(pars[1])/(1+(x/abs(pars[3])))
|
fitfunc = lambda pars,x: abs(pars[0])/(1+(x/abs(pars[2]))) + abs(pars[1])/(1+(x/abs(pars[3])))
|
||||||
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
||||||
|
|
||||||
p0 = [500,350,10,8000]
|
|
||||||
|
|
||||||
p1 = p0
|
p1 = p0
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ import rowers.metrics as metrics
|
|||||||
from rowers.metrics import axes,axlabels,yaxminima,yaxmaxima
|
from rowers.metrics import axes,axlabels,yaxminima,yaxmaxima
|
||||||
|
|
||||||
from utils import lbstoN
|
from utils import lbstoN
|
||||||
|
from datautils import p0
|
||||||
import datautils
|
import datautils
|
||||||
|
|
||||||
watermarkurl = "/static/img/logo7.png"
|
watermarkurl = "/static/img/logo7.png"
|
||||||
@@ -1409,7 +1410,7 @@ def interactive_agegroupcpchart(age,normalized=False):
|
|||||||
fitfunc = lambda pars,x: pars[0]/(1+(x/pars[2])) + pars[1]/(1+(x/pars[3]))
|
fitfunc = lambda pars,x: pars[0]/(1+(x/pars[2])) + pars[1]/(1+(x/pars[3]))
|
||||||
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
||||||
|
|
||||||
p0 = [500,350,10,8000]
|
# p0 = [500,350,10,8000]
|
||||||
|
|
||||||
# fitting WC data to three parameter CP model
|
# fitting WC data to three parameter CP model
|
||||||
if len(fhduration)>=4:
|
if len(fhduration)>=4:
|
||||||
@@ -1640,9 +1641,9 @@ def interactive_agegroup_plot(df,distance=2000,duration=None,
|
|||||||
fitfunc = lambda pars, x: np.abs(pars[0])*(1-x/max(120,pars[1]))-np.abs(pars[2])*np.exp(-x/np.abs(pars[3]))+np.abs(pars[4])*(np.sin(np.pi*x/max(50,pars[5])))
|
fitfunc = lambda pars, x: np.abs(pars[0])*(1-x/max(120,pars[1]))-np.abs(pars[2])*np.exp(-x/np.abs(pars[3]))+np.abs(pars[4])*(np.sin(np.pi*x/max(50,pars[5])))
|
||||||
errfunc = lambda pars, x,y: fitfunc(pars,x)-y
|
errfunc = lambda pars, x,y: fitfunc(pars,x)-y
|
||||||
|
|
||||||
p0 = [700,120,700,10,100,100]
|
p0age = [700,120,700,10,100,100]
|
||||||
|
|
||||||
p1, success = optimize.leastsq(errfunc,p0[:],
|
p1, success = optimize.leastsq(errfunc,p0age[:],
|
||||||
args = (age,power))
|
args = (age,power))
|
||||||
|
|
||||||
expo_vals = fitfunc(p1, age2)
|
expo_vals = fitfunc(p1, age2)
|
||||||
@@ -1755,7 +1756,7 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
|
|||||||
fitfunc = lambda pars,x: pars[0]/(1+(x/pars[2])) + pars[1]/(1+(x/pars[3]))
|
fitfunc = lambda pars,x: pars[0]/(1+(x/pars[2])) + pars[1]/(1+(x/pars[3]))
|
||||||
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
||||||
|
|
||||||
p0 = [500,350,10,8000]
|
# p0 = [500,350,10,8000]
|
||||||
wcpower = pd.Series(wcpower)
|
wcpower = pd.Series(wcpower)
|
||||||
wcdurations = pd.Series(wcdurations)
|
wcdurations = pd.Series(wcdurations)
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -90,6 +90,11 @@ def handle_c2_import_stroke_data(c2token,
|
|||||||
starttimeunix,
|
starttimeunix,
|
||||||
csvfilename,debug=True,**kwargs):
|
csvfilename,debug=True,**kwargs):
|
||||||
|
|
||||||
|
if 'workouttype' in kwargs:
|
||||||
|
workouttype = kwargs['workouttype']
|
||||||
|
else:
|
||||||
|
workouttype = 'rower'
|
||||||
|
|
||||||
authorizationstring = str('Bearer ' + c2token)
|
authorizationstring = str('Bearer ' + c2token)
|
||||||
headers = {'Authorization': authorizationstring,
|
headers = {'Authorization': authorizationstring,
|
||||||
'user-agent': 'sanderroosendaal',
|
'user-agent': 'sanderroosendaal',
|
||||||
@@ -100,7 +105,7 @@ def handle_c2_import_stroke_data(c2token,
|
|||||||
strokedata = pd.DataFrame.from_dict(s.json()['data'])
|
strokedata = pd.DataFrame.from_dict(s.json()['data'])
|
||||||
result = add_c2_stroke_data_db(
|
result = add_c2_stroke_data_db(
|
||||||
strokedata,workoutid,starttimeunix,
|
strokedata,workoutid,starttimeunix,
|
||||||
csvfilename,debug=debug,
|
csvfilename,debug=debug,workouttype=workouttype
|
||||||
)
|
)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ $( document ).ready(function() {
|
|||||||
|| $(this).val() == 'dynamic'
|
|| $(this).val() == 'dynamic'
|
||||||
|| $(this).val() == 'slides'
|
|| $(this).val() == 'slides'
|
||||||
|| $(this).val() == 'paddle'
|
|| $(this).val() == 'paddle'
|
||||||
|
|| $(this).val() == 'bike'
|
||||||
|| $(this).val() == 'snow'
|
|| $(this).val() == 'snow'
|
||||||
) {
|
) {
|
||||||
$('#id_boattype').toggle(false);
|
$('#id_boattype').toggle(false);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ $( document ).ready(function() {
|
|||||||
|| $(this).val() == 'dynamic'
|
|| $(this).val() == 'dynamic'
|
||||||
|| $(this).val() == 'slides'
|
|| $(this).val() == 'slides'
|
||||||
|| $(this).val() == 'paddle'
|
|| $(this).val() == 'paddle'
|
||||||
|
|| $(this).val() == 'bike'
|
||||||
|| $(this).val() == 'snow'
|
|| $(this).val() == 'snow'
|
||||||
) {
|
) {
|
||||||
$('#id_boattype').toggle(false);
|
$('#id_boattype').toggle(false);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ $( document ).ready(function() {
|
|||||||
|| $(this).val() == 'slides'
|
|| $(this).val() == 'slides'
|
||||||
|| $(this).val() == 'paddle'
|
|| $(this).val() == 'paddle'
|
||||||
|| $(this).val() == 'snow'
|
|| $(this).val() == 'snow'
|
||||||
|
|| $(this).val() == 'bike'
|
||||||
) {
|
) {
|
||||||
$('#id_boattype').toggle(false);
|
$('#id_boattype').toggle(false);
|
||||||
$('#id_boattype').val('1x');
|
$('#id_boattype').val('1x');
|
||||||
|
|||||||
+1
-1
@@ -9757,7 +9757,7 @@ def workout_getimportview(request,externalid,source = 'c2'):
|
|||||||
w = Workout.objects.get(id=id)
|
w = Workout.objects.get(id=id)
|
||||||
w.uploadedtoc2 = c2id
|
w.uploadedtoc2 = c2id
|
||||||
w.name = 'Imported from C2'
|
w.name = 'Imported from C2'
|
||||||
w.workouttype = 'rower'
|
w.workouttype = workouttype
|
||||||
w.save()
|
w.save()
|
||||||
|
|
||||||
message = "This workout does not have any stroke data associated with it. We created synthetic stroke data."
|
message = "This workout does not have any stroke data associated with it. We created synthetic stroke data."
|
||||||
|
|||||||
Reference in New Issue
Block a user