diff --git a/rowers/datautils.py b/rowers/datautils.py index dda402c0..68efe7a5 100644 --- a/rowers/datautils.py +++ b/rowers/datautils.py @@ -365,11 +365,17 @@ def getmaxwattinterval(tt,ww,i): return deltat,wmax -def getfastest(df,thedistance): +def getfastest(df,thevalue,mode='distance'): tt = df['time'].copy() dd = df['cumdist'].copy() tmax = tt.max() + if mode == 'distance': + if dd.max() > thevalue: + return 0 + else: + if tt.max() > thevalue: + return 0 if tmax > 500000: newlen=int(tmax/2000.) @@ -412,6 +418,10 @@ def getfastest(df,thedistance): restime = np.array(restime) distance = np.array(distance) - d2 = griddata(distance,restime,[thedistance],method='linear',rescale=True) + d2 = 0 + if mode == 'distance': + d2 = griddata(distance,restime,[thevalue],method='linear',rescale=True) + else: + d2 = griddata(restime,distance,[thevalue],method='linear',rescale=True) return d2[0]/1000.