Private
Public Access
1
0

beginning of forcecuve_compare

This commit is contained in:
2024-04-05 17:19:34 +02:00
parent fce523ef5d
commit 560800f80c
3 changed files with 49 additions and 51 deletions

View File

@@ -522,8 +522,6 @@ def interactive_activitychart2(workouts, startdate, enddate, stack='type',
return script, div
def interactive_forcecurve(theworkouts):
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
ids = [int(w.id) for w in theworkouts]
boattype = theworkouts[0].boattype
@@ -1990,52 +1988,42 @@ def interactive_streamchart(id=0, promember=0):
def forcecurve_multi_interactive_chart(selected): # pragma: no cover
df_plot = pd.DataFrame()
ids = [analysis.id for analysis in selected]
workoutids = [analysis.workout.id for analysis in selected]
selected_dict = [ForceCurveAnalysisSerializer(analysis).data for analysis in selected]
columns = ['catch', 'slip', 'wash', 'finish', 'averageforce',
'peakforceangle', 'peakforce', 'spm', 'distance',
'workoutstate', 'driveenergy']
'workoutstate', 'driveenergy', 'cumdist']
rowdata = dataprep.getsmallrowdata_db(columns, ids=workoutids,
workstrokesonly=False)
rowdata.dropna(axis=1, how='all', inplace=True)
rowdata.dropna(axis=0, how='any', inplace=True)
if rowdata.empty:
return "", "No Valid Data Available", "", ""
data_dict = rowdata.to_dict("records")
thresholdforces = []
for analysis in selected:
workstrokesonly = not analysis.include_rest_strokes
spm_min = analysis.spm_min
spm_max = analysis.spm_max
dist_min = analysis.dist_min
dist_max = analysis.dist_max
work_min = analysis.work_min
work_max = analysis.work_max
rowdata = dataprep.getsmallrowdata_db(columns, ids=[analysis.workout.id],
workstrokesonly=workstrokesonly)
boattype = analysis.workout.boattype
thresholdforce = 100. if 'x' in boattype else 200.
thresholdforces.append({'id': analysis.workout.id, 'thresholdforce': thresholdforce})
rowdata = rowdata[rowdata['spm']>spm_min]
rowdata = rowdata[rowdata['spm']<spm_max]
rowdata = rowdata[rowdata['driveenergy']>work_min]
rowdata = rowdata[rowdata['driveenergy']<work_max]
rowdata = rowdata[rowdata['distance']<dist_max]
rowdata = rowdata[rowdata['distance']>dist_min]
catchav = rowdata['catch'].median()
finishav = rowdata['finish'].median()
washav = (rowdata['finish']-rowdata['wash']).median()
slipav = (rowdata['slip']+rowdata['catch']).median()
peakforceav = rowdata['peakforce'].median()
peakforceangleav = rowdata['peakforceangle'].median()
thresholdforce = 100 if 'x' in analysis.workout.boattype else 200
x = [catchav,
slipav,
peakforceangleav,
washav,
finishav]
y = [0, thresholdforce,
peakforceav,
thresholdforce, 0]
xname = 'x_'+str(analysis.id)
yname = 'y_'+str(analysis.id)
df_plot[xname] = x
df_plot[yname] = y
chart_data = {
'title': '',
'data': data_dict,
'thresholdforces': thresholdforces,
'forcecurve_analyses': selected_dict,
}
script, div = get_chart("/forcecurve_compare", chart_data)
return script, div
source = ColumnDataSource(
df_plot
)