In [1]:
%matplotlib inline
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt

mpl.rcParams['legend.fontsize'] = 10
mpl.interactive(True)

fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
p = ax.plot(x, y, z, label='parametric curve')
ax.legend()

plt.draw()



In [2]:
def grid_me(ax):
    ax.grid(color='0.75', linestyle='--', linewidth=1)

In [15]:
def graph_it(ts, Ms):
    fig = plt.figure(figsize=(12, 10), dpi=80, facecolor='w', edgecolor='k')
    ax = fig.add_subplot(2,1,1)
    ax.plot(ts, [M[0] for M in Ms], c='b', label=r'$M_x$', lw=2)
    ax.plot(ts, [M[1] for M in Ms], c='r', label=r'$M_y$', lw=2)
    ax.plot(ts, [M[2] for M in Ms], c='g', label=r'$M_z$', lw=2)
    ax.set_ylabel(r'Moment (Nm)')
    grid_me(ax)
    plt.legend(prop={'size':10})
    plt.show()

In [14]:
ts = range(10)
Ms = np.random.rand(10,3)
graph_it(ts, Ms)


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-14-e5f72d01f6f4> in <module>()
      1 ts = range(10)
      2 Ms = np.random.rand(10,3)
----> 3 graph_it(ts, Ms)

<ipython-input-11-7b18ec0ac28d> in graph_it(ts, Ms)
      5     ax.plot(ts, [M[1] for M in Ms], c='r', label=r'$M_y$', lw=2)
      6     ax.plot(ts, [M[2] for M in Ms], c='g', label=r'$M_z$', lw=2)
----> 7     ax.plot(ts, [M[3] for M in Ms], c='y', label=r'$M_z$', lw=2)
      8     ax.set_ylabel(r'Moment (Nm)')
      9     grid_me(ax)

IndexError: index out of bounds

In [5]:
from TSatPy.State import Quaternion

In [7]:
a = Quaternion([0,0,1], radians=3)

In [9]:
a.decompose()


Out[9]:
(<Quaternion [0 0 -0.997495], 0.0707372>, <Quaternion [0 0 0], 1>)

In [ ]: