fix
This commit is contained in:
@@ -398,10 +398,12 @@ def getfastest(df,thevalue,mode='distance'):
|
|||||||
dd = pd.Series(dd)
|
dd = pd.Series(dd)
|
||||||
|
|
||||||
G = pd.concat([pd.Series([0]),dd])
|
G = pd.concat([pd.Series([0]),dd])
|
||||||
|
T = pd.concat([pd.Series([0]),dd])
|
||||||
h = np.mgrid[0:len(tt)+1:1,0:len(tt)+1:1]
|
h = np.mgrid[0:len(tt)+1:1,0:len(tt)+1:1]
|
||||||
distances = pd.DataFrame(h[1]-h[0])
|
distances = pd.DataFrame(h[1]-h[0])
|
||||||
ones = 1+np.zeros(len(G))
|
ones = 1+np.zeros(len(G))
|
||||||
Ghor = np.outer(ones,G)
|
Ghor = np.outer(ones,G)
|
||||||
|
Thor = np.outer(ones,T)
|
||||||
Gver = np.outer(G,ones)
|
Gver = np.outer(G,ones)
|
||||||
Gdif = Ghor-Gver
|
Gdif = Ghor-Gver
|
||||||
Gdif = np.tril(Gdif.T).T
|
Gdif = np.tril(Gdif.T).T
|
||||||
@@ -413,27 +415,42 @@ def getfastest(df,thevalue,mode='distance'):
|
|||||||
|
|
||||||
restime = []
|
restime = []
|
||||||
distance = []
|
distance = []
|
||||||
|
starttimes = []
|
||||||
|
endtime = []
|
||||||
|
|
||||||
for i in np.arange(0,len(tt)+1,1):
|
for i in np.arange(0,len(tt)+1,1):
|
||||||
restime.append(deltat*i)
|
restime.append(deltat*i)
|
||||||
cp = np.diag(F,i).max()
|
cp = np.diag(F,i).max()
|
||||||
|
loc = np.argmax(np.diag(F,i))
|
||||||
|
thestarttime = np.diag(Thor,i)[loc]
|
||||||
|
starttimes.append(thestarttime)
|
||||||
distance.append(cp)
|
distance.append(cp)
|
||||||
|
|
||||||
|
|
||||||
distance[0] = distance[1]
|
distance[0] = distance[1]
|
||||||
|
|
||||||
restime = np.array(restime)
|
restime = np.array(restime)
|
||||||
distance = np.array(distance)
|
distance = np.array(distance)
|
||||||
|
starttimes = np.array(starttimes)
|
||||||
|
|
||||||
#for i in range(len(restime)):
|
#for i in range(len(restime)):
|
||||||
# if restime[i]<thevalue*60*1000:
|
# if restime[i]<thevalue*60*1000:
|
||||||
# print(i,restime[i],distance[i],60*1000*thevalue)
|
# print(i,restime[i],distance[i],60*1000*thevalue)
|
||||||
|
|
||||||
d2 = 0
|
d2 = 0
|
||||||
|
|
||||||
if mode == 'distance':
|
if mode == 'distance':
|
||||||
d2 = griddata(distance,restime,[thevalue],method='linear',rescale=True)
|
duration = griddata(distance,restime,[thevalue],method='linear',rescale=True)
|
||||||
return d2[0]/1000.
|
starttime = griddata(distance,starttimes,[thevalue],method='linear',rescale=True)
|
||||||
|
distance = griddata(distance,distance,[thevalue],method='linear',rescale=True)
|
||||||
|
endtime = starttime+duration
|
||||||
|
print(duration,starttime,endtime)
|
||||||
|
return duration[0]/1000.,starttime[0]/1000.,endtime[0]/1000.
|
||||||
else:
|
else:
|
||||||
d2 = griddata(restime,distance,[thevalue*60*1000],method='linear',rescale=True)
|
distance = griddata(restime,distance,[thevalue*60*1000],method='linear',rescale=True)
|
||||||
return d2[0]
|
starttime = griddata(restime,starttimes,[thevalue*60*1000],method='linear',rescale=True)
|
||||||
|
duration = griddata(restime,restime,[thevalue*60*1000],method='linear',rescale=True)
|
||||||
|
endtime = starttime+duration
|
||||||
|
return distance[0],starttime[0]/1000.,endtime[0]/1000.
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -3267,6 +3267,9 @@ class IndoorVirtualRaceResult(models.Model):
|
|||||||
acceptsocialmedia = models.BooleanField(default=True,
|
acceptsocialmedia = models.BooleanField(default=True,
|
||||||
verbose_name = 'I agree with sharing my name in challenge related social media posts (unchecking this does not prevent you from participation)')
|
verbose_name = 'I agree with sharing my name in challenge related social media posts (unchecking this does not prevent you from participation)')
|
||||||
|
|
||||||
|
startsecond = models.FloatField(default=0)
|
||||||
|
endsecond = models.FloatField(default=0)
|
||||||
|
|
||||||
def isduplicate(self,other):
|
def isduplicate(self,other):
|
||||||
if self.userid != other.userid:
|
if self.userid != other.userid:
|
||||||
return False
|
return False
|
||||||
@@ -3335,7 +3338,8 @@ class CourseTestResult(models.Model):
|
|||||||
duration = models.TimeField(default=datetime.time(1,0))
|
duration = models.TimeField(default=datetime.time(1,0))
|
||||||
distance = models.IntegerField(default=0)
|
distance = models.IntegerField(default=0)
|
||||||
coursecompleted = models.BooleanField(default=False)
|
coursecompleted = models.BooleanField(default=False)
|
||||||
|
startsecond = models.FloatField(default=0)
|
||||||
|
endsecond = models.FloatField(default=0)
|
||||||
|
|
||||||
|
|
||||||
class IndoorVirtualRaceResultForm(ModelForm):
|
class IndoorVirtualRaceResultForm(ModelForm):
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ def add_workouts_plannedsession(ws,ps,r):
|
|||||||
record.delete()
|
record.delete()
|
||||||
|
|
||||||
df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[w.id])
|
df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[w.id])
|
||||||
fastest_milliseconds = datautils.getfastest(df,ps.sessionvalue,mode='distance')
|
fastest_milliseconds,starttime,endtime = datautils.getfastest(df,ps.sessionvalue,mode='distance')
|
||||||
|
|
||||||
if fastest_milliseconds > 0:
|
if fastest_milliseconds > 0:
|
||||||
w.plannedsession = ps
|
w.plannedsession = ps
|
||||||
@@ -418,6 +418,8 @@ def add_workouts_plannedsession(ws,ps,r):
|
|||||||
coursecompleted = True,
|
coursecompleted = True,
|
||||||
workoutid=w.id,
|
workoutid=w.id,
|
||||||
distance = ps.sessionvalue,
|
distance = ps.sessionvalue,
|
||||||
|
startsecond=starttime,
|
||||||
|
endsecond=endtime,
|
||||||
)
|
)
|
||||||
|
|
||||||
record.save()
|
record.save()
|
||||||
@@ -440,7 +442,7 @@ def add_workouts_plannedsession(ws,ps,r):
|
|||||||
record.delete()
|
record.delete()
|
||||||
|
|
||||||
df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[w.id])
|
df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[w.id])
|
||||||
fastest_meters = datautils.getfastest(df,ps.sessionvalue,mode='time')
|
fastest_meters,starttime,endtime = datautils.getfastest(df,ps.sessionvalue,mode='time')
|
||||||
|
|
||||||
if fastest_meters > 0:
|
if fastest_meters > 0:
|
||||||
w.plannedsession = ps
|
w.plannedsession = ps
|
||||||
@@ -454,6 +456,8 @@ def add_workouts_plannedsession(ws,ps,r):
|
|||||||
duration = duration,
|
duration = duration,
|
||||||
coursecompleted = True,
|
coursecompleted = True,
|
||||||
distance = fastest_meters,
|
distance = fastest_meters,
|
||||||
|
startsecond=starttime,
|
||||||
|
endsecond=endtime,
|
||||||
)
|
)
|
||||||
record.save()
|
record.save()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user