Private
Public Access
1
0

Merge branch 'release/v3.30'

This commit is contained in:
Sander Roosendaal
2017-07-03 22:17:10 +02:00
8 changed files with 204 additions and 150 deletions
+6 -3
View File
@@ -428,7 +428,8 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
isbreakthrough = False isbreakthrough = False
if workouttype == 'water': if workouttype == 'water':
delta,cpvalues,avgpower = datautils.getsinglecp(row.df) delta,cpvalues,avgpower = datautils.getsinglecp(row.df)
if utils.isbreakthrough(delta,cpvalues,r.p0,r.p1,r.p2,r.p3,r.cpratio): res,btvalues = utils.isbreakthrough(delta,cpvalues,r.p0,r.p1,r.p2,r.p3,r.cpratio)
if res:
isbreakthrough = True isbreakthrough = True
res = datautils.updatecp(delta,cpvalues,r) res = datautils.updatecp(delta,cpvalues,r)
@@ -595,14 +596,16 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
if settings.DEBUG and r.getemailnotifications: if settings.DEBUG and r.getemailnotifications:
res = handle_sendemail_breakthrough.delay(w.id,r.user.email, res = handle_sendemail_breakthrough.delay(w.id,r.user.email,
r.user.first_name, r.user.first_name,
r.user.last_name) r.user.last_name,
btvalues=btvalues.to_json())
elif r.getemailnotifications: elif r.getemailnotifications:
try: try:
res = queuehigh.enqueue( res = queuehigh.enqueue(
handle_sendemail_breakthrough(w.id, handle_sendemail_breakthrough(w.id,
r.user.email, r.user.email,
r.user.first_name, r.user.first_name,
r.user.last_name)) r.user.last_name,
btvalues=btvalues.to_json()))
except AttributeError: except AttributeError:
pass pass
else: else:
+3 -4
View File
@@ -77,8 +77,8 @@ def cpfit(powerdf):
def getlogarr(maxt): def getlogarr(maxt):
maxlog10 = np.log10(maxt-5) maxlog10 = np.log10(maxt-5)
logarr = np.log10(5.)+np.arange(50)*maxlog10/50. logarr = np.arange(50)*maxlog10/50.
logarr = [int(10.**(la)) for la in logarr] logarr = [5+int(10.**(la)) for la in logarr]
logarr = pd.Series(logarr) logarr = pd.Series(logarr)
logarr.drop_duplicates(keep='first',inplace=True) logarr.drop_duplicates(keep='first',inplace=True)
@@ -88,7 +88,7 @@ def getlogarr(maxt):
def getsinglecp(df): def getsinglecp(df):
thesecs = df['TimeStamp (sec)'].max()-df['TimeStamp (sec)'].min() thesecs = df['TimeStamp (sec)'].max()-df['TimeStamp (sec)'].min()
if thesecs != 0: if thesecs != 0:
maxt = 2*thesecs maxt = 1.05*thesecs
else: else:
maxt = 1000. maxt = 1000.
@@ -152,7 +152,6 @@ def getcp(dfgrouped,logarr):
dt = pd.Series(dt) dt = pd.Series(dt)
cpw = pd.Series(cpw) cpw = pd.Series(cpw)
if len(dt): if len(dt):
cpvalues = griddata(dt.values, cpvalues = griddata(dt.values,
cpw.values, cpw.values,
logarr,method='linear', logarr,method='linear',
+29 -4
View File
@@ -18,6 +18,7 @@ import matplotlib.pyplot as plt
from matplotlib import figure from matplotlib import figure
import stravalib import stravalib
import pandas as pd
from django_rq import job from django_rq import job
@@ -49,7 +50,9 @@ def handle_new_workout_from_file(r,f2,
# send email when a breakthrough workout is uploaded # send email when a breakthrough workout is uploaded
@app.task @app.task
def handle_sendemail_breakthrough(workoutid,useremail,userfirstname,userlastname): def handle_sendemail_breakthrough(workoutid,useremail,
userfirstname,userlastname,
btvalues = pd.DataFrame().to_json()):
# send email with attachment # send email with attachment
subject = "A breakthrough workout on rowsandall.com" subject = "A breakthrough workout on rowsandall.com"
@@ -60,7 +63,7 @@ def handle_sendemail_breakthrough(workoutid,useremail,userfirstname,userlastname
message += " Critical Power (CP) is the power that you can " message += " Critical Power (CP) is the power that you can "
message += "sustain for a given duration. For more, see this " message += "sustain for a given duration. For more, see this "
message += " article in the analytics blog:\n\n" message += " article in the analytics blog:\n\n"
message += " [link to article to be written]\n\n" message += " http://analytics.rowsandall.com/2017/06/17/how-do-we-calculate-critical-power/ \n\n"
message += "Link to the workout http://rowsandall.com/rowers/workout/" message += "Link to the workout http://rowsandall.com/rowers/workout/"
message += str(workoutid) message += str(workoutid)
message +="/edit\n\n" message +="/edit\n\n"
@@ -69,6 +72,27 @@ def handle_sendemail_breakthrough(workoutid,useremail,userfirstname,userlastname
message += str(workoutid) message += str(workoutid)
message += "/updatecp\n\n" message += "/updatecp\n\n"
btvalues = pd.read_json(btvalues)
btvalues.sort_values('delta',axis=0,inplace=True)
if not btvalues.empty:
message += "These were the breakthrough values:\n"
for t in btvalues.itertuples():
delta = t.delta
cpvalue = t.cpvalues
pwr = t.pwr
message += "Time: {delta} seconds\n".format(
delta=delta
)
message += "New: {cpvalue:.0f} Watt\n".format(
cpvalue=cpvalue
)
message += "Old: {pwr:.0f} Watt\n\n".format(
pwr=pwr
)
message += "To opt out of these email notifications, deselect the checkbox on your Profile page under Account Information.\n\n" message += "To opt out of these email notifications, deselect the checkbox on your Profile page under Account Information.\n\n"
message += "Best Regards, the Rowsandall Team" message += "Best Regards, the Rowsandall Team"
@@ -222,10 +246,11 @@ def handle_otwsetpower(f1,boattype,weightvalue,
update_strokedata(workoutid,rowdata.df,debug=debug) update_strokedata(workoutid,rowdata.df,debug=debug)
delta,cpvalues,avgpower = datautils.getsinglecp(rowdata.df) delta,cpvalues,avgpower = datautils.getsinglecp(rowdata.df)
if utils.isbreakthrough(delta,cpvalues,ps[0],ps[1],ps[2],ps[3],ratio): res,btvalues = utils.isbreakthrough(delta,cpvalues,ps[0],ps[1],ps[2],ps[3],ratio)
if res:
handle_sendemail_breakthrough(workoutid,email, handle_sendemail_breakthrough(workoutid,email,
first_name, first_name,
last_name) last_name,btvalues=btvalues.to_json())
# send email # send email
fullemail = first_name + " " + last_name + " " + "<" + email + ">" fullemail = first_name + " " + last_name + " " + "<" + email + ">"
+9 -1
View File
@@ -7,8 +7,10 @@
{% block content %} {% block content %}
<div id="workouts" class="grid_6 alpha"> <div id="workouts" class="grid_6 alpha">
<div class="grid_6 alpha">
<h1>Stream Editor</h1> <h1>Stream Editor</h1>
</div>
<div class="grid_6 alpha">
<div class="grid_2 alpha"> <div class="grid_2 alpha">
<p> <p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a> <a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
@@ -25,6 +27,12 @@
<span class="tooltiptext">Run calculations to get power values for your row.</span> <span class="tooltiptext">Run calculations to get power values for your row.</span>
</div> </div>
</div>
<div class="grid_6 alpha">
<div class="grid_2 prefix_4 alpha">
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/wind">Wind Edit</a></p>
</div>
</div>
<div class="grid_6 alpha"> <div class="grid_6 alpha">
<p> <p>
Edit river Stream between turning points in your row. Edit river Stream between turning points in your row.
+9 -1
View File
@@ -6,8 +6,10 @@
{% block content %} {% block content %}
<div id="workouts" class="grid_6 alpha"> <div id="workouts" class="grid_6 alpha">
<div class="grid_6 alpha">
<h1>Wind Editor</h1> <h1>Wind Editor</h1>
</div>
<div class="grid_6 alpha">
<div class="grid_2 alpha"> <div class="grid_2 alpha">
<p> <p>
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a> <a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
@@ -24,6 +26,12 @@
<span class="tooltiptext">Run calculations to get power values for your row.</span> <span class="tooltiptext">Run calculations to get power values for your row.</span>
</div> </div>
</div>
<div class="grid_6 alpha">
<div class="grid_2 prefix_4 alpha">
<p><a class="button blue small" href="/rowers/workout/{{ workout.id }}/stream">Stream Edit</a></p>
</div>
</div>
<div class="grid_6 alpha"> <div class="grid_6 alpha">
<p> <p>
Update wind between distance 1 and distance 2. Submit wind strength Update wind between distance 1 and distance 2. Submit wind strength
+13 -3
View File
@@ -1,6 +1,6 @@
import math import math
import numpy as np import numpy as np
import pandas as pd
lbstoN = 4.44822 lbstoN = 4.44822
@@ -77,7 +77,6 @@ def geo_distance(lat1,lon1,lat2,lon2):
def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio): def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio):
pwr = p0/(1+delta/p2) pwr = p0/(1+delta/p2)
pwr += p1/(1+delta/p3) pwr += p1/(1+delta/p3)
@@ -85,4 +84,15 @@ def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio):
res = np.sum(cpvalues>pwr) res = np.sum(cpvalues>pwr)
return res>1 btdf = pd.DataFrame(
{
'delta':delta[cpvalues>pwr],
'cpvalues':cpvalues[cpvalues>pwr],
'pwr':pwr[cpvalues>pwr],
}
)
btdf.sort_values('delta',axis=0,inplace=True)
return res>1,btdf
+3 -2
View File
@@ -4403,8 +4403,9 @@ def workout_otwsetpower_view(request,id=0,message="",successmessage=""):
rowdata.write_csv(f1,gzip=True) rowdata.write_csv(f1,gzip=True)
# do power calculation (asynchronous) # do power calculation (asynchronous)
u = request.user r = row.user
r = Rower.objects.get(user=u) u = r.user
first_name = u.first_name first_name = u.first_name
last_name = u.last_name last_name = u.last_name
emailaddress = u.email emailaddress = u.email
BIN
View File
Binary file not shown.