plotting some help lines and data points force curve
This commit is contained in:
@@ -403,6 +403,34 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
if rowdata.empty:
|
if rowdata.empty:
|
||||||
return "","No Valid Data Available","",""
|
return "","No Valid Data Available","",""
|
||||||
|
|
||||||
|
|
||||||
|
# quick linear regression
|
||||||
|
# peakforce = slope*peakforceangle + intercept
|
||||||
|
slope, intercept, r,p,stderr = linregress(rowdata['peakforceangle'],rowdata['peakforce'])
|
||||||
|
theta = np.arctan(slope)
|
||||||
|
|
||||||
|
a = rowdata['peakforceangle']-rowdata['peakforceangle'].mean()
|
||||||
|
F = rowdata['peakforce']-rowdata['peakforce'].mean()
|
||||||
|
|
||||||
|
R = np.array([[np.cos(theta),np.sin(theta)],
|
||||||
|
[-np.sin(theta),np.cos(theta)]])
|
||||||
|
Rinv = np.array([[np.cos(theta),np.sin(theta)],
|
||||||
|
[-np.sin(theta),np.cos(theta)]])
|
||||||
|
|
||||||
|
x = R[0,0]*a+R[0,1]*F
|
||||||
|
y = R[1,0]*a+R[1,1]*F
|
||||||
|
|
||||||
|
|
||||||
|
x05 = x.quantile(q=0.05)
|
||||||
|
x25 = x.quantile(q=0.25)
|
||||||
|
x75 = x.quantile(q=0.75)
|
||||||
|
x95 = x.quantile(q=0.95)
|
||||||
|
|
||||||
|
y05 = y.quantile(q=0.05)
|
||||||
|
y25 = y.quantile(q=0.25)
|
||||||
|
y75 = y.quantile(q=0.75)
|
||||||
|
y95 = y.quantile(q=0.95)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
catchav = rowdata['catch'].mean()
|
catchav = rowdata['catch'].mean()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -427,6 +455,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
peakforceav = 0
|
peakforceav = 0
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
averageforceav = rowdata['averageforce'].mean()
|
averageforceav = rowdata['averageforce'].mean()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -437,6 +466,19 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
peakforceangleav = 0
|
peakforceangleav = 0
|
||||||
|
|
||||||
|
peakforceangle05 = rowdata['peakforceangle'].quantile(q=0.05)
|
||||||
|
peakforce05 = rowdata['peakforce'].quantile(q=0.05)
|
||||||
|
|
||||||
|
peakforceangle25 = rowdata['peakforceangle'].quantile(q=0.25)
|
||||||
|
peakforce25 = rowdata['peakforce'].quantile(q=0.25)
|
||||||
|
|
||||||
|
peakforceangle75 = rowdata['peakforceangle'].quantile(q=0.75)
|
||||||
|
peakforce75 = rowdata['peakforce'].quantile(q=0.75)
|
||||||
|
|
||||||
|
peakforceangle95 = rowdata['peakforceangle'].quantile(q=0.95)
|
||||||
|
peakforce95 = rowdata['peakforce'].quantile(q=0.95)
|
||||||
|
|
||||||
|
|
||||||
x = [catchav,
|
x = [catchav,
|
||||||
catchav+slipav,
|
catchav+slipav,
|
||||||
peakforceangleav,
|
peakforceangleav,
|
||||||
@@ -455,11 +497,31 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
y = y,
|
y = y,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
sourcetrend = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
x = [peakforceangle25,peakforceangle75],
|
||||||
|
y = [peakforce25,peakforce75]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
sourcefit = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
x = rowdata['peakforceangle'],
|
||||||
|
y = slope*rowdata['peakforceangle']+intercept
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
source2 = ColumnDataSource(
|
source2 = ColumnDataSource(
|
||||||
rowdata
|
rowdata
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sourcepoints = ColumnDataSource(
|
||||||
|
data = dict(
|
||||||
|
peakforceangle = rowdata['peakforceangle'],
|
||||||
|
peakforce = rowdata['peakforce']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
plot = Figure(tools=TOOLS,
|
plot = Figure(tools=TOOLS,
|
||||||
toolbar_sticky=False,toolbar_location="above")
|
toolbar_sticky=False,toolbar_location="above")
|
||||||
|
|
||||||
@@ -493,7 +555,10 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
avf = Span(location=averageforceav,dimension='width',line_color='blue',
|
avf = Span(location=averageforceav,dimension='width',line_color='blue',
|
||||||
line_dash=[6,6],line_width=2)
|
line_dash=[6,6],line_width=2)
|
||||||
|
|
||||||
|
plot.circle('peakforceangle','peakforce',source=sourcepoints,color='cyan')
|
||||||
plot.line('x','y',source=source,color="red")
|
plot.line('x','y',source=source,color="red")
|
||||||
|
plot.line('x','y',source=sourcetrend,color="blue")
|
||||||
|
plot.line('x','y',source=sourcefit,color="green")
|
||||||
|
|
||||||
plot.add_layout(avf)
|
plot.add_layout(avf)
|
||||||
|
|
||||||
@@ -585,6 +650,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
callback = CustomJS(args = dict(
|
callback = CustomJS(args = dict(
|
||||||
source=source,
|
source=source,
|
||||||
source2=source2,
|
source2=source2,
|
||||||
|
sourcepoints=sourcepoints,
|
||||||
avf=avf,
|
avf=avf,
|
||||||
avflabel=avflabel,
|
avflabel=avflabel,
|
||||||
catchlabel=catchlabel,
|
catchlabel=catchlabel,
|
||||||
@@ -598,6 +664,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
), code="""
|
), code="""
|
||||||
var data = source.data
|
var data = source.data
|
||||||
var data2 = source2.data
|
var data2 = source2.data
|
||||||
|
var datapoints = sourcepoints.data
|
||||||
|
|
||||||
var x = data['x']
|
var x = data['x']
|
||||||
var y = data['y']
|
var y = data['y']
|
||||||
@@ -636,11 +703,15 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
var peakforceav = 0
|
var peakforceav = 0
|
||||||
var count = 0
|
var count = 0
|
||||||
|
|
||||||
|
datapoints['peakforceangle'] = []
|
||||||
|
datapoints['peakforce'] = []
|
||||||
|
|
||||||
for (i=0; i<c.length; i++) {
|
for (i=0; i<c.length; i++) {
|
||||||
if (spm1[i]>=minspm && spm1[i]<=maxspm) {
|
if (spm1[i]>=minspm && spm1[i]<=maxspm) {
|
||||||
if (distance1[i]>=mindist && distance1[i]<=maxdist) {
|
if (distance1[i]>=mindist && distance1[i]<=maxdist) {
|
||||||
if (driveenergy1[i]>=minwork && driveenergy1[i]<=maxwork) {
|
if (driveenergy1[i]>=minwork && driveenergy1[i]<=maxwork) {
|
||||||
|
datapoints['peakforceangle'].push(peakforceangle[i])
|
||||||
|
datapoints['peakforce'].push(peakforce[i])
|
||||||
catchav += c[i]
|
catchav += c[i]
|
||||||
finishav += finish[i]
|
finishav += finish[i]
|
||||||
slipav += slip[i]
|
slipav += slip[i]
|
||||||
@@ -677,6 +748,7 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False):
|
|||||||
|
|
||||||
// source.trigger('change');
|
// source.trigger('change');
|
||||||
source.change.emit();
|
source.change.emit();
|
||||||
|
sourcepoints.change.emit();
|
||||||
""")
|
""")
|
||||||
|
|
||||||
annotation = TextInput(title="Type your plot notes here", value="",
|
annotation = TextInput(title="Type your plot notes here", value="",
|
||||||
|
|||||||
Reference in New Issue
Block a user