From ea44143cf2290e887c16fc7e1f9fa6a0e084fcbd Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 31 Mar 2021 20:16:17 +0200 Subject: Paper rework WIP for submission to CHES'21 --- .../Accelerometer Data Analysis.ipynb | 120 +++++++++++++-------- .../sensor-analysis/fig-acc-theory-meas-run50.pdf | Bin 17426 -> 17426 bytes .../fig-acc-trace-stacked-run50.pdf | Bin 64277 -> 65065 bytes .../sensor-analysis/fig-acc-trace-steps-run50.pdf | Bin 103833 -> 64403 bytes 4 files changed, 78 insertions(+), 42 deletions(-) (limited to 'prototype') diff --git a/prototype/sensor-analysis/Accelerometer Data Analysis.ipynb b/prototype/sensor-analysis/Accelerometer Data Analysis.ipynb index 3310027..3f01de9 100644 --- a/prototype/sensor-analysis/Accelerometer Data Analysis.ipynb +++ b/prototype/sensor-analysis/Accelerometer Data Analysis.ipynb @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 97, + "execution_count": 220, "metadata": { "scrolled": false }, @@ -83,7 +83,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Loading run #28 with 4918 packets total, 178 distinct over 161.5061011314392s\n" + "Loading run #28 with 4918 packets total, 178 distinct over 162s\n" ] }, { @@ -1047,7 +1047,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1071,16 +1071,18 @@ " seq, *data, _crc = struct.unpack('" + "" ], "text/plain": [ "" @@ -2268,7 +2270,7 @@ "ivl_start, ivl_end = 0.5, 1\n", "ivl_start, ivl_end = int(ivl_start*60*sampling_rate), int(ivl_end*60*sampling_rate)\n", "\n", - "fig, ax = plt.subplots(figsize=(8, 5))\n", + "fig, ax = plt.subplots(figsize=(5, 2.5))\n", "#ax.axvspan(ivl_start/60/sampling_rate, ivl_end/60/sampling_rate, color='orange', alpha=0.5)\n", "\n", "# Run 40\n", @@ -2329,13 +2331,14 @@ "print(f'Found sensor scale: {sensor_scale-1.0:+.3f}')\n", "print() \n", "\n", - "plot_measurements(ax, t, y, offset=sensor_offx, scale=sensor_scale, grid=False, label='Accelerometer readings')\n", + "plot_measurements(ax, t, y, offset=sensor_offx, scale=sensor_scale, grid=False,\n", + " label='Raw acceleration', label2='After Low Pass', linewidth=[0.5, 1])\n", "\n", "ax.axhline(0, linewidth=1, color='black', alpha=0.5, zorder=1)\n", "\n", - "label = {'label': 'Theoretical results from direct frequency measurement'}\n", + "label = {'label': 'Theory'}\n", "for theory, meas, (_1, _2, f_actual) in zip(acc_theory, acc_meas, le_data):\n", - " ax.axhline(theory, color='orange', alpha=1, zorder=1, linewidth=1, **label)\n", + " ax.axhline(theory, color='orange', alpha=1, zorder=1, linewidth=0.5, **label)\n", " label = {}\n", " meas = (meas - sensor_offx) * sensor_scale\n", " #ax.axhline(meas, color='red', alpha=0.2, zorder=1)\n", @@ -2348,13 +2351,26 @@ " print()\n", "\n", "ax.legend(loc='upper left')\n", + "\n", + "f_ax = ax.twinx()\n", + "f_ax.spines['right'].set_position(('outward', 50))\n", + "f_ax.set_ylabel('$f\\;[rpm]$')\n", + "g_ylim = ax.get_ylim()\n", + "f_ax.set_ylim(g_ylim)\n", + "\n", + "g_to_f = lambda a: 60/2/np.pi * np.sqrt(a*g/r_mems)\n", + "f_to_g = lambda f: (f/60*2*np.pi)**2 * r_mems / g\n", + "tick_fs = list(np.linspace(0, 1000, 11))\n", + "f_ax.set_yticks([f_to_g(f) for f in tick_fs])\n", + "f_ax.set_yticklabels([f'{f:.0f}' if f == 0 or f > 200 else '' for f in tick_fs])\n", + "\n", "fig.tight_layout()\n", "fig.savefig('fig-acc-trace-steps-run50.pdf')" ] }, { "cell_type": "code", - "execution_count": 146, + "execution_count": 222, "metadata": {}, "outputs": [ { @@ -3362,7 +3378,7 @@ }, { "cell_type": "code", - "execution_count": 145, + "execution_count": 223, "metadata": { "scrolled": false }, @@ -3371,7 +3387,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Loading run #50 with 79193 packets total, 2623 distinct over 2102.6222710609436s\n", + "Loading run #50 with 79193 packets total, 2623 distinct over 2103s\n", "Packet length: 40\n", "Very approximate lower bound on baudrate: 129032.25806451612 bd\n", "Sequence number range: 2121 ... 4755\n" @@ -4338,7 +4354,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -4356,121 +4372,121 @@ "\n", "Centrifugal acceleration at 1.58 Hz:\n", " Theory: 0.55 g / 5.42 m/s^2\n", - " Measurement: 0.51 g / 5.028966965088801 m/s^2\n", + " Measurement: 0.51 g / 5.03 m/s^2\n", " Rel. Error: 7.78 %\n", " Abs. Error: 0.04 g / 0.39 m/s^2\n", "\n", "Centrifugal acceleration at 2.11 Hz:\n", " Theory: 0.99 g / 9.67 m/s^2\n", - " Measurement: 0.93 g / 9.162411313131324 m/s^2\n", + " Measurement: 0.93 g / 9.16 m/s^2\n", " Rel. Error: 5.51 %\n", " Abs. Error: 0.05 g / 0.50 m/s^2\n", "\n", "Centrifugal acceleration at 2.85 Hz:\n", " Theory: 1.80 g / 17.64 m/s^2\n", - " Measurement: 1.75 g / 17.17632651666313 m/s^2\n", + " Measurement: 1.75 g / 17.18 m/s^2\n", " Rel. Error: 2.68 %\n", " Abs. Error: 0.05 g / 0.46 m/s^2\n", "\n", "Centrifugal acceleration at 3.30 Hz:\n", " Theory: 2.41 g / 23.65 m/s^2\n", - " Measurement: 2.38 g / 23.327857994031824 m/s^2\n", + " Measurement: 2.38 g / 23.33 m/s^2\n", " Rel. Error: 1.36 %\n", " Abs. Error: 0.03 g / 0.32 m/s^2\n", "\n", "Centrifugal acceleration at 4.58 Hz:\n", " Theory: 4.64 g / 45.55 m/s^2\n", - " Measurement: 4.61 g / 45.215765910987294 m/s^2\n", + " Measurement: 4.61 g / 45.22 m/s^2\n", " Rel. Error: 0.73 %\n", " Abs. Error: 0.03 g / 0.33 m/s^2\n", "\n", "Centrifugal acceleration at 5.03 Hz:\n", " Theory: 5.60 g / 54.94 m/s^2\n", - " Measurement: 5.60 g / 54.879353326521255 m/s^2\n", + " Measurement: 5.60 g / 54.88 m/s^2\n", " Rel. Error: 0.10 %\n", " Abs. Error: 0.01 g / 0.06 m/s^2\n", "\n", "Centrifugal acceleration at 5.64 Hz:\n", " Theory: 7.04 g / 69.07 m/s^2\n", - " Measurement: 7.07 g / 69.32805905894263 m/s^2\n", + " Measurement: 7.07 g / 69.33 m/s^2\n", " Rel. Error: -0.37 %\n", " Abs. Error: -0.03 g / -0.26 m/s^2\n", "\n", "Centrifugal acceleration at 6.27 Hz:\n", " Theory: 8.70 g / 85.36 m/s^2\n", - " Measurement: 8.73 g / 85.58819751832274 m/s^2\n", + " Measurement: 8.73 g / 85.59 m/s^2\n", " Rel. Error: -0.27 %\n", " Abs. Error: -0.02 g / -0.23 m/s^2\n", "\n", "Centrifugal acceleration at 6.92 Hz:\n", " Theory: 10.60 g / 103.98 m/s^2\n", - " Measurement: 10.61 g / 104.02675841921068 m/s^2\n", + " Measurement: 10.61 g / 104.03 m/s^2\n", " Rel. Error: -0.05 %\n", " Abs. Error: -0.01 g / -0.05 m/s^2\n", "\n", "Centrifugal acceleration at 7.52 Hz:\n", " Theory: 12.52 g / 122.79 m/s^2\n", - " Measurement: 12.55 g / 123.06283558349547 m/s^2\n", + " Measurement: 12.55 g / 123.06 m/s^2\n", " Rel. Error: -0.22 %\n", " Abs. Error: -0.03 g / -0.27 m/s^2\n", "\n", "Centrifugal acceleration at 8.11 Hz:\n", " Theory: 14.56 g / 142.81 m/s^2\n", - " Measurement: 14.60 g / 143.1378855707173 m/s^2\n", + " Measurement: 14.60 g / 143.14 m/s^2\n", " Rel. Error: -0.23 %\n", " Abs. Error: -0.03 g / -0.33 m/s^2\n", "\n", "Centrifugal acceleration at 8.83 Hz:\n", " Theory: 17.26 g / 169.29 m/s^2\n", - " Measurement: 17.29 g / 169.5411921794013 m/s^2\n", + " Measurement: 17.29 g / 169.54 m/s^2\n", " Rel. Error: -0.15 %\n", " Abs. Error: -0.03 g / -0.25 m/s^2\n", "\n", "Centrifugal acceleration at 9.34 Hz:\n", " Theory: 19.32 g / 189.42 m/s^2\n", - " Measurement: 19.33 g / 189.55282064313795 m/s^2\n", + " Measurement: 19.33 g / 189.55 m/s^2\n", " Rel. Error: -0.07 %\n", " Abs. Error: -0.01 g / -0.14 m/s^2\n", "\n", "Centrifugal acceleration at 10.08 Hz:\n", " Theory: 22.50 g / 220.62 m/s^2\n", - " Measurement: 22.64 g / 222.01323904535036 m/s^2\n", + " Measurement: 22.64 g / 222.01 m/s^2\n", " Rel. Error: -0.63 %\n", " Abs. Error: -0.14 g / -1.39 m/s^2\n", "\n", "Centrifugal acceleration at 10.92 Hz:\n", " Theory: 26.40 g / 258.92 m/s^2\n", - " Measurement: 26.44 g / 259.29404953313013 m/s^2\n", + " Measurement: 26.44 g / 259.29 m/s^2\n", " Rel. Error: -0.14 %\n", " Abs. Error: -0.04 g / -0.37 m/s^2\n", "\n", "Centrifugal acceleration at 11.92 Hz:\n", " Theory: 31.46 g / 308.51 m/s^2\n", - " Measurement: 31.43 g / 308.2330187199834 m/s^2\n", + " Measurement: 31.43 g / 308.23 m/s^2\n", " Rel. Error: 0.09 %\n", " Abs. Error: 0.03 g / 0.28 m/s^2\n", "\n", "Centrifugal acceleration at 13.24 Hz:\n", " Theory: 38.81 g / 380.63 m/s^2\n", - " Measurement: 38.83 g / 380.7555308252864 m/s^2\n", + " Measurement: 38.83 g / 380.76 m/s^2\n", " Rel. Error: -0.03 %\n", " Abs. Error: -0.01 g / -0.13 m/s^2\n", "\n", "Centrifugal acceleration at 14.10 Hz:\n", " Theory: 44.02 g / 431.68 m/s^2\n", - " Measurement: 44.00 g / 431.4606825509938 m/s^2\n", + " Measurement: 44.00 g / 431.46 m/s^2\n", " Rel. Error: 0.05 %\n", " Abs. Error: 0.02 g / 0.22 m/s^2\n", "\n", "Centrifugal acceleration at 15.18 Hz:\n", " Theory: 51.02 g / 500.34 m/s^2\n", - " Measurement: 50.93 g / 499.4553254402874 m/s^2\n", + " Measurement: 50.93 g / 499.46 m/s^2\n", " Rel. Error: 0.18 %\n", " Abs. Error: 0.09 g / 0.89 m/s^2\n", "\n", "Centrifugal acceleration at 16.39 Hz:\n", " Theory: 59.48 g / 583.28 m/s^2\n", - " Measurement: 59.48 g / 583.3128315154445 m/s^2\n", + " Measurement: 59.48 g / 583.31 m/s^2\n", " Rel. Error: -0.00 %\n", " Abs. Error: -0.00 g / -0.03 m/s^2\n", "\n" @@ -4546,13 +4562,13 @@ " idx = (t_start/60 < t) & (t < t_end/60)\n", " new_t = t[idx]\n", " new_t -= min(new_t)\n", - " ax.plot(new_t*60, yp[idx], color='darkblue', alpha=0.2, label=label[0])\n", - " ax.plot(new_t*60, filtered[idx], color='darkblue', label=label[1])\n", + " ax.plot(new_t*60, yp[idx], color='darkblue', alpha=0.2, label=label[0], linewidth=1)\n", + " ax.plot(new_t*60, filtered[idx], color='darkblue', label=label[1], linewidth=0.5)\n", " label = (None, None)\n", "\n", "ax.axhline(0, linewidth=1, color='black', alpha=0.5, zorder=1)\n", "\n", - "label = {'label': 'Calculated from rotor speed'}\n", + "label = {'label': 'Theory'}\n", "for theory, meas, (_1, _2, f_actual) in zip(acc_theory, acc_meas, le_data):\n", " ax.axhline(theory, color='orange', alpha=1, zorder=1, linewidth=1, **label)\n", " label = {}\n", @@ -4561,19 +4577,39 @@ " \n", " print(f'Centrifugal acceleration at {f_actual:.2f} Hz:')\n", " print(f' Theory: {theory:.2f} g / {theory*g:.2f} m/s^2')\n", - " print(f' Measurement: {meas:.2f} g / {meas*g} m/s^2')\n", + " print(f' Measurement: {meas:.2f} g / {meas*g:.2f} m/s^2')\n", " print(f' Rel. Error: {(theory/meas - 1.0) * 100:.2f} %')\n", " print(f' Abs. Error: {theory-meas:.2f} g / {(theory-meas)*g:.2f} m/s^2')\n", " print()\n", "\n", "ax.legend(loc='upper left')\n", "ax.grid(axis='x')\n", + "\n", + "f_ax = ax.twinx()\n", + "f_ax.spines['right'].set_position(('outward', 50))\n", + "f_ax.set_ylabel('$f\\;[rpm]$')\n", + "g_ylim = ax.get_ylim()\n", + "f_ax.set_ylim(g_ylim)\n", + "\n", + "g_to_f = lambda a: 60/2/np.pi * np.sqrt(a*g/r_mems)\n", + "f_to_g = lambda f: (f/60*2*np.pi)**2 * r_mems / g\n", + "tick_fs = list(np.linspace(0, 1000, 11))\n", + "f_ax.set_yticks([f_to_g(f) for f in tick_fs])\n", + "f_ax.set_yticklabels([f'{f:.0f}' if f == 0 or f > 200 else '' for f in tick_fs])\n", + "\n", "#ax.set_yscale('log')\n", "#ax.set_ylim([0.3, 30])\n", "fig.tight_layout()\n", "fig.savefig('fig-acc-trace-stacked-run50.pdf')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 8, diff --git a/prototype/sensor-analysis/fig-acc-theory-meas-run50.pdf b/prototype/sensor-analysis/fig-acc-theory-meas-run50.pdf index 51d5325..bae7ce8 100644 Binary files a/prototype/sensor-analysis/fig-acc-theory-meas-run50.pdf and b/prototype/sensor-analysis/fig-acc-theory-meas-run50.pdf differ diff --git a/prototype/sensor-analysis/fig-acc-trace-stacked-run50.pdf b/prototype/sensor-analysis/fig-acc-trace-stacked-run50.pdf index ebcd5a5..a81246b 100644 Binary files a/prototype/sensor-analysis/fig-acc-trace-stacked-run50.pdf and b/prototype/sensor-analysis/fig-acc-trace-stacked-run50.pdf differ diff --git a/prototype/sensor-analysis/fig-acc-trace-steps-run50.pdf b/prototype/sensor-analysis/fig-acc-trace-steps-run50.pdf index 8d5c65f..c1bc499 100644 Binary files a/prototype/sensor-analysis/fig-acc-trace-steps-run50.pdf and b/prototype/sensor-analysis/fig-acc-trace-steps-run50.pdf differ -- cgit