fix bug in perf chart
This commit is contained in:
@@ -1092,6 +1092,9 @@ def workout_goldmedalstandard(workout):
|
||||
return workout.goldmedalstandard,workout.goldmedalseconds
|
||||
if workout.workouttype in rowtypes:
|
||||
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.goldmedalseconds = goldmedalseconds
|
||||
workout.save()
|
||||
|
||||
@@ -130,8 +130,6 @@ def build_goldmedalstandards(workouts,kfitness):
|
||||
for w in workouts:
|
||||
goldmedalstandard,goldmedalseconds = dataprep.workout_goldmedalstandard(w)
|
||||
ids.append(w.id)
|
||||
if w.workouttype in mytypes.otwtypes:
|
||||
goldmedalstandard = goldmedalstandard / (1.-w.user.otwslack/100.)
|
||||
if goldmedalseconds > 60:
|
||||
goldmedalstandards.append(goldmedalstandard)
|
||||
goldmedaldurations.append(goldmedalseconds)
|
||||
@@ -1713,9 +1711,9 @@ def getfatigues(
|
||||
fatigue = 0
|
||||
fitness = 0
|
||||
|
||||
#impulses = []
|
||||
#for f in fatigues:
|
||||
# impulses.append(0)
|
||||
impulses = []
|
||||
for f in fatigues:
|
||||
impulses.append(0)
|
||||
|
||||
lambda_a = 2/(kfatigue+1)
|
||||
lambda_c = 2/(kfitness+1)
|
||||
@@ -1752,7 +1750,6 @@ def getfatigues(
|
||||
|
||||
impulses.append(weight)
|
||||
|
||||
|
||||
fatigue = (1-lambda_a)*fatigue+weight*lambda_a
|
||||
fitness = (1-lambda_c)*fitness+weight*lambda_c
|
||||
|
||||
@@ -1762,6 +1759,7 @@ def getfatigues(
|
||||
testpower.append(np.nan)
|
||||
testduration.append(np.nan)
|
||||
|
||||
|
||||
return fatigues,fitnesses,dates,testpower,testduration,impulses
|
||||
|
||||
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'
|
||||
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'
|
||||
p0 = 0
|
||||
@@ -1782,6 +1783,7 @@ def performance_chart(user,startdate=None,enddate=None,kfitness=42,kfatigue=7,
|
||||
fatigues = []
|
||||
fitnesses = []
|
||||
testduration = []
|
||||
impulses = []
|
||||
|
||||
if showtests:
|
||||
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:
|
||||
pass
|
||||
|
||||
|
||||
dates = [d for d in df['date']]
|
||||
testpower = df['testpower'].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,
|
||||
})
|
||||
|
||||
|
||||
endfitness = fitnesses[-1]
|
||||
endfatigue = fatigues[-1]
|
||||
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['date'] = df.index.values
|
||||
|
||||
#for row in df.iterrows():
|
||||
# print(row)
|
||||
|
||||
source = ColumnDataSource(
|
||||
data = dict(
|
||||
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()
|
||||
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()
|
||||
y1rangemax = df.loc[:,['fitness','fatigue']].max().max()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user