aboutsummaryrefslogtreecommitdiffstats
path: root/run.ipynb
diff options
context:
space:
mode:
authorandreas128 <Andreas>2016-12-14 16:22:48 +0100
committerandreas128 <Andreas>2016-12-14 16:22:48 +0100
commit02e4cf6ab3ea3f55cfcd904d462fd3c494af8593 (patch)
tree1cc479962ab9b5f1b8e824a9a2eb82da6e33a11d /run.ipynb
parentbf1dcd15c041b73aeca73cd1aebe894d3128b4f2 (diff)
downloadODR-StaticPrecorrection-02e4cf6ab3ea3f55cfcd904d462fd3c494af8593.tar.gz
ODR-StaticPrecorrection-02e4cf6ab3ea3f55cfcd904d462fd3c494af8593.tar.bz2
ODR-StaticPrecorrection-02e4cf6ab3ea3f55cfcd904d462fd3c494af8593.zip
Add live analyse for sholders of dab signal
Diffstat (limited to 'run.ipynb')
-rw-r--r--run.ipynb176
1 files changed, 145 insertions, 31 deletions
diff --git a/run.ipynb b/run.ipynb
index 5c61960..4f243d8 100644
--- a/run.ipynb
+++ b/run.ipynb
@@ -11,6 +11,8 @@
"import numpy as np\n",
"import time\n",
"import src.gen_source as gen_source\n",
+ "from guppy import hpy \n",
+ "import mydab\n",
"\n",
"import tcp_async\n",
"import tcp_sync\n",
@@ -29,6 +31,7 @@
" reload(tcp_async)\n",
" reload(tcp_sync)\n",
" reload(gen_source)\n",
+ " reload(mydab)\n",
"except:\n",
" pass"
]
@@ -124,38 +127,114 @@
"metadata": {},
"outputs": [],
"source": [
- "top.set_txgain(85)\n",
- "for x2 in np.linspace(-0.15, 0.15, num = 15):\n",
+ "import itertools\n",
+ "x = np.linspace(-0.1, 0.1, num = 5)\n",
+ "l = list(itertools.product(x,x,x,x,x))\n",
+ "mag = [sum(map(lambda x:x*x,el)) for el in l]\n",
+ "idx = list(np.argsort(mag))\n",
+ "l = list(np.array(l)[idx])\n",
+ "len(l)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "top.set_txgain(84)\n",
+ "sync.has_msg()\n",
+ "msgs = np.array(sync.get_msgs(2))\n",
+ "fft = np.fft.fftshift(msgs[0])\n",
+ "#plt.plot(fft)\n",
+ "#plt.plot((4000 - f, 4000 -f),(-180,-40))\n",
+ "\n",
+ "mydab.calc_signal_sholder_ratio(fft, fft_size, samp_rate)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def meas(i):\n",
+ " import sys\n",
+ " sys.stdout.write(str(i) + \" \")\n",
+ " top.set_txgain(i)\n",
+ " sync.has_msg()\n",
+ " msgs = np.array(sync.get_msgs(10))\n",
+ " \n",
+ " res = []\n",
+ " for msg in msgs:\n",
+ " fft = np.fft.fftshift(msg)\n",
+ " res.append(mydab.calc_signal_sholder_ratio(fft, fft_size, samp_rate))\n",
+ " return np.mean(res)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "res = [meas(i) for i in range(89)]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "plt.plot(res)\n",
+ "plt.title(\"DAB sholders\")\n",
+ "plt.xlabel(\"tx gain [db]\")\n",
+ "plt.ylabel(\"signal - sholder [db]\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "top.set_txgain(84)\n",
+ "for el in l:\n",
" t2 = time.time()\n",
- " for x3 in np.linspace(-0.15, 0.15, num = 14):\n",
- " for x4 in np.linspace(-0.15, 0.15, num = 7):\n",
- " path = gen_source.gen_file(frequency_0=frequency_0,\n",
- " frequency_1=frequency_1,\n",
- " samp_rate=samp_rate,\n",
- " x2 = x2,\n",
- " x3 = x3,\n",
- " x4 = x4,\n",
- " path='./np_twotone')\n",
- " #a_load = np.fromfile(path, dtype=np.complex64)\n",
- " #plt.plot(a_load.real[0:100])\n",
- " \n",
- " sync.has_msg()\n",
- " np.array(sync.get_msgs(2))\n",
- " msgs = np.array(sync.get_msgs(5))\n",
- " inter_mod_avg = (np.max(score(msgs[0], frequency_0, frequency_1, samp_rate)) \n",
- " + np.max(score(msgs[1], frequency_0, frequency_1, samp_rate)) \n",
- " + np.max(score(msgs[2], frequency_0, frequency_1, samp_rate)) \n",
- " + np.max(score(msgs[3], frequency_0, frequency_1, samp_rate)) \n",
- " + np.max(score(msgs[4], frequency_0, frequency_1, samp_rate)))/5\n",
- " msg = msgs[0]\n",
- " \n",
- " \n",
- " print(\"inter_mod %.3f, x_2 %.3f, x_3 %.3f\" % (inter_mod_avg, x2, x3))\n",
- " \n",
- " plt.plot(msg)\n",
- " plt.savefig(\"/tmp/out/inter_mod_%.3f_x_2_%.3f_x_3_%.3f_x_4_%.3f.png\" % (inter_mod_avg, x2, x3, x4))\n",
- " plt.clf()\n",
- " print(time.time() - t2)"
+ " path = gen_source.gen_file(frequency_0=frequency_0,\n",
+ " frequency_1=frequency_1,\n",
+ " samp_rate=samp_rate,\n",
+ " coefs = el,\n",
+ " path='./np_twotone',\n",
+ " count = 10\n",
+ " )\n",
+ " #a_load = np.fromfile(path, dtype=np.complex64)\n",
+ " #plt.plot(a_load.real[0:100])\n",
+ " \n",
+ " sync.has_msg()\n",
+ " np.array(sync.get_msgs(2))\n",
+ " msgs = np.array(sync.get_msgs(5))\n",
+ " scores = [np.max(score(msg, frequency_0, frequency_1, samp_rate)) for msg in msgs]\n",
+ " inter_mod_avg = np.mean(scores)\n",
+ " inter_mod_var = np.var(scores)\n",
+ " msg = msgs[0]\n",
+ " \n",
+ " \n",
+ " param_str = \"_\".join([\"%.3f\" % f for f in el])\n",
+ " print(\"inter_mod %.3f +- %.3f, %s\" % (inter_mod_avg, inter_mod_var, param_str))\n",
+ " \n",
+ " plt.plot(msg)\n",
+ " plt.savefig(\"/tmp/out/inter_mod_%.3f_+-%.3f_%s.png\" % (inter_mod_avg, inter_mod_var, param_str))\n",
+ " plt.clf()\n",
+ " \n",
+ " a = np.fromfile(\"./np_twotone\", dtype=np.complex64)\n",
+ " plt.plot(a.real)\n",
+ " plt.savefig(\"/tmp/out/inter_mod_%.3f_+-%.3f_%s_wave.png\" % (inter_mod_avg, inter_mod_var, param_str))\n",
+ " plt.clf()\n",
+ " #h = hpy() \n",
+ " #print h.heap()\n",
+ " print(time.time() - t2)"
]
},
{
@@ -207,6 +286,41 @@
"execution_count": null,
"metadata": {},
"outputs": [],
+ "source": [
+ "gen_source.gen_file_d(800000, 1000000, 0, 0.5, 0, 0, 4000000, count = 5)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "a2 = np.fromfile(\"./np_twotone\", dtype=np.complex64)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "plt.plot(a.real)\n",
+ "plt.plot(a2.real)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": []
},
{