{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%matplotlib inline\n", "from __future__ import division\n", "\n", "import numpy as np # For matrix manipulation\n", "import datetime # For convertim time to date\n", "\n", "import pandas as pd # Used for data handling and manipulation\n", "import matplotlib.pyplot as plt # Used for plotting spectrum\n", "import matplotlib.pylab as pylab # Used for increasing size of plot\n", "from mpl_toolkits.mplot3d import Axes3D # For 3 D plot\n", "\n", "import plotly \n", "plotly.tools.set_credentials_file(username='rasp.pi.sensor', api_key='o6as73e2ve')\n", "import plotly.plotly as py # Plotly 3d plot\n", "import plotly.graph_objs as go # Plotly 3d plot\n", "\n", "# Plotly offline\n", "from plotly import __version__\n", "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\n", "init_notebook_mode(connected=True)\n", "\n", "import scipy.interpolate as interpolate # Interpolation\n", "import scipy.optimize as optimize # Finding intersections\n", "\n", "# For low pass filter\n", "from scipy.signal import butter, lfilter, freqz\n", "\n", "# For calculating uncertainties\n", "#from uncertainties import ufloat\n", "#from uncertainties.umath import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Read accelerometer csv for 5 points\n", "for i in range(1,6):\n", " globals()[\"p\"+str(i)] = pd.read_csv('p'+str(i)+'.csv')\n", " # Make Time column index and convert to DateTime\n", " globals()[\"p\"+str(i)].index = pd.DatetimeIndex(globals()[\"p\"+str(i)]['Time']*1000000000)\n", "\n", "# Read body data \n", "body = pd.read_csv('body.csv')\n", "body.index = pd.DatetimeIndex(body['Time']*1000000000)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "marker": { "line": { "color": "rgba(217, 217, 217, 0.14)", "width": 0.5 }, "opacity": 0.8, "size": 6 }, "mode": "markers+text", "text": [ "p1", "p2", "p3", "p4", "p5(C)" ], "type": "scatter3d", "x": [ 599.629, 2820.8959999999997, 1297.55, 2180.3720000000003, 1643.545 ], "y": [ 2236.0370000000003, 2310.044, 2121.8320000000003, 2367.1710000000003, 2280.325 ], "z": [ 14.446, 26.469, 9.117, 14.459000000000001, 17.303 ] } ], "layout": { "margin": { "b": 0, "l": 0, "r": 0, "t": 0 }, "scene": { "xaxis": { "title": "X Axis [mm]" }, "yaxis": { "range": [ 1800, 3200 ], "title": "Y Axis [mm]" }, "zaxis": { "range": [ -100, 100 ], "title": "Z Axis [mm]" } }, "title": "Position of markers" } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# SHOW POSITIONS OF ACCELEROMETERS on ASV\n", "time = 20 # secs\n", "# Use time to obtain index using sampling freq of 60Hz (period = 1/60)\n", "t = round(time / round(1/60,6))\n", "\n", "xs = [p1.Pos_X[t],p2.Pos_X[t],p3.Pos_X[t],p4.Pos_X[t],p5.Pos_X[t]]\n", "ys = [p1.Pos_Y[t],p2.Pos_Y[t],p3.Pos_Y[t],p4.Pos_Y[t],p5.Pos_Y[t]]\n", "zs = [p1.Pos_Z[t],p2.Pos_Z[t],p3.Pos_Z[t],p4.Pos_Z[t],p5.Pos_Z[t]]\n", "lbls = ['p1','p2','p3','p4','p5(C)']\n", "\n", "trace1 = go.Scatter3d(x=xs,y=ys,z=zs,text=lbls,mode='markers+text',\n", " marker=dict(size=6,\n", " line=dict(color='rgba(217, 217, 217, 0.14)',\n", " width=0.5),\n", " opacity=0.8))\n", "\n", "data = [trace1]\n", "layout = go.Layout(title = 'Position of markers',\n", " scene = dict(xaxis=dict(title = 'X Axis [mm]'),\n", " #range=[0,3000]),\n", " yaxis=dict(title = 'Y Axis [mm]',\n", " range=[1800,3200]),\n", " zaxis=dict(title = 'Z Axis [mm]',\n", " range=[-100,100])),\n", " margin=dict(l=0,r=0,b=0,t=0))\n", "\n", "fig = go.Figure(data=data, layout=layout)\n", "#py.iplot(fig, filename='simple-3d-scatter')\n", "plotly.offline.iplot(fig, filename='simple-3d-scatter')" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "