Takes one ForceTimeStampXXXX.csv file and plots a grid of F v T, F v P, and P v T.
Manipulations
Plot features
To Do
In [1]:
import numpy as np
import pandas as pd
from bokeh.layouts import gridplot
from bokeh.plotting import figure, show
from bokeh.io import output_notebook, output_file
from bokeh.models import HoverTool
In [2]:
output_notebook()
output_file("ForceTimeStampPlot.html")
In [3]:
df=pd.read_csv('ForceTimestamp20160713_051922.csv')
In [4]:
df.head(5)
Out[4]:
In [6]:
timezero = df.loc[0,' milliseconds']
df['Time']= (df[' milliseconds']-timezero) / 1000
In [7]:
df.columns
Out[7]:
In [8]:
df.head(5)
Out[8]:
In [10]:
forceconversion = 35 # counts per gram
df['Force'] = df[' Compensated Force'] / forceconversion
In [12]:
positionzero = df.loc[0,' Position']
df['Position'] = df[' Position']-positionzero
In [13]:
df.head(5)
Out[13]:
In [14]:
df['AverageForce'] = df['Force'].rolling(center=True,window=19).mean()
df.fillna(value=0)
Out[14]:
In [15]:
TOOLS = 'box_zoom,wheel_zoom,pan,crosshair,reset'
hover1 = HoverTool(
tooltips=[
("index", "$index"),
("(x,y)", "($x, $y)"),
]
)
hover2 = HoverTool(
tooltips=[
("index", "$index"),
("(x,y)", "($x, $y)"),
]
)
hover3 = HoverTool(
tooltips=[
("index", "$index"),
("(x,y)", "($x, $y)"),
]
)
p1 = figure(title="Force vs. Time", toolbar_location = 'above', tools=[TOOLS,hover1])
p1.grid.grid_line_alpha=0.3
p1.xaxis.axis_label = 'Time [s]'
p1.yaxis.axis_label = 'Force [g]'
p1.line(df['Time'],df['Force'], color="firebrick", alpha=0.3, line_width=2)
p1.line(df['Time'],df['AverageForce'], color="navy", alpha=0.8, line_width=2)
p2 = figure(title="Force vs. Position", toolbar_location = 'above', tools=[TOOLS,hover2])
p2.grid.grid_line_alpha=0.3
p2.xaxis.axis_label = 'Position [mm]'
p2.yaxis.axis_label = 'Force [g]'
p2.line(df['Position'],df['Force'], color="firebrick", alpha=0.3, line_width=2)
p2.line(df['Position'],df['AverageForce'], color="navy", alpha=0.8, line_width=2)
p3 = figure(title="Position vs. Time", toolbar_location = 'right', tools=[TOOLS,hover3])
p3.grid.grid_line_alpha=0.3
p3.xaxis.axis_label = 'Time [s]'
p3.yaxis.axis_label = 'Position [mm]'
p3.line(df['Time'],df['Position'])
grid = gridplot([p1,p2],[p3,None], merge_tools=False)
show(grid)
In [ ]: