adding critical stroke rate chart
This commit is contained in:
@@ -1113,6 +1113,75 @@ def interactive_otwcpchart(powerdf, promember=0, rowername="", r=None,
|
||||
return [script, div, p1, ratio, message]
|
||||
|
||||
|
||||
def interactive_otwcrchart(powerdf, promember=0, rowername="", r=None,
|
||||
cpfit='data',
|
||||
title='', type='water'):
|
||||
|
||||
powerdf2 = powerdf.filter((pl.col("Delta") > 0) & (pl.col("CR") > 0))
|
||||
|
||||
# plot tools
|
||||
if (promember == 1): # pragma: no cover
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||
else:
|
||||
TOOLS = 'pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||
|
||||
x_axis_type = 'log'
|
||||
|
||||
deltas = powerdf2['Delta'].apply(lambda x: timedeltaconv(x))
|
||||
powerdf2 = powerdf2.with_columns(
|
||||
ftime = deltas.apply(lambda x: strfdelta(x)),
|
||||
Deltaminutes = pl.col("Delta")/60.
|
||||
)
|
||||
|
||||
# there is no Paul's law for OTW
|
||||
|
||||
thesecs = powerdf2['Delta']
|
||||
theavpower = powerdf2['CR']
|
||||
|
||||
p1, fitt, fitpower, ratio = datautils.cpfit(powerdf2)
|
||||
if cpfit == 'automatic' and r is not None:
|
||||
if type == 'water':
|
||||
p1 = [r.r0, r.r1, r.r2, r.r3]
|
||||
ratio = r.cpratio
|
||||
elif type == 'erg': # pragma: no cover
|
||||
p1 = [r.er0, r.er1, r.er2, r.er3]
|
||||
ratio = r.ecrratio
|
||||
|
||||
def fitfunc(pars, x):
|
||||
return abs(pars[0])/(1+(x/abs(pars[2]))) + abs(pars[1])/(1+(x/abs(pars[3])))
|
||||
|
||||
fitpower = fitfunc(p1, fitt)
|
||||
|
||||
message = ""
|
||||
# if len(fitpower[fitpower<0]) > 0:
|
||||
# message = "CP model fit didn't give correct results"
|
||||
|
||||
deltas = fitt.apply(lambda x: timedeltaconv(x))
|
||||
ftime = niceformat(deltas)
|
||||
|
||||
|
||||
|
||||
fit_data = pl.DataFrame(dict(
|
||||
CR=fitpower,
|
||||
CRmax=ratio*fitpower,
|
||||
duration=fitt/60.,
|
||||
ftime=ftime,
|
||||
))
|
||||
|
||||
if not title:
|
||||
title = "Critical StrokeRate for "+rowername
|
||||
|
||||
chart_dict = {
|
||||
'data': powerdf2.to_dicts(),
|
||||
'fitdata': fit_data.to_dicts(),
|
||||
'title': title,
|
||||
}
|
||||
|
||||
script, div = get_chart("/cr", chart_dict)
|
||||
|
||||
return [script, div, p1, ratio, message]
|
||||
|
||||
|
||||
def interactive_agegroup_plot(df, distance=2000, duration=None,
|
||||
sex='male', weightcategory='hwt'):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user