MVP in-stroke analysis comparison
This commit is contained in:
@@ -5,7 +5,7 @@ from rowers.metrics import rowingmetrics, metricsdicts
|
||||
from scipy.spatial import ConvexHull, Delaunay
|
||||
from scipy.stats import linregress, percentileofscore
|
||||
from pytz import timezone as tz, utc
|
||||
from rowers.models import course_spline, VirtualRaceResult
|
||||
from rowers.models import course_spline, VirtualRaceResult, InStrokeAnalysis
|
||||
from bokeh.palettes import Category20c, Category10
|
||||
from bokeh.layouts import layout, widgetbox
|
||||
from bokeh.resources import CDN, INLINE
|
||||
@@ -4078,6 +4078,81 @@ def interactive_streamchart(id=0, promember=0):
|
||||
|
||||
return [script, div]
|
||||
|
||||
def instroke_multi_interactive_chart(selected):
|
||||
df_plot = pd.DataFrame()
|
||||
ids = [analysis.id for analysis in selected]
|
||||
for analysis in selected:
|
||||
#start_second, end_second, spm_min, spm_max, name
|
||||
activeminutesmin = int(analysis.start_second/60.)
|
||||
activeminutesmax = int(analysis.end_second/60.)
|
||||
rowdata = rrdata(csvfile=analysis.workout.csvfilename)
|
||||
data = rowdata.get_instroke_data(
|
||||
analysis.metric,
|
||||
spm_min=analysis.spm_min,
|
||||
spm_max=analysis.spm_max,
|
||||
activeminutesmin=activeminutesmin,
|
||||
activeminutesmax=activeminutesmax,
|
||||
)
|
||||
mean_vals = data.mean()
|
||||
xvals = np.arange(len(mean_vals))
|
||||
xname = 'x_'+str(analysis.id)
|
||||
yname = 'y_'+str(analysis.id)
|
||||
df_plot[xname] = xvals
|
||||
df_plot[yname] = mean_vals
|
||||
|
||||
source = ColumnDataSource(
|
||||
df_plot
|
||||
)
|
||||
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,crosshair'
|
||||
plot = Figure(plot_width=920,tools=TOOLS,
|
||||
toolbar_location='above',
|
||||
toolbar_sticky=False)
|
||||
|
||||
plot.sizing_mode = 'stretch_both'
|
||||
|
||||
# add watermark
|
||||
watermarkurl = "/static/img/logo7.png"
|
||||
|
||||
watermarkrange = Range1d(start=0, end=1)
|
||||
watermarkalpha = 0.6
|
||||
watermarkx = 0.99
|
||||
watermarky = 0.01
|
||||
watermarkw = 184
|
||||
watermarkh = 35
|
||||
watermarkanchor = 'bottom_right'
|
||||
plot.extra_y_ranges = {"watermark": watermarkrange}
|
||||
plot.extra_x_ranges = {"watermark": watermarkrange}
|
||||
|
||||
plot.image_url([watermarkurl], watermarkx, watermarky,
|
||||
watermarkw, watermarkh,
|
||||
global_alpha=watermarkalpha,
|
||||
w_units='screen',
|
||||
h_units='screen',
|
||||
anchor=watermarkanchor,
|
||||
dilate=True,
|
||||
x_range_name="watermark",
|
||||
y_range_name="watermark",
|
||||
)
|
||||
|
||||
colors = itertools.cycle(palette)
|
||||
|
||||
try:
|
||||
items = itertools.izip(ids, colors)
|
||||
except AttributeError:
|
||||
items = zip(ids, colors)
|
||||
|
||||
for id, color in items:
|
||||
xname = 'x_'+str(id)
|
||||
yname = 'y_'+str(id)
|
||||
analysis = InStrokeAnalysis.objects.get(id=id)
|
||||
plot.line(xname,yname,source=source,legend_label=analysis.name,
|
||||
line_width=2, color=color)
|
||||
|
||||
script, div = components(plot)
|
||||
|
||||
return (script, div)
|
||||
|
||||
def instroke_interactive_chart(df,metric, workout, spm_min, spm_max,
|
||||
activeminutesmin, activeminutesmax,
|
||||
individual_curves,
|
||||
|
||||
Reference in New Issue
Block a user