Skip to content

Commit

Permalink
Update output of notebook, and add .ipynb_checkpoints to .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayitzin committed Oct 1, 2024
1 parent 4f4ae10 commit cfaf62c
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*.DS_Store
build/*
dist/*
*/.ipynb_checkpoints/*

# test-related
.coverage
Expand Down
169 changes: 149 additions & 20 deletions notebooks/Showcase.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "af951b8628e04da1a5dd3dc9308a7701",
"model_id": "63a32ec81389462e8170cc5fd8e872e8",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -213,7 +213,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3600367061b3430ab0636f066888825c",
"model_id": "42d1864a7bcd4bc99dd0cd9e91adedb7",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -344,18 +344,11 @@
"Rotation of 30 degrees about Z-axis:\n",
"[[ 0.8660254 -0.5 0. ]\n",
" [ 0.5 0.8660254 0. ]\n",
" [ 0. 0. 1. ]]\n"
]
},
{
"ename": "NameError",
"evalue": "name 'rotation' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[7], line 14\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[38;5;66;03m# New rotation matrix from products of rotations about X-, Y-, and Z-axis, respectively.\u001b[39;00m\n\u001b[0;32m 11\u001b[0m \u001b[38;5;66;03m# Order of matrix multiplication is right to left: x --> y --> z\u001b[39;00m\n\u001b[0;32m 12\u001b[0m orientation \u001b[38;5;241m=\u001b[39m ahrs\u001b[38;5;241m.\u001b[39mDCM(z\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m30.0\u001b[39m\u001b[38;5;241m*\u001b[39mahrs\u001b[38;5;241m.\u001b[39mDEG2RAD) \u001b[38;5;241m@\u001b[39m ahrs\u001b[38;5;241m.\u001b[39mDCM(y\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m20.0\u001b[39m\u001b[38;5;241m*\u001b[39mahrs\u001b[38;5;241m.\u001b[39mDEG2RAD) \u001b[38;5;241m@\u001b[39m ahrs\u001b[38;5;241m.\u001b[39mDCM(x\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m10.0\u001b[39m\u001b[38;5;241m*\u001b[39mahrs\u001b[38;5;241m.\u001b[39mDEG2RAD)\n\u001b[1;32m---> 14\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRotation Matrix \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mtype\u001b[39m(\u001b[43mrotation\u001b[49m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 15\u001b[0m \u001b[38;5;28mprint\u001b[39m(orientation)\n",
"\u001b[1;31mNameError\u001b[0m: name 'rotation' is not defined"
" [ 0. 0. 1. ]]\n",
"Rotation Matrix <class 'ahrs.common.dcm.DCM'>:\n",
"[[ 0.81379768 -0.44096961 0.37852231]\n",
" [ 0.46984631 0.88256412 0.01802831]\n",
" [-0.34202014 0.16317591 0.92541658]]\n"
]
}
],
Expand Down Expand Up @@ -387,10 +380,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "3b2f1a04-6dd1-4e94-a53f-de1c28c22cf2",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"DCM([[ 0.81379768, -0.44096961, 0.37852231],\n",
" [ 0.46984631, 0.88256412, 0.01802831],\n",
" [-0.34202014, 0.16317591, 0.92541658]])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"orientation = ahrs.DCM( euler=('zyx', np.array([30.0, 20.0, 10.0])*ahrs.DEG2RAD) )\n",
"orientation.view()"
Expand All @@ -408,10 +414,59 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "046c9a46-5b4b-4e5c-a4f8-e4e9c40afa7e",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rotation.T =\n",
"[[ 0.81379768 0.46984631 -0.34202014]\n",
" [-0.44096961 0.88256412 0.16317591]\n",
" [ 0.37852231 0.01802831 0.92541658]] \n",
"\n",
"rotation.I =\n",
"[[ 0.81379768 0.46984631 -0.34202014]\n",
" [-0.44096961 0.88256412 0.16317591]\n",
" [ 0.37852231 0.01802831 0.92541658]] \n",
"\n",
"rotation.inv =\n",
"[[ 0.81379768 0.46984631 -0.34202014]\n",
" [-0.44096961 0.88256412 0.16317591]\n",
" [ 0.37852231 0.01802831 0.92541658]] \n",
"\n",
"rotation.det =\n",
"1.0000000000000002 \n",
"\n",
"rotation.determinant =\n",
"1.0000000000000002 \n",
"\n",
"rotation.fro =\n",
"1.7320508075688772 \n",
"\n",
"rotation.frobenius =\n",
"1.7320508075688772 \n",
"\n",
"rotation.adj =\n",
"[[ 0.81379768 0.46984631 -0.34202014]\n",
" [-0.44096961 0.88256412 0.16317591]\n",
" [ 0.37852231 0.01802831 0.92541658]] \n",
"\n",
"rotation.adjugate =\n",
"[[ 0.81379768 0.46984631 -0.34202014]\n",
" [-0.44096961 0.88256412 0.16317591]\n",
" [ 0.37852231 0.01802831 0.92541658]] \n",
"\n",
"rotation.log =\n",
"[[ 0. 0.48647923 -0.38485157]\n",
" [-0.48647923 0. 0.07752532]\n",
" [ 0.38485157 -0.07752532 0. ]] \n",
"\n"
]
}
],
"source": [
"attribute_list = ['T', 'I', 'inv', 'det', 'determinant', 'fro', 'frobenius', 'adj', 'adjugate', 'log']\n",
"for attribute_name in attribute_list:\n",
Expand All @@ -431,10 +486,84 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "5eedfc5e-b40b-47cc-ba29-eae8f89491bc",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DCM.all() Returns True if all elements evaluate to True.\n",
"DCM.any() Returns True if any of the elements of `a` evaluate to True.\n",
"DCM.argmax() Return indices of the maximum values along the given axis.\n",
"DCM.argmin() Return indices of the minimum values along the given axis.\n",
"DCM.argpartition() Returns the indices that would partition this array.\n",
"DCM.argsort() Returns the indices that would sort this array.\n",
"DCM.astype() Copy of the array, cast to a specified type.\n",
"DCM.byteswap() Swap the bytes of the array elements\n",
"DCM.choose() Use an index array to construct a new array from a set of choices.\n",
"DCM.clip() Return an array whose values are limited to ``[min, max]``.\n",
"DCM.compress() Return selected slices of this array along given axis.\n",
"DCM.conj() Complex-conjugate all elements.\n",
"DCM.conjugate() Return the complex conjugate, element-wise.\n",
"DCM.copy() Return a copy of the array.\n",
"DCM.cumprod() Return the cumulative product of the elements along the given axis.\n",
"DCM.cumsum() Return the cumulative sum of the elements along the given axis.\n",
"DCM.diagonal() Return specified diagonals. In NumPy 1.9 the returned array is a\n",
"DCM.dot() <No description found>\n",
"DCM.dump() Dump a pickle of the array to the specified file.\n",
"DCM.dumps() Returns the pickle of the array as a string.\n",
"DCM.fill() Fill the array with a scalar value.\n",
"DCM.flatten() Return a copy of the array collapsed into one dimension.\n",
"DCM.from_axang() Synonym of method `from_axisangle`.\n",
"DCM.from_axisangle() DCM from axis-angle representation\n",
"DCM.from_q() Synonym of method `from_quaternion`.\n",
"DCM.from_quaternion() DCM from given quaternion\n",
"DCM.getfield() Returns a field of the given array as a certain type.\n",
"DCM.item() Copy an element of an array to a standard Python scalar and return it.\n",
"DCM.itemset() Insert scalar into an array (scalar is cast to array's dtype, if possible)\n",
"DCM.max() Return the maximum along a given axis.\n",
"DCM.mean() Returns the average of the array elements along given axis.\n",
"DCM.min() Return the minimum along a given axis.\n",
"DCM.newbyteorder() Return the array with the same data viewed with a different byte order.\n",
"DCM.nonzero() Return the indices of the elements that are non-zero.\n",
"DCM.ode() Ordinary Differential Equation of the DCM.\n",
"DCM.partition() Rearranges the elements in the array in such a way that the value of the\n",
"DCM.prod() Return the product of the array elements over the given axis\n",
"DCM.ptp() Peak to peak (maximum - minimum) value along a given axis.\n",
"DCM.put() Set ``a.flat[n] = values[n]`` for all `n` in indices.\n",
"DCM.ravel() Return a flattened array.\n",
"DCM.repeat() Repeat elements of an array.\n",
"DCM.reshape() Returns an array containing the same data with a new shape.\n",
"DCM.resize() Change shape and size of array in-place.\n",
"DCM.round() Return `a` with each element rounded to the given number of decimals.\n",
"DCM.searchsorted() Find indices where elements of v should be inserted in a to maintain order.\n",
"DCM.setfield() Put a value into a specified place in a field defined by a data-type.\n",
"DCM.setflags() Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY,\n",
"DCM.sort() Sort an array in-place. Refer to `numpy.sort` for full documentation.\n",
"DCM.squeeze() Remove axes of length one from `a`.\n",
"DCM.std() Returns the standard deviation of the array elements along given axis.\n",
"DCM.sum() Return the sum of the array elements over the given axis.\n",
"DCM.swapaxes() Return a view of the array with `axis1` and `axis2` interchanged.\n",
"DCM.take() Return an array formed from the elements of `a` at the given indices.\n",
"DCM.to_angles() Synonym of method `to_rpy`.\n",
"DCM.to_axang() Synonym of method `to_axisangle`.\n",
"DCM.to_axisangle() Return axis-angle representation of the DCM.\n",
"DCM.to_q() Synonym of method `to_quaternion`.\n",
"DCM.to_quaternion() Quaternion from Direction Cosine Matrix.\n",
"DCM.to_rpy() Roll-Pitch-Yaw Angles from DCM\n",
"DCM.tobytes() Construct Python bytes containing the raw data bytes in the array.\n",
"DCM.tofile() Write array to a file as text or binary (default).\n",
"DCM.tolist() Return the array as an ``a.ndim``-levels deep nested list of Python scalars.\n",
"DCM.tostring() A compatibility alias for `tobytes`, with exactly the same behavior.\n",
"DCM.trace() Return the sum along diagonals of the array.\n",
"DCM.transpose() Returns a view of the array with axes transposed.\n",
"DCM.var() Returns the variance of the array elements, along given axis.\n",
"DCM.view() New view of array with the same data.\n"
]
}
],
"source": [
"# List all DCM methods and the first descriptive line from each docstring\n",
"from tools import describe_methods\n",
Expand Down

0 comments on commit cfaf62c

Please sign in to comment.