Private
Public Access
1
0

Merge branch 'hotfix/paceline'

This commit is contained in:
sanderroosendaal
2016-10-31 21:18:26 +01:00
3 changed files with 66 additions and 33 deletions

View File

@@ -96,7 +96,7 @@ def nicepaceformat(values):
return out
def get_datetimes(seconds,tzinfo=0):
def get_datetimes(seconds,tzinfo=0,datevalues=0):
out = []
for second in seconds:
if (second<=0) or (second>1e9):
@@ -122,6 +122,10 @@ def get_datetimes(seconds,tzinfo=0):
seconds=sec,microseconds=microsecond)
if datevalues==1:
t = datetime.datetime(2016,5,1)+dt
dt = t
out.append(dt)
@@ -246,7 +250,8 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
velo = thedistances/thesecs
p = 500./velo
p2 = get_datetimes(p)
p2 = get_datetimes(p,datevalues=1)
p2a = get_datetimes(p)
source = ColumnDataSource(
data = dict(
@@ -255,7 +260,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
spm = 0*theavpower,
tim = niceformat(get_datetimes(thesecs,tzinfo=1)),
power = theavpower,
pace = nicepaceformat(p2),
pace = nicepaceformat(p2a),
)
)
@@ -273,7 +278,8 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
fitvelo = 500./fitp
fitpower = 2.8*(fitvelo**3)
fitt = 10**fitx/fitvelo
fitp2 = get_datetimes(fitp)
fitp2 = get_datetimes(fitp,datevalues=1)
fitp2a = get_datetimes(fitp,datevalues=0)
sourcepaul = ColumnDataSource(
@@ -283,7 +289,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
power = fitpower,
spm = 0*fitpower,
tim = niceformat(get_datetimes(fitt,tzinfo=1)),
pace = nicepaceformat(fitp2),
pace = nicepaceformat(fitp2a),
)
)
@@ -333,7 +339,8 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
fitvelo = (fitpower/2.8)**(1./3.)
fitdist = fitt*fitvelo
fitp = 500./fitvelo
fitp2 = get_datetimes(fitp)
fitp2 = get_datetimes(fitp,datevalues=1)
fitp2a = get_datetimes(fitp,datevalues=0)
sourcecomplex = ColumnDataSource(
data = dict(
@@ -342,7 +349,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
tim = niceformat(get_datetimes(fitt,tzinfo=1)),
spm = 0*fitpower,
power = fitpower,
pace = nicepaceformat(fitp2),
pace = nicepaceformat(fitp2a),
)
)
@@ -371,7 +378,8 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
p = 500./velo
p2 = get_datetimes(p)
p2 = get_datetimes(p,datevalues=1)
p2a = get_datetimes(p,datevalues=0)
source2 = ColumnDataSource(
data = dict(
@@ -379,7 +387,7 @@ def interactive_cpchart(thedistances,thesecs,theavpower,
power = cpdata['CP'],
tim = niceformat(get_datetimes(cpdata['Delta'],tzinfo=1)),
dist = cpdata['Distance'],
pace = nicepaceformat(p2),
pace = nicepaceformat(p2a),
)
)
@@ -643,7 +651,8 @@ def interactive_chart(id=0,promember=0):
# p[p>3000] = 3000.
p2 = get_datetimes(p)
p2 = get_datetimes(p,datevalues=1)
p2a = get_datetimes(p,datevalues=0)
source = ColumnDataSource(
data = dict(
@@ -651,7 +660,7 @@ def interactive_chart(id=0,promember=0):
y=hr,
y2=p2,
tf = niceformat(t2),
pace = nicepaceformat(p2),
pace = nicepaceformat(p2a),
heartrate = hr,
spm=spm,
spmc=np.rint(10*spm)/10.,
@@ -873,7 +882,7 @@ def interactive_cum_flex_chart(theworkouts,promember=0,
if yparam1 == 'pace':
y_axis_type = 'datetime'
y1 = get_datetimes(y1)
y1 = get_datetimes(y1,datevalues=1)
ymax = datetime.datetime(2016,5,1,0,1,30)
ymin = datetime.datetime(2016,5,1,0,2,30)
@@ -1302,7 +1311,7 @@ def interactive_flex_chart(id=0,promember=0,
if yparam1 == 'pace':
y_axis_type = 'datetime'
y1 = get_datetimes(y1)
y1 = get_datetimes(y1,datevalues=1)
ymax = datetime.datetime(2016,5,1,0,1,30)
ymin = datetime.datetime(2016,5,1,0,2,30)
@@ -1483,7 +1492,7 @@ def interactive_flex_chart2(id=0,promember=0,
yaxminima = {
'hr':100,
'spm':15,
'pace': datetime.datetime(2016,5,1,0,3,30),
'pace': datetime.timedelta(minutes=1,seconds=40),
'power': 0,
'averageforce': 0,
'peakforce': 0,
@@ -1495,7 +1504,7 @@ def interactive_flex_chart2(id=0,promember=0,
yaxmaxima = {
'hr':200,
'spm':45,
'pace':datetime.datetime(2016,5,1,0,1,30),
'pace':datetime.timedelta(minutes=3,seconds=30),
'power': 600,
'averageforce':200,
'peakforce':400,
@@ -1612,7 +1621,7 @@ def interactive_flex_chart2(id=0,promember=0,
if yparam1 == 'pace':
y_axis_type = 'datetime'
y1 = get_datetimes(y1)
y1 = get_datetimes(y1,datevalues=1)
ymax = datetime.datetime(2016,5,1,0,1,30)
ymin = datetime.datetime(2016,5,1,0,2,30)
@@ -1720,8 +1729,9 @@ def interactive_flex_chart2(id=0,promember=0,
yrange1 = Range1d(start=yaxminima[yparam1],end=yaxmaxima[yparam1])
plot.y_range = yrange1
if (yparam1 != 'pace'):
yrange1 = Range1d(start=yaxminima[yparam1],end=yaxmaxima[yparam1])
plot.y_range = yrange1
if (xparam != 'time') and (xparam != 'distance'):
xrange1 = Range1d(start=yaxminima[xparam],end=yaxmaxima[xparam])
@@ -1747,7 +1757,7 @@ def interactive_flex_chart2(id=0,promember=0,
minutes = ["%M"]
)
if yparam2 != 'None':
if yparam2 != 'None' and yparam2 != 'pace':
yrange2 = Range1d(start=yaxminima[yparam2],end=yaxmaxima[yparam2])
plot.extra_y_ranges = {"yax2": yrange2}
@@ -1965,7 +1975,8 @@ def interactive_bar_chart(id=0,promember=0):
TOOLS = 'pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
t2 = get_datetimes(t,tzinfo=1)
p2 = get_datetimes(p)
p2 = get_datetimes(p,datevalues=1)
p2a = get_datetimes(p,datevalues=0)
source = ColumnDataSource(
data = dict(
@@ -1981,7 +1992,7 @@ def interactive_bar_chart(id=0,promember=0):
hr_bottom = 0.0*hr,
y2=p2,
tf = niceformat(t2),
pace = nicepaceformat(p2),
pace = nicepaceformat(p2a),
heartrate = hr,
spmc=np.rint(10*spm)/10.,
spm=spm,
@@ -2173,8 +2184,8 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
if yparam == 'pace':
y_axis_type = 'datetime'
y1 = get_datetimes(y1)
y2 = get_datetimes(y2)
y1 = get_datetimes(y1,datevalues=1)
y2 = get_datetimes(y2,datevalues=1)
ymax = datetime.datetime(2016,5,1,0,1,30)
ymin = datetime.datetime(2016,5,1,0,2,30)
@@ -2363,9 +2374,12 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0):
rowdata.df[' DriveLength (meters)'] = drivelength
t2 = get_datetimes(t,tzinfo=1)
p2 = get_datetimes(p)
nowindp2 = get_datetimes(nowindpace)
ergpace2 = get_datetimes(ergpace)
p2 = get_datetimes(p,datevalues=1)
p2a = get_datetimes(p,datevalues=0)
nowindp2 = get_datetimes(nowindpace,datevalues=1)
nowindp2a = get_datetimes(nowindpace,datevalues=0)
ergpace2 = get_datetimes(ergpace,datevalues=1)
ergpace2a = get_datetimes(ergpace,datevalues=0)
# Add hover to this comma-separated string and see what changes
if (promember==1):
@@ -2380,9 +2394,9 @@ def interactive_otw_advanced_pace_chart(id=0,promember=0):
nowindp2 = nowindp2,
ergpace2 = ergpace2,
tf = niceformat(t2),
pace = nicepaceformat(p2),
ergpace = nicepaceformat(ergpace2),
nowindpace = nicepaceformat(nowindp2),
pace = nicepaceformat(p2a),
ergpace = nicepaceformat(ergpace2a),
nowindpace = nicepaceformat(nowindp2a),
heartrate = hr,
spm=spm,
spmc=np.rint(10*spm)/10.,

View File

@@ -164,13 +164,13 @@
<td> {{ value }} m </td>
{% endif %}
{% if key == "pace" %}
<td> {{ value |durationprint:"%M:%S.%f" }} </td>
<td> {{ value |paceprint }} </td>
{% endif %}
{% if key == "power" %}
<td> {{ value }} W </td>
{% endif %}
{% if key == "duration" %}
<td> {{ value |durationprint:"%H:%M:%S.%f" }} </td>
<td> {{ value |paceprint }} </td>
{% endif %}
{% endfor %}
</tr>
@@ -203,13 +203,13 @@
<td> {{ value }} m </td>
{% endif %}
{% if key == "pace" %}
<td> {{ value |durationprint:"%M:%S.%f" }} </td>
<td> {{ value |paceprint }} </td>
{% endif %}
{% if key == "power" %}
<td> {{ value }} W </td>
{% endif %}
{% if key == "duration" %}
<td> {{ value |durationprint:"%H:%M:%S.%f" }} </td>
<td> {{ value |paceprint }} </td>
{% endif %}
{% endfor %}
</tr>

View File

@@ -3,6 +3,17 @@ from time import strftime
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(
minutes=minutes,
seconds=seconds,
tenths=tenths,
)
return res
@register.filter
def durationprint(d,dstring):
if (d == None):
@@ -10,6 +21,14 @@ def durationprint(d,dstring):
else:
return d.strftime(dstring)[:-5]
@register.filter
def paceprint(d):
if (d == None):
return d
else:
return strfdelta(d)
@register.filter
def lookup(dict, key):
s = dict.get(key)