summaryrefslogtreecommitdiff
path: root/lab-windows/grid_scope.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'lab-windows/grid_scope.ipynb')
-rw-r--r--lab-windows/grid_scope.ipynb111
1 files changed, 80 insertions, 31 deletions
diff --git a/lab-windows/grid_scope.ipynb b/lab-windows/grid_scope.ipynb
index 9f53906..6ce34fb 100644
--- a/lab-windows/grid_scope.ipynb
+++ b/lab-windows/grid_scope.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 104,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -36,7 +36,7 @@
"metadata": {},
"outputs": [],
"source": [
- "db = sqlite3.connect('/mnt/c/Users/jaseg/shared/waveform-raspi.sqlite3')"
+ "db = sqlite3.connect('data/waveform-raspi.sqlite3')"
]
},
{
@@ -100,7 +100,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "f960454ab93244db97e039ae7ebd02ee",
+ "model_id": "55690b4f59d54454b83deb5200c05f09",
"version_major": 2,
"version_minor": 0
},
@@ -177,7 +177,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "264a9f8478e449289c1592c9595dc6cc",
+ "model_id": "cf5c2e35008740379508eaaedfcf3b31",
"version_major": 2,
"version_minor": 0
},
@@ -246,7 +246,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7c2382eb8e124ef9b29546ecaed3e155",
+ "model_id": "efa9db02cdfc4f6c86d1eadd4769d097",
"version_major": 2,
"version_minor": 0
},
@@ -279,7 +279,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "d29e8ee5bf7f4e94a1749239aec24d6d",
+ "model_id": "e4122530c1444f75aca410ad51d4a733",
"version_major": 2,
"version_minor": 0
},
@@ -356,7 +356,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "47c40f28b5a34a94b4a631fd62107521",
+ "model_id": "a36a994f6f484a6cba81b6e680c9eee1",
"version_major": 2,
"version_minor": 0
},
@@ -412,7 +412,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "4a4cb62296df496bad37d93547d3c26a",
+ "model_id": "e4116959544f44f6a4b898419a5d51db",
"version_major": 2,
"version_minor": 0
},
@@ -490,7 +490,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -509,21 +509,13 @@
},
{
"cell_type": "code",
- "execution_count": 81,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "<ipython-input-81-a751e13723ea>:17: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n",
- " fig, ax = plt.subplots(figsize=(9,5))\n"
- ]
- },
- {
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "3809a1a83b5844e3906f1d74bcd15b5d",
+ "model_id": "09069e2c9cb740d5b58846371aeea0f2",
"version_major": 2,
"version_minor": 0
},
@@ -548,7 +540,7 @@
"5.0"
]
},
- "execution_count": 81,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -585,21 +577,13 @@
},
{
"cell_type": "code",
- "execution_count": 156,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "<ipython-input-156-ddde6af5dee1>:20: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n",
- " fig, ax = plt.subplots()\n"
- ]
- },
- {
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "d137ae59ed7947ce8e3f7295e102f2f0",
+ "model_id": "b812e4b240a642398f09bb3cff8f5cee",
"version_major": 2,
"version_minor": 0
},
@@ -616,7 +600,7 @@
"(1.6666666666666667e-05, 0.5)"
]
},
- "execution_count": 156,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -649,6 +633,71 @@
"ax.grid()\n",
"ax.set_xlim([1/60000, 0.5])"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "c835382368b6423ab5446835c5785afd",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ "(5e-07, 0.02)"
+ ]
+ },
+ "execution_count": 27,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Number of samplepoints\n",
+ "N = len(data)\n",
+ "# sample spacing\n",
+ "T = 1.0 / 10.0\n",
+ "x = np.linspace(0.0, N*T, N)\n",
+ "yf = scipy.fftpack.fft(data)\n",
+ "xf = np.linspace(0.0, 1.0/(2.0*T), N//2)\n",
+ "\n",
+ "yf = 2.0/N * np.abs(yf[:N//2])\n",
+ "\n",
+ "average_from = lambda val, start, average_width: np.hstack([val[:start], [ np.mean(val[i:i+average_width]) for i in range(start, len(val), average_width) ]])\n",
+ "\n",
+ "average_width = 6\n",
+ "average_start = 20\n",
+ "yf = average_from(yf, average_start, average_width)\n",
+ "xf = average_from(xf, average_start, average_width)\n",
+ "yf = average_from(yf, 70, 4)\n",
+ "xf = average_from(xf, 70, 4)\n",
+ "\n",
+ "fig, ax = plt.subplots()\n",
+ "ax.loglog(xf, yf)\n",
+ "ax.xaxis.set_major_formatter(plt.FuncFormatter(lambda x, _pos: f'{1/x:.1f}'))\n",
+ "ax.set_xlabel('T in s')\n",
+ "ax.set_ylabel('Amplitude Δf')\n",
+ "\n",
+ "for i, t in enumerate([45, 60, 600, 1200, 1800, 3600]):\n",
+ " ax.axvline(1/t, color='red', alpha=0.5)\n",
+ " ax.annotate(f'{t} s', xy=(1/t, 3e-5), xytext=(-15, 0), xycoords='data', textcoords='offset pixels', rotation=90)\n",
+ "#ax.text(1/60, 10,'60 s', ha='left')\n",
+ "ax.grid()\n",
+ "ax.set_xlim([1/60000, 0.5])\n",
+ "ax.set_ylim([5e-7, 2e-2])"
+ ]
}
],
"metadata": {