fix bug in perf chart
This commit is contained in:
@@ -1092,6 +1092,9 @@ def workout_goldmedalstandard(workout):
|
|||||||
return workout.goldmedalstandard,workout.goldmedalseconds
|
return workout.goldmedalstandard,workout.goldmedalseconds
|
||||||
if workout.workouttype in rowtypes:
|
if workout.workouttype in rowtypes:
|
||||||
goldmedalstandard,goldmedalseconds = calculate_goldmedalstandard(workout.user,workout)
|
goldmedalstandard,goldmedalseconds = calculate_goldmedalstandard(workout.user,workout)
|
||||||
|
if workout.workouttype in otwtypes:
|
||||||
|
factor = 100./(100.-workout.user.otwslack)
|
||||||
|
goldmedalstandard = goldmedalstandard*factor
|
||||||
workout.goldmedalstandard = goldmedalstandard
|
workout.goldmedalstandard = goldmedalstandard
|
||||||
workout.goldmedalseconds = goldmedalseconds
|
workout.goldmedalseconds = goldmedalseconds
|
||||||
workout.save()
|
workout.save()
|
||||||
|
|||||||
@@ -130,8 +130,6 @@ def build_goldmedalstandards(workouts,kfitness):
|
|||||||
for w in workouts:
|
for w in workouts:
|
||||||
goldmedalstandard,goldmedalseconds = dataprep.workout_goldmedalstandard(w)
|
goldmedalstandard,goldmedalseconds = dataprep.workout_goldmedalstandard(w)
|
||||||
ids.append(w.id)
|
ids.append(w.id)
|
||||||
if w.workouttype in mytypes.otwtypes:
|
|
||||||
goldmedalstandard = goldmedalstandard / (1.-w.user.otwslack/100.)
|
|
||||||
if goldmedalseconds > 60:
|
if goldmedalseconds > 60:
|
||||||
goldmedalstandards.append(goldmedalstandard)
|
goldmedalstandards.append(goldmedalstandard)
|
||||||
goldmedaldurations.append(goldmedalseconds)
|
goldmedaldurations.append(goldmedalseconds)
|
||||||
@@ -1713,9 +1711,9 @@ def getfatigues(
|
|||||||
fatigue = 0
|
fatigue = 0
|
||||||
fitness = 0
|
fitness = 0
|
||||||
|
|
||||||
#impulses = []
|
impulses = []
|
||||||
#for f in fatigues:
|
for f in fatigues:
|
||||||
# impulses.append(0)
|
impulses.append(0)
|
||||||
|
|
||||||
lambda_a = 2/(kfatigue+1)
|
lambda_a = 2/(kfatigue+1)
|
||||||
lambda_c = 2/(kfitness+1)
|
lambda_c = 2/(kfitness+1)
|
||||||
@@ -1752,7 +1750,6 @@ def getfatigues(
|
|||||||
|
|
||||||
impulses.append(weight)
|
impulses.append(weight)
|
||||||
|
|
||||||
|
|
||||||
fatigue = (1-lambda_a)*fatigue+weight*lambda_a
|
fatigue = (1-lambda_a)*fatigue+weight*lambda_a
|
||||||
fitness = (1-lambda_c)*fitness+weight*lambda_c
|
fitness = (1-lambda_c)*fitness+weight*lambda_c
|
||||||
|
|
||||||
@@ -1762,6 +1759,7 @@ def getfatigues(
|
|||||||
testpower.append(np.nan)
|
testpower.append(np.nan)
|
||||||
testduration.append(np.nan)
|
testduration.append(np.nan)
|
||||||
|
|
||||||
|
|
||||||
return fatigues,fitnesses,dates,testpower,testduration,impulses
|
return fatigues,fitnesses,dates,testpower,testduration,impulses
|
||||||
|
|
||||||
def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
||||||
@@ -1771,6 +1769,9 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||||
TOOLS2 = 'box_zoom,hover'
|
TOOLS2 = 'box_zoom,hover'
|
||||||
|
|
||||||
|
# to avoid data mess later on
|
||||||
|
startdate = arrow.get(startdate).datetime.replace(hour=0,minute=0,second=0,microsecond=0)
|
||||||
|
|
||||||
|
|
||||||
modelchoice = 'coggan'
|
modelchoice = 'coggan'
|
||||||
p0 = 0
|
p0 = 0
|
||||||
@@ -1782,6 +1783,7 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
fatigues = []
|
fatigues = []
|
||||||
fitnesses = []
|
fitnesses = []
|
||||||
testduration = []
|
testduration = []
|
||||||
|
impulses = []
|
||||||
|
|
||||||
if showtests:
|
if showtests:
|
||||||
workouts = Workout.objects.filter(user=user.rower,date__gte=startdate,
|
workouts = Workout.objects.filter(user=user.rower,date__gte=startdate,
|
||||||
@@ -1809,6 +1811,7 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
dates = [d for d in df['date']]
|
dates = [d for d in df['date']]
|
||||||
testpower = df['testpower'].values.tolist()
|
testpower = df['testpower'].values.tolist()
|
||||||
fatigues = df['fatigue'].values.tolist()
|
fatigues = df['fatigue'].values.tolist()
|
||||||
@@ -1836,6 +1839,7 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
'impulse':impulses,
|
'impulse':impulses,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
endfitness = fitnesses[-1]
|
endfitness = fitnesses[-1]
|
||||||
endfatigue = fatigues[-1]
|
endfatigue = fatigues[-1]
|
||||||
endform = endfitness-endfatigue
|
endform = endfitness-endfatigue
|
||||||
@@ -1853,6 +1857,9 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
df = df.groupby(['date']).max()
|
df = df.groupby(['date']).max()
|
||||||
df['date'] = df.index.values
|
df['date'] = df.index.values
|
||||||
|
|
||||||
|
#for row in df.iterrows():
|
||||||
|
# print(row)
|
||||||
|
|
||||||
source = ColumnDataSource(
|
source = ColumnDataSource(
|
||||||
data = dict(
|
data = dict(
|
||||||
testpower = df['testpower'],
|
testpower = df['testpower'],
|
||||||
@@ -1929,7 +1936,10 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
|||||||
|
|
||||||
y2rangemin = df.loc[:,['form']].min().min()
|
y2rangemin = df.loc[:,['form']].min().min()
|
||||||
y2rangemax = df.loc[:,['form']].max().max()
|
y2rangemax = df.loc[:,['form']].max().max()
|
||||||
if dofatigue:
|
if dofatigue and showtests:
|
||||||
|
y1rangemin = df.loc[:,['testpower','fitness','fatigue']].min().min()
|
||||||
|
y1rangemax = df.loc[:,['testpower','fitness','fatigue']].max().max()
|
||||||
|
elif dofatigue:
|
||||||
y1rangemin = df.loc[:,['fitness','fatigue']].min().min()
|
y1rangemin = df.loc[:,['fitness','fatigue']].min().min()
|
||||||
y1rangemax = df.loc[:,['fitness','fatigue']].max().max()
|
y1rangemax = df.loc[:,['fitness','fatigue']].max().max()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user