small improvements
This commit is contained in:
@@ -1007,7 +1007,10 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
|
|
||||||
f = rowdatadf['TimeStamp (sec)'].diff().mean()
|
f = rowdatadf['TimeStamp (sec)'].diff().mean()
|
||||||
if f != 0:
|
if f != 0:
|
||||||
windowsize = 2*(int(10./(f)))+1
|
try:
|
||||||
|
windowsize = 2*(int(10./(f)))+1
|
||||||
|
except ValueError:
|
||||||
|
windowsize = 1
|
||||||
else:
|
else:
|
||||||
windowsize = 1
|
windowsize = 1
|
||||||
if windowsize <= 3:
|
if windowsize <= 3:
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ import arrow
|
|||||||
|
|
||||||
from rowers.utils import get_strava_stream
|
from rowers.utils import get_strava_stream
|
||||||
|
|
||||||
|
def safetimedelta(x):
|
||||||
|
try:
|
||||||
|
return timedelta(seconds=x)
|
||||||
|
except ValueError:
|
||||||
|
return timedelta(seconds=0)
|
||||||
|
|
||||||
siteurl = SITE_URL
|
siteurl = SITE_URL
|
||||||
|
|
||||||
# testing task
|
# testing task
|
||||||
@@ -292,7 +298,7 @@ def handle_check_race_course(self,
|
|||||||
rowdata = rowdata[rowdata['time']>splitsecond]
|
rowdata = rowdata[rowdata['time']>splitsecond]
|
||||||
# we may want to expand the time (interpolate)
|
# we may want to expand the time (interpolate)
|
||||||
rowdata['dt'] = rowdata['time'].apply(
|
rowdata['dt'] = rowdata['time'].apply(
|
||||||
lambda x: timedelta(seconds=x)
|
lambda x: safetimedelta(seconds=x)
|
||||||
)
|
)
|
||||||
rowdata = rowdata.resample('100ms',on='dt').mean()
|
rowdata = rowdata.resample('100ms',on='dt').mean()
|
||||||
rowdata = rowdata.interpolate()
|
rowdata = rowdata.interpolate()
|
||||||
@@ -618,7 +624,7 @@ def handle_calctrimp(id,
|
|||||||
|
|
||||||
df2['time'] = df2[' ElapsedTime (sec)']
|
df2['time'] = df2[' ElapsedTime (sec)']
|
||||||
df2['time'] = df2['time'].apply(
|
df2['time'] = df2['time'].apply(
|
||||||
lambda x:timedelta(seconds=x)
|
lambda x:safetimedelta(seconds=x)
|
||||||
)
|
)
|
||||||
|
|
||||||
duration = df['TimeStamp (sec)'].max()-df['TimeStamp (sec)'].min()
|
duration = df['TimeStamp (sec)'].max()-df['TimeStamp (sec)'].min()
|
||||||
@@ -1659,11 +1665,10 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
haspower = row.df[' Power (watts)'].mean() > 50
|
haspower = row.df[' Power (watts)'].mean() > 50
|
||||||
except TypeError:
|
except (TypeError, KeyError):
|
||||||
haspower = True
|
|
||||||
except KeyError:
|
|
||||||
haspower = False
|
haspower = False
|
||||||
|
|
||||||
|
|
||||||
nr_rows = len(row.df)
|
nr_rows = len(row.df)
|
||||||
if (plotnr in [1, 2, 4, 5, 8, 11, 9, 12]) and (nr_rows > 1200):
|
if (plotnr in [1, 2, 4, 5, 8, 11, 9, 12]) and (nr_rows > 1200):
|
||||||
bin = int(nr_rows / 1200.)
|
bin = int(nr_rows / 1200.)
|
||||||
@@ -1700,14 +1705,13 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename,
|
|||||||
t += ' - Power Distribution'
|
t += ' - Power Distribution'
|
||||||
fig1 = row.get_power_piechart(t)
|
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)
|
||||||
canvas.print_figure('static/plots/' + imagename)
|
plt.close(fig1)
|
||||||
# plt.imsave(fname='static/plots/'+imagename)
|
fig1.clf()
|
||||||
plt.close(fig1)
|
gc.collect()
|
||||||
fig1.clf()
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
return imagename
|
return imagename
|
||||||
|
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user