working predictions and fit type
This commit is contained in:
@@ -274,6 +274,8 @@ def trendflexdata(workouts, options,userid=0):
|
||||
workmin = options['workmin']
|
||||
workmax = options['workmax']
|
||||
ploterrorbars = options['ploterrorbars']
|
||||
cpfit = options['cpfit']
|
||||
piece = options['piece']
|
||||
ids = options['ids']
|
||||
workstrokesonly = not includereststrokes
|
||||
|
||||
@@ -502,7 +504,7 @@ def histodata(workouts, options):
|
||||
|
||||
def cpdata(workouts, options):
|
||||
userid = options['userid']
|
||||
|
||||
cpfit = options['cpfit']
|
||||
|
||||
u = User.objects.get(id=userid)
|
||||
r = u.rower
|
||||
@@ -527,17 +529,18 @@ def cpdata(workouts, options):
|
||||
rowername = r.user.first_name+" "+r.user.last_name
|
||||
|
||||
if len(powerdf) !=0 :
|
||||
res = interactive_otwcpchart(powerdf,promember=True,rowername=rowername)
|
||||
res = interactive_otwcpchart(powerdf,promember=True,rowername=rowername,r=r,
|
||||
cpfit=cpfit)
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
p1 = res[2]
|
||||
ratio = res[3]
|
||||
r.p0 = p1[0]
|
||||
r.p1 = p1[1]
|
||||
r.p2 = p1[2]
|
||||
r.p3 = p1[3]
|
||||
r.cpratio = ratio
|
||||
r.save()
|
||||
#r.p0 = p1[0]
|
||||
#r.p1 = p1[1]
|
||||
#r.p2 = p1[2]
|
||||
#r.p3 = p1[3]
|
||||
#r.cpratio = ratio
|
||||
#r.save()
|
||||
paulslope = 1
|
||||
paulintercept = 1
|
||||
message = res[4]
|
||||
@@ -547,12 +550,57 @@ def cpdata(workouts, options):
|
||||
paulslope = 1
|
||||
paulintercept = 1
|
||||
p1 = [1,1,1,1]
|
||||
ratio = 1
|
||||
message = ""
|
||||
|
||||
scripta = script.split('\n')[2:-1]
|
||||
script = ''.join(scripta)
|
||||
|
||||
return (script,div)
|
||||
minutes = options['piece']
|
||||
if minutes != 0:
|
||||
hourvalue,tvalue = divmod(minutes,60)
|
||||
hourvalue = int(hourvalue)
|
||||
minutevalue = int(tvalue)
|
||||
tvalue = int(60*(tvalue-minutevalue))
|
||||
if hourvalue >= 24:
|
||||
hourvalue = 23
|
||||
pieceduration = datetime.time(
|
||||
minute = minutevalue,
|
||||
hour = hourvalue,
|
||||
second = tvalue,
|
||||
)
|
||||
pieceseconds = 2600.*pieceduration.hour+60.*pieceduration.minute+pieceduration.second
|
||||
# CP model
|
||||
pwr = p1[0]/(1+pieceseconds/p1[2])
|
||||
pwr += p1[1]/(1+pieceseconds/p1[3])
|
||||
|
||||
if pwr <= 0:
|
||||
pwr = 50.
|
||||
|
||||
if not np.isnan(pwr):
|
||||
try:
|
||||
pwr2 = pwr*ratio
|
||||
except:
|
||||
pwr2 = pwr
|
||||
|
||||
duration = timedeltaconv(pieceseconds)
|
||||
power = int(pwr)
|
||||
upper = int(pwr2)
|
||||
else:
|
||||
duration = timedeltaconv(0)
|
||||
power = 0
|
||||
upper = 0
|
||||
|
||||
htmly = env.get_template('otwcp.html')
|
||||
html_content = htmly.render({
|
||||
'script':script,
|
||||
'the_div':div,
|
||||
'duration':duration,
|
||||
'power':power,
|
||||
'upper':upper,
|
||||
})
|
||||
|
||||
return (script,html_content)
|
||||
|
||||
def statsdata(workouts, options):
|
||||
includereststrokes = options['includereststrokes']
|
||||
|
||||
Reference in New Issue
Block a user