Fixed Ranking distances
This commit is contained in:
@@ -186,7 +186,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
|
||||
velo = thedistances/thesecs
|
||||
p = pd.Series(500./velo)
|
||||
|
||||
p2 = p.fillna(method='ffil').apply(lambda x: timedeltaconv(x))
|
||||
p2 = p.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
|
||||
|
||||
source = ColumnDataSource(
|
||||
data = dict(
|
||||
@@ -198,7 +198,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
|
||||
),
|
||||
|
||||
power = theavpower,
|
||||
pace = nicepaceformat(p2),
|
||||
fpace = nicepaceformat(p2),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -228,7 +228,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
|
||||
tim = niceformat(
|
||||
fitt.fillna(method='ffill').apply(lambda x: timedeltaconv(x))
|
||||
),
|
||||
pace = nicepaceformat(fitp2),
|
||||
fpace = nicepaceformat(fitp2),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -269,7 +269,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
|
||||
),
|
||||
spm = 0*fitpower,
|
||||
power = fitpower,
|
||||
pace = nicepaceformat(fitp2),
|
||||
fpace = nicepaceformat(fitp2),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
<td> {{ value }} W </td>
|
||||
{% endif %}
|
||||
{% if key == "duration" %}
|
||||
<td> {{ value |paceprint }} </td>
|
||||
<td> {{ value |deltatimeprint }} </td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
@@ -209,7 +209,7 @@
|
||||
<td> {{ value }} W </td>
|
||||
{% endif %}
|
||||
{% if key == "duration" %}
|
||||
<td> {{ value |paceprint }} </td>
|
||||
<td> {{ value |deltatimeprint }} </td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
||||
@@ -6,7 +6,20 @@ register = template.Library()
|
||||
def strfdelta(tdelta):
|
||||
minutes,seconds = divmod(tdelta.seconds,60)
|
||||
tenths = int(tdelta.microseconds/1e5)
|
||||
res = "{minutes:0>2}:{seconds:0>2}.{tenths:0>1}".format(
|
||||
res = "{minutes:0>1}:{seconds:0>2}.{tenths:0>1}".format(
|
||||
minutes=minutes,
|
||||
seconds=seconds,
|
||||
tenths=tenths,
|
||||
)
|
||||
|
||||
return res
|
||||
|
||||
def strfdeltah(tdelta):
|
||||
hours, rest = divmod(tdelta.seconds,3600)
|
||||
minutes,seconds = divmod(rest,60)
|
||||
tenths = int(tdelta.microseconds/1e5)
|
||||
res = "{hours:0>2}:{minutes:0>2}:{seconds:0>2}.{tenths:0>1}".format(
|
||||
hours=hours,
|
||||
minutes=minutes,
|
||||
seconds=seconds,
|
||||
tenths=tenths,
|
||||
@@ -28,6 +41,13 @@ def paceprint(d):
|
||||
else:
|
||||
return strfdelta(d)
|
||||
|
||||
@register.filter
|
||||
def deltatimeprint(d):
|
||||
if (d == None):
|
||||
return d
|
||||
else:
|
||||
return strfdeltah(d)
|
||||
|
||||
|
||||
@register.filter
|
||||
def lookup(dict, key):
|
||||
|
||||
@@ -66,6 +66,7 @@ import mailprocessing
|
||||
from io import BytesIO
|
||||
from scipy.special import lambertw
|
||||
|
||||
from dataprep import timedeltaconv
|
||||
|
||||
LOCALTIMEZONE = tz('Etc/UTC')
|
||||
USER_LANGUAGE = 'en-US'
|
||||
@@ -1617,8 +1618,8 @@ def rankings_view(request,theuser=0,
|
||||
t = rankingdistance/velo
|
||||
pwr = 2.8*(velo**3)
|
||||
a = {'distance':rankingdistance,
|
||||
'duration':get_datetimes([t])[0],
|
||||
'pace':get_datetimes([p])[0],
|
||||
'duration':timedeltaconv(t),
|
||||
'pace':timedeltaconv(p),
|
||||
'power':int(pwr)}
|
||||
predictions.append(a)
|
||||
|
||||
@@ -1650,8 +1651,8 @@ def rankings_view(request,theuser=0,
|
||||
p3 = 500./velo3
|
||||
|
||||
a = {'distance':rankingdistance,
|
||||
'duration':get_datetimes([t3])[0],
|
||||
'pace':get_datetimes([p3])[0],
|
||||
'duration':timedeltaconv(t3),
|
||||
'pace':timedeltaconv(p3),
|
||||
'power':int(pwr3)}
|
||||
cpredictions.append(a)
|
||||
|
||||
@@ -1677,8 +1678,8 @@ def rankings_view(request,theuser=0,
|
||||
p = 500./velo
|
||||
pwr = 2.8*(velo**3)
|
||||
a = {'distance':int(d),
|
||||
'duration':get_datetimes([t])[0],
|
||||
'pace':get_datetimes([p])[0],
|
||||
'duration':timedeltaconv(t),
|
||||
'pace':timedeltaconv(p),
|
||||
'power':int(pwr)}
|
||||
predictions.append(a)
|
||||
|
||||
@@ -1697,8 +1698,8 @@ def rankings_view(request,theuser=0,
|
||||
d = t*velo
|
||||
p = 500./velo
|
||||
a = {'distance':int(d),
|
||||
'duration':get_datetimes([t])[0],
|
||||
'pace':get_datetimes([p])[0],
|
||||
'duration':timedeltaconv(t),
|
||||
'pace':timedeltaconv(p),
|
||||
'power':int(pwr)}
|
||||
cpredictions.append(a)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user