Private
Public Access
1
0

some improvements

This commit is contained in:
Sander Roosendaal
2017-12-13 20:53:02 +01:00
parent 1a18f033b4
commit 8590dc7a88
4 changed files with 40 additions and 19 deletions

View File

@@ -1185,7 +1185,6 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
# fitting the data to three parameter CP model
p1 = p0
if len(thesecs)>=4:
p1, success = optimize.leastsq(errfunc, p0[:], args = (thesecs,theavpower))
@@ -1271,7 +1270,7 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
if cpdata.empty:
message = 'Calculations are running in the background. Please refresh this page to see updated results'
return ['','',paulslope,paulintercept,p1,message]
return ['','',paulslope,paulintercept,p1,message,p1wc]
velo = cpdata['distance']/cpdata['delta']
@@ -1338,7 +1337,7 @@ def interactive_cpchart(rower,thedistances,thesecs,theavpower,
script, div = components(plot)
return [script,div,paulslope,paulintercept,p1,message]
return [script,div,paulslope,paulintercept,p1,message,p1wc]
def interactive_windchart(id=0,promember=0):
# check if valid ID exists (workout exists)

View File

@@ -343,11 +343,14 @@ def getagegrouprecord(age,sex='male',weightcategory='hwt',
)
)
ages = df['age']
powers = df['power']
if not df.empty:
ages = df['age']
powers = df['power']
poly_coefficients = np.polyfit(ages,powers,6)
poly_coefficients = np.polyfit(ages,powers,6)
power = np.polyval(poly_coefficients,age)
power = np.polyval(poly_coefficients,age)
else:
power = 0
return power

View File

@@ -160,15 +160,21 @@
{{ the_div|safe }}
<p>The dashed lines are based on the Concept2 rankings for your age, gender
and weight category. World class means within 5% of World Record in terms
{% if age %}
<p>The dashed lines are based on the
<a href="https://log.concept2.com/rankings">Concept2</a>
rankings for your age, gender
and weight category. World class means within 5% of
<a href="http://www.concept2.com/indoor-rowers/racing/records/world">
World Record</a> in terms
of power. Excellent, Good, and Fair indicate the power levels of the top
10%, 25% and 50% of the Concept2 rankings. Average is taken
as being in the top 75%, given that the Concept2 rankings probably
as being in the top 75%, which is quite good,
given that the Concept2 rankings probably
represent the more competitive sub-group of all people who erg.
Please note that this is a prediction for people of exactly your age,
and your actual place in the Concept2 Ranking may be different.</p>
{% endif %}
</div>
<div id="predictions" class="grid_12 alpha">

View File

@@ -3543,7 +3543,6 @@ def rankings_view2(request,theuser=0,
age = calculate_age(r.birthdate)
durations = [1,4,30,60]
distances = [100,500,1000,2000,5000,6000,10000,21097,42195]
print r.weightcategory,r.sex,age,'aap'
for distance in distances:
worldclasspower = metrics.getagegrouprecord(
age,
@@ -3552,9 +3551,12 @@ def rankings_view2(request,theuser=0,
weightcategory=r.weightcategory
)
velo = (worldclasspower/2.8)**(1./3.)
duration = distance/velo
wcdurations.append(duration)
wcpower.append(worldclasspower)
try:
duration = distance/velo
wcdurations.append(duration)
wcpower.append(worldclasspower)
except ZeroDivisionError:
pass
for duration in durations:
worldclasspower = metrics.getagegrouprecord(
age,
@@ -3562,12 +3564,16 @@ def rankings_view2(request,theuser=0,
duration=duration,
weightcategory=r.weightcategory
)
wcdurations.append(60.*duration)
velo = (worldclasspower/2.8)**(1./3.)
distance = int(60*duration*velo)
wcpower.append(worldclasspower)
try:
velo = (worldclasspower/2.8)**(1./3.)
distance = int(60*duration*velo)
wcdurations.append(60.*duration)
wcpower.append(worldclasspower)
except ValueError:
pass
else:
worldclasspower = None
age = 0
result = request.user.is_authenticated() and ispromember(request.user)
if result:
@@ -3702,6 +3708,10 @@ def rankings_view2(request,theuser=0,
paulintercept = res[3]
p1 = res[4]
message = res[5]
try:
testcalc = float(pd.Series(res[6]))
except TypeError:
age = 0
else:
script = ''
div = '<p>No ranking pieces found.</p>'
@@ -3840,6 +3850,9 @@ def rankings_view2(request,theuser=0,
'deltaform':deltaform,
'id': theuser,
'theuser':uu,
'age':age,
'sex':r.sex,
'weightcategory':r.weightcategory,
'startdate':startdate,
'enddate':enddate,
'teams':get_my_teams(request.user),