Browse Source

Now import flight data and calibrate it

master
Nathan Bergey 2 years ago
parent
commit
ffc9c0a20a
  1. BIN
      data/L-12_flight.hdf5
  2. 171
      post.ipynb

BIN
data/L-12_flight.hdf5

171
post.ipynb

@ -7,7 +7,7 @@
"---\n",
"title: PSAS Magnetometer Calibration\n",
"author: Nathan\n",
"date: 2019/9/22\n",
"date: 2019/11/05\n",
"---"
]
},
@ -530,7 +530,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"\n",
@ -582,6 +584,171 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Applying to Flight Data\n",
"\n",
"We can now take our calibration matrix and apply it to real flight data! Here is a 3D look at the [Launch-12](https://github.com/psas/Launch-12) **raw** (uncalibrated) magnetometer data from liftoff to apogee:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"l12_data = h5py.File(\"data/L-12_flight.hdf5\", \"r\")\n",
"l12_adis = l12_data[\"ADIS\"]\n",
"\n",
"l12_time = np.array(l12_adis[\"time\"])\n",
"\n",
"l12_m_raw_x = np.array(l12_adis[\"mag_x\"]) * 1e6\n",
"l12_m_raw_y = np.array(l12_adis[\"mag_y\"]) * 1e6\n",
"l12_m_raw_z = np.array(l12_adis[\"mag_z\"]) * 1e6"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure(figsize=(24,24))\n",
"gs = gridspec.GridSpec(2, 2, width_ratios=[1, 1])\n",
"\n",
"ax1 = plt.subplot(gs[0])\n",
"plt.title(r\"Launch 12 Flight XY\")\n",
"plt.xlabel(r\"Magnetic Field X [$ \\mu$T]\")\n",
"plt.ylabel(r\"Magnetic Field Y [$ \\mu$T]\")\n",
"ax1.plot(l12_m_raw_x, l12_m_raw_y, lw=0.8, label=\"\")\n",
"ax1.add_patch(patches.Circle((0, 0), 53, edgecolor=\"#cccccc\", linewidth=1.0, linestyle='--', fill=False))\n",
"plt.xlim([-80,80])\n",
"plt.ylim([-80,80])\n",
"\n",
"ax2 = plt.subplot(gs[1])\n",
"plt.title(r\"Launch 12 Flight YZ\")\n",
"plt.xlabel(r\"Magnetic Field Y [$ \\mu$T]\")\n",
"plt.ylabel(r\"Magnetic Field Z [$ \\mu$T]\")\n",
"ax2.plot(l12_m_raw_y, l12_m_raw_z, lw=0.8, label=\"\")\n",
"ax2.add_patch(patches.Circle((0, 0), 53, edgecolor=\"#cccccc\", linewidth=1.0, linestyle='--', fill=False))\n",
"plt.xlim([-80,80])\n",
"plt.ylim([-80,80])\n",
"\n",
"ax3 = plt.subplot(gs[2])\n",
"plt.title(r\"Launch 12 Flight XZ\")\n",
"plt.xlabel(r\"Magnetic Field X [$ \\mu$T]\")\n",
"plt.ylabel(r\"Magnetic Field Z [$ \\mu$T]\")\n",
"ax3.plot(l12_m_raw_x, l12_m_raw_z, lw=0.8, label=\"\")\n",
"ax3.add_patch(patches.Circle((0, 0), 53, edgecolor=\"#cccccc\", linewidth=1.0, linestyle='--', fill=False))\n",
"plt.xlim([-80,80])\n",
"plt.ylim([-80,80])\n",
"\n",
"ax4 = plt.subplot(gs[3], projection='3d')\n",
"plt.title(r\"Launch 12 Flight XYZ\")\n",
"plt.xlabel(r\"Field Strength Y [$\\mu$T]\")\n",
"plt.ylabel(r\"Field Strength Z [$\\mu$T]\")\n",
"ax4.set_zlabel('Field Strength X [$\\mu$T]')\n",
"\n",
"ax4.plot_wireframe(x, y, z, color=\"k\", alpha=0.1, lw=0.2)\n",
"\n",
"ax4.plot(l12_m_raw_y, l12_m_raw_z, l12_m_raw_x, '-', lw=0.5)\n",
"ax4.plot([0],[0],[0], 'g.')\n",
"\n",
"ax4.set_xlim(-60, 60)\n",
"ax4.set_ylim(-60, 60)\n",
"ax4.set_zlim(-60, 60)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The rocket spins during flight, and we see the magnetic field measurement spiral around the plots. We also see the familiar stretch and offset that we saw in the calibration data.\n",
"\n",
"\n",
"## Calibrated Flight Data\n",
"\n",
"So now lets calibrate the flight data!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"l12_m_x = []\n",
"l12_m_y = []\n",
"l12_m_z = []\n",
"for i, t in enumerate(l12_time):\n",
" s = np.array((l12_m_raw_x[i], l12_m_raw_y[i], l12_m_raw_z[i])).reshape(3, 1)\n",
" s = apply_mag_correction(s)\n",
" mx, my, mz = s[0][0], s[1][0], s[2][0]\n",
" l12_m_x.append(mx)\n",
" l12_m_y.append(my)\n",
" l12_m_z.append(mz)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"class": "fullwidth"
},
"outputs": [],
"source": [
"fig = plt.figure(figsize=(24,24))\n",
"gs = gridspec.GridSpec(2, 2, width_ratios=[1, 1])\n",
"\n",
"ax1 = plt.subplot(gs[0])\n",
"plt.title(r\"Launch 12 Flight XY\")\n",
"plt.xlabel(r\"Magnetic Field X [$ \\mu$T]\")\n",
"plt.ylabel(r\"Magnetic Field Y [$ \\mu$T]\")\n",
"ax1.plot(l12_m_x, l12_m_y, lw=0.8, label=\"\")\n",
"ax1.add_patch(patches.Circle((0, 0), 53, edgecolor=\"#cccccc\", linewidth=1.0, linestyle='--', fill=False))\n",
"plt.xlim([-60,60])\n",
"plt.ylim([-60,60])\n",
"\n",
"ax2 = plt.subplot(gs[1])\n",
"plt.title(r\"Launch 12 Flight YZ\")\n",
"plt.xlabel(r\"Magnetic Field Y [$ \\mu$T]\")\n",
"plt.ylabel(r\"Magnetic Field Z [$ \\mu$T]\")\n",
"ax2.plot(l12_m_y, l12_m_z, lw=0.8, label=\"\")\n",
"ax2.add_patch(patches.Circle((0, 0), 53, edgecolor=\"#cccccc\", linewidth=1.0, linestyle='--', fill=False))\n",
"plt.xlim([-60,60])\n",
"plt.ylim([-60,60])\n",
"\n",
"ax3 = plt.subplot(gs[2])\n",
"plt.title(r\"Launch 12 Flight XZ\")\n",
"plt.xlabel(r\"Magnetic Field X [$ \\mu$T]\")\n",
"plt.ylabel(r\"Magnetic Field Z [$ \\mu$T]\")\n",
"ax3.plot(l12_m_x, l12_m_z, lw=0.8, label=\"\")\n",
"ax3.add_patch(patches.Circle((0, 0), 53, edgecolor=\"#cccccc\", linewidth=1.0, linestyle='--', fill=False))\n",
"plt.xlim([-60,60])\n",
"plt.ylim([-60,60])\n",
"\n",
"ax4 = plt.subplot(gs[3], projection='3d')\n",
"plt.title(r\"Launch 12 Flight XYZ\")\n",
"plt.xlabel(r\"Field Strength Y [$\\mu$T]\")\n",
"plt.ylabel(r\"Field Strength Z [$\\mu$T]\")\n",
"ax4.set_zlabel('Field Strength X [$\\mu$T]')\n",
"\n",
"ax4.plot_wireframe(x, y, z, color=\"k\", alpha=0.1, lw=0.2)\n",
"\n",
"ax4.plot(l12_m_y, l12_m_z, l12_m_x, '-', lw=0.5)\n",
"ax4.plot([0],[0],[0], 'g.')\n",
"\n",
"ax4.set_xlim(-60, 60)\n",
"ax4.set_ylim(-60, 60)\n",
"ax4.set_zlim(-60, 60)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},

Loading…
Cancel
Save