Private
Public Access
1
0

some error checking in getfastest

This commit is contained in:
Sander Roosendaal
2020-11-09 20:36:24 +01:00
parent e08ebd1d64
commit 79b4c1032f

View File

@@ -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.