Merge branch 'release/flexpowerzonesbugfix'
This commit is contained in:
@@ -4,6 +4,7 @@ import time
|
|||||||
import gc
|
import gc
|
||||||
import gzip
|
import gzip
|
||||||
import shutil
|
import shutil
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
import rowingdata
|
import rowingdata
|
||||||
from rowingdata import main as rmain
|
from rowingdata import main as rmain
|
||||||
@@ -17,6 +18,8 @@ from matplotlib import figure
|
|||||||
|
|
||||||
import stravalib
|
import stravalib
|
||||||
|
|
||||||
|
from utils import serialize_list,deserialize_list
|
||||||
|
|
||||||
from rowers.dataprepnodjango import update_strokedata
|
from rowers.dataprepnodjango import update_strokedata
|
||||||
|
|
||||||
from django.core.mail import send_mail, BadHeaderError,EmailMessage
|
from django.core.mail import send_mail, BadHeaderError,EmailMessage
|
||||||
@@ -171,17 +174,22 @@ def handle_otwsetpower(f1,boattype,weightvalue,
|
|||||||
# This function generates all the static (PNG image) plots
|
# This function generates all the static (PNG image) plots
|
||||||
@app.task
|
@app.task
|
||||||
def handle_makeplot(f1,f2,t,hrdata,plotnr,imagename):
|
def handle_makeplot(f1,f2,t,hrdata,plotnr,imagename):
|
||||||
|
|
||||||
hrmax = hrdata['hrmax']
|
hrmax = hrdata['hrmax']
|
||||||
hrut2 = hrdata['hrut2']
|
hrut2 = hrdata['hrut2']
|
||||||
hrut1 = hrdata['hrut1']
|
hrut1 = hrdata['hrut1']
|
||||||
hrat = hrdata['hrat']
|
hrat = hrdata['hrat']
|
||||||
hrtr = hrdata['hrtr']
|
hrtr = hrdata['hrtr']
|
||||||
hran = hrdata['hran']
|
hran = hrdata['hran']
|
||||||
|
ftp = hrdata['ftp']
|
||||||
|
powerzones = deserialize_list(hrdata['powerzones'])
|
||||||
|
powerperc = np.array(deserialize_list(hrdata['powerperc'])).astype(int)
|
||||||
|
|
||||||
rr = rowingdata.rower(hrmax=hrmax,hrut2=hrut2,
|
rr = rowingdata.rower(hrmax=hrmax,hrut2=hrut2,
|
||||||
hrut1=hrut1,hrat=hrat,
|
hrut1=hrut1,hrat=hrat,
|
||||||
hrtr=hrtr,hran=hran)
|
hrtr=hrtr,hran=hran,
|
||||||
|
ftp=ftp,powerperc=powerperc,
|
||||||
|
powerzones=powerzones)
|
||||||
try:
|
try:
|
||||||
row = rdata(f2,rower=rr)
|
row = rdata(f2,rower=rr)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
|
|||||||
from time import strftime,strptime,mktime,time,daylight
|
from time import strftime,strptime,mktime,time,daylight
|
||||||
import os
|
import os
|
||||||
from rowers.tasks import handle_makeplot
|
from rowers.tasks import handle_makeplot
|
||||||
|
from rowers.utils import serialize_list,deserialize_list
|
||||||
from rowers.c2stuff import C2NoTokenError
|
from rowers.c2stuff import C2NoTokenError
|
||||||
|
|
||||||
from minimocktest import MockTestCase
|
from minimocktest import MockTestCase
|
||||||
@@ -1062,9 +1063,15 @@ class PlotTests(TestCase):
|
|||||||
duration="0:55:00",distance=8000,
|
duration="0:55:00",distance=8000,
|
||||||
csvfilename=filename)
|
csvfilename=filename)
|
||||||
|
|
||||||
# timestr = strftime("%Y%m%d-%H%M%S")
|
# timestr = strftime("%Y%m%d-%H%M%S")
|
||||||
# imagename = f1+timestr+'.png'
|
# imagename = f1+timestr+'.png'
|
||||||
# fullpathimagename = 'static/plots/'+imagename
|
# fullpathimagename = 'static/plots/'+imagename
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
self.hrdata = {
|
self.hrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -1073,7 +1080,9 @@ class PlotTests(TestCase):
|
|||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
'ftp':r.ftp,
|
'ftp':r.ftp,
|
||||||
}
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_ote_plots(self):
|
def test_ote_plots(self):
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
import math
|
import math
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def serialize_list(value,token=','):
|
||||||
|
assert(isinstance(value, list) or isinstance(value, tuple) or isinstance(value,np.ndarray))
|
||||||
|
return token.join([unicode(s) for s in value])
|
||||||
|
|
||||||
|
def deserialize_list(value,token=','):
|
||||||
|
if isinstance(value, list):
|
||||||
|
return value
|
||||||
|
return value.split(token)
|
||||||
|
|
||||||
def geo_distance(lat1,lon1,lat2,lon2):
|
def geo_distance(lat1,lon1,lat2,lon2):
|
||||||
""" Approximate distance and bearing between two points
|
""" Approximate distance and bearing between two points
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ def splitstdata(lijst):
|
|||||||
|
|
||||||
return [np.array(t),np.array(latlong)]
|
return [np.array(t),np.array(latlong)]
|
||||||
|
|
||||||
from utils import geo_distance
|
from utils import geo_distance,serialize_list,deserialize_list
|
||||||
|
|
||||||
# Check if a user is a Pro member
|
# Check if a user is a Pro member
|
||||||
def promember(user):
|
def promember(user):
|
||||||
@@ -3135,6 +3135,12 @@ def workout_add_otw_powerplot_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3143,6 +3149,8 @@ def workout_add_otw_powerplot_view(request,id):
|
|||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
'ftp':r.ftp,
|
'ftp':r.ftp,
|
||||||
|
'powerperc':powerperc,
|
||||||
|
'powerzones':r.powerzones,
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3180,6 +3188,13 @@ def workout_add_piechart_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3188,6 +3203,8 @@ def workout_add_piechart_view(request,id):
|
|||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
'ftp':r.ftp,
|
'ftp':r.ftp,
|
||||||
|
'powerperc':powerperc,
|
||||||
|
'powerzones':r.powerzones,
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3225,6 +3242,13 @@ def workout_add_power_piechart_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3233,6 +3257,8 @@ def workout_add_power_piechart_view(request,id):
|
|||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
'ftp':r.ftp,
|
'ftp':r.ftp,
|
||||||
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3268,6 +3294,12 @@ def workout_add_timeplot_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3276,6 +3308,8 @@ def workout_add_timeplot_view(request,id):
|
|||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
'ftp':r.ftp,
|
'ftp':r.ftp,
|
||||||
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3313,6 +3347,12 @@ def workout_add_distanceplot_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3321,6 +3361,8 @@ def workout_add_distanceplot_view(request,id):
|
|||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
'ftp':r.ftp,
|
'ftp':r.ftp,
|
||||||
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3356,6 +3398,12 @@ def workout_add_distanceplot2_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3363,6 +3411,9 @@ def workout_add_distanceplot2_view(request,id):
|
|||||||
'hrat':r.at,
|
'hrat':r.at,
|
||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
|
'ftp':r.ftp,
|
||||||
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3400,6 +3451,12 @@ def workout_add_timeplot2_view(request,id):
|
|||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
r = Rower.objects.get(user=u)
|
r = Rower.objects.get(user=u)
|
||||||
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
|
|
||||||
hrpwrdata = {
|
hrpwrdata = {
|
||||||
'hrmax':r.max,
|
'hrmax':r.max,
|
||||||
'hrut2':r.ut2,
|
'hrut2':r.ut2,
|
||||||
@@ -3407,6 +3464,9 @@ def workout_add_timeplot2_view(request,id):
|
|||||||
'hrat':r.at,
|
'hrat':r.at,
|
||||||
'hrtr':r.tr,
|
'hrtr':r.tr,
|
||||||
'hran':r.an,
|
'hran':r.an,
|
||||||
|
'ftp':r.ftp,
|
||||||
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
}
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
@@ -3856,7 +3916,6 @@ def workout_upload_view(request,message=""):
|
|||||||
r.pw_at,
|
r.pw_at,
|
||||||
r.pw_tr,r.pw_an])/r.ftp
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
|
||||||
print powerperc
|
|
||||||
rr = rrower(hrmax=r.max,hrut2=r.ut2,
|
rr = rrower(hrmax=r.max,hrut2=r.ut2,
|
||||||
hrut1=r.ut1,hrat=r.at,
|
hrut1=r.ut1,hrat=r.at,
|
||||||
hrtr=r.tr,hran=r.an,ftp=r.ftp,
|
hrtr=r.tr,hran=r.an,ftp=r.ftp,
|
||||||
@@ -3956,14 +4015,24 @@ def workout_upload_view(request,message=""):
|
|||||||
imagename = f1[:-4]+'.png'
|
imagename = f1[:-4]+'.png'
|
||||||
fullpathimagename = 'static/plots/'+imagename
|
fullpathimagename = 'static/plots/'+imagename
|
||||||
u = request.user
|
u = request.user
|
||||||
hrpwrdata = {
|
r = Rower.objects.get(user=request.user)
|
||||||
'hrmax':r.max,
|
powerperc = 100*np.array([r.pw_ut2,
|
||||||
'hrut2':r.ut2,
|
r.pw_ut1,
|
||||||
'hrut1':r.ut1,
|
r.pw_at,
|
||||||
'hrat':r.at,
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
'hrtr':r.tr,
|
|
||||||
'hran':r.an,
|
|
||||||
}
|
hrpwrdata = {
|
||||||
|
'hrmax':r.max,
|
||||||
|
'hrut2':r.ut2,
|
||||||
|
'hrut1':r.ut1,
|
||||||
|
'hrat':r.at,
|
||||||
|
'hrtr':r.tr,
|
||||||
|
'hran':r.an,
|
||||||
|
'ftp':r.ftp,
|
||||||
|
'powerperc':serialize_list(powerperc),
|
||||||
|
'powerzones':serialize_list(r.powerzones),
|
||||||
|
}
|
||||||
|
|
||||||
# make plot - asynchronous task
|
# make plot - asynchronous task
|
||||||
plotnrs = {
|
plotnrs = {
|
||||||
|
|||||||
Reference in New Issue
Block a user