fixing course calculations
This commit is contained in:
@@ -31,17 +31,24 @@ def time_in_path(df, p, maxmin='max', getall=False, name='unknown', logfile=None
|
||||
|
||||
if len(df[b == 2]):
|
||||
if logfile is not None: # pragma: no cover
|
||||
s = '{name} {maxmin} {getall} {nrpasses} passes found'.format(
|
||||
s = '{name} {maxmin} {getall} {nrpasses} passes found at {time} seconds'.format(
|
||||
name = name,
|
||||
maxmin = maxmin,
|
||||
getall = getall,
|
||||
nrpasses = len(df[b==2]),
|
||||
time = df[b==2]['time'].min() if not getall else df[b==2]['time'].max()
|
||||
)
|
||||
dologging(logfile,s)
|
||||
if getall: # pragma: no cover
|
||||
return df[b == 2]['time'], df[b == 2]['cum_dist']
|
||||
try:
|
||||
return df[b == 2]['time'], df[b == 2]['cumdist']
|
||||
except KeyError:
|
||||
return df[b == 2]['time'], df[b == 2]['cum_dist']
|
||||
else:
|
||||
return df[b == 2]['time'].min(), df[b == 2]['cum_dist'].min()
|
||||
try:
|
||||
return df[b == 2]['time'].min(), df[b == 2]['cumdist'].min()
|
||||
except KeyError:
|
||||
return df[b == 2]['time'].min(), df[b == 2]['cum_dist'].min()
|
||||
|
||||
if logfile is not None: # pragma: no cover
|
||||
s = '{name} {maxmin} {getall} {nrpasses} pass not found'.format(
|
||||
@@ -60,7 +67,10 @@ def time_in_path(df, p, maxmin='max', getall=False, name='unknown', logfile=None
|
||||
def coursetime_first(data, paths, polygons=[], logfile=None):
|
||||
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
if len(polygons) == 0:
|
||||
@@ -72,7 +82,10 @@ def coursetime_first(data, paths, polygons=[], logfile=None):
|
||||
coursecompleted = True
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
return entrytime, entrydistance, coursecompleted
|
||||
|
||||
@@ -80,7 +93,10 @@ def coursetime_first(data, paths, polygons=[], logfile=None):
|
||||
def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
if len(polygons) == 0:
|
||||
@@ -100,7 +116,10 @@ def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
coursecompleted = True
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
return entrytime, entrydistance, coursecompleted
|
||||
|
||||
@@ -110,7 +129,10 @@ def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
data, paths[0], name=str(polygons[0]), logfile=logfile)
|
||||
data2 = data[data['time'] > time].copy()
|
||||
data2['time'] = data2['time'].apply(lambda x: x-time)
|
||||
data2['cum_dist'] = data2['cum_dist'].apply(lambda x: x-dist)
|
||||
try:
|
||||
data2['cumdist'] = data2['cumdist'].apply(lambda x: x-dist)
|
||||
except KeyError:
|
||||
data2['cum_dist'] = data2['cum_dist'].apply(lambda x: x-dist)
|
||||
(
|
||||
timenext,
|
||||
distnext,
|
||||
@@ -119,7 +141,10 @@ def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
return time+timenext, dist+distnext, coursecompleted
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
return entrytime, entrydistance, coursecompleted # pragma: no cover
|
||||
|
||||
@@ -1363,6 +1363,7 @@ def handle_check_race_course(self,
|
||||
dologging(logfile, logmessage)
|
||||
dologging(logfile2, logmessage)
|
||||
rowdata2 = rowdata[rowdata['time'] > (startt-10.)]
|
||||
#rowdata2.to_csv('debug_course.csv')
|
||||
|
||||
(
|
||||
coursetimeseconds,
|
||||
@@ -1377,6 +1378,14 @@ def handle_check_race_course(self,
|
||||
) = coursetime_first(
|
||||
rowdata2, paths, polygons=polygons, logfile=logfile)
|
||||
|
||||
dologging(logfile, "First time through all gates {t} seconds, {m} meters, completed {c}".format(
|
||||
t=coursetimeseconds, m=coursemeters, c=coursecompleted
|
||||
))
|
||||
|
||||
dologging(logfile, "Start time through all gates {t} seconds, {m} meters, completed {c}".format(
|
||||
t=coursetimefirst, m=coursemetersfirst, c=firstcompleted
|
||||
))
|
||||
|
||||
coursetimesecondsnet = coursetimeseconds-coursetimefirst
|
||||
coursemeters = coursemeters-coursemetersfirst
|
||||
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user