Private
Public Access
1
0

small improvements

This commit is contained in:
Sander Roosendaal
2019-04-03 22:22:40 +02:00
parent 9fb2523b9a
commit 0ff24d8aee
3 changed files with 20 additions and 13 deletions

View File

@@ -1007,7 +1007,10 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
f = rowdatadf['TimeStamp (sec)'].diff().mean()
if f != 0:
windowsize = 2*(int(10./(f)))+1
try:
windowsize = 2*(int(10./(f)))+1
except ValueError:
windowsize = 1
else:
windowsize = 1
if windowsize <= 3:

View File

@@ -97,6 +97,12 @@ import arrow
from rowers.utils import get_strava_stream
def safetimedelta(x):
try:
return timedelta(seconds=x)
except ValueError:
return timedelta(seconds=0)
siteurl = SITE_URL
# testing task
@@ -292,7 +298,7 @@ def handle_check_race_course(self,
rowdata = rowdata[rowdata['time']>splitsecond]
# we may want to expand the time (interpolate)
rowdata['dt'] = rowdata['time'].apply(
lambda x: timedelta(seconds=x)
lambda x: safetimedelta(seconds=x)
)
rowdata = rowdata.resample('100ms',on='dt').mean()
rowdata = rowdata.interpolate()
@@ -618,7 +624,7 @@ def handle_calctrimp(id,
df2['time'] = df2[' ElapsedTime (sec)']
df2['time'] = df2['time'].apply(
lambda x:timedelta(seconds=x)
lambda x:safetimedelta(seconds=x)
)
duration = df['TimeStamp (sec)'].max()-df['TimeStamp (sec)'].min()
@@ -1659,11 +1665,10 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename,
try:
haspower = row.df[' Power (watts)'].mean() > 50
except TypeError:
haspower = True
except KeyError:
except (TypeError, KeyError):
haspower = False
nr_rows = len(row.df)
if (plotnr in [1, 2, 4, 5, 8, 11, 9, 12]) and (nr_rows > 1200):
bin = int(nr_rows / 1200.)
@@ -1700,14 +1705,13 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename,
t += ' - Power Distribution'
fig1 = row.get_power_piechart(t)
canvas = FigureCanvas(fig1)
if fig1:
canvas = FigureCanvas(fig1)
# plt.savefig('static/plots/'+imagename,format='png')
canvas.print_figure('static/plots/' + imagename)
# plt.imsave(fname='static/plots/'+imagename)
plt.close(fig1)
fig1.clf()
gc.collect()
canvas.print_figure('static/plots/' + imagename)
plt.close(fig1)
fig1.clf()
gc.collect()
return imagename

Binary file not shown.