aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-01-06 11:23:54 +0000
committerandreas128 <Andreas>2017-01-06 11:23:54 +0000
commit770048b409f7ba0636abc74cecc8efaeb863afb4 (patch)
tree7f4cad6a8db5a31f519de47f1a4fcb625f7787e0
parent02e4cf6ab3ea3f55cfcd904d462fd3c494af8593 (diff)
downloadODR-StaticPrecorrection-770048b409f7ba0636abc74cecc8efaeb863afb4.tar.gz
ODR-StaticPrecorrection-770048b409f7ba0636abc74cecc8efaeb863afb4.tar.bz2
ODR-StaticPrecorrection-770048b409f7ba0636abc74cecc8efaeb863afb4.zip
add plot
-rw-r--r--live_analyse_py.grc89
-rw-r--r--run.ipynb166
2 files changed, 134 insertions, 121 deletions
diff --git a/live_analyse_py.grc b/live_analyse_py.grc
index aada771..b380b70 100644
--- a/live_analyse_py.grc
+++ b/live_analyse_py.grc
@@ -365,7 +365,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(1368, 599)</value>
+ <value>(1240, 343)</value>
</param>
<param>
<key>_rotation</key>
@@ -463,7 +463,7 @@
</param>
<param>
<key>file</key>
- <value>/home/andreas/dab/dab_run.dat</value>
+ <value>/home/andreas/dab/ODR-StaticPrecorrection/input.dat</value>
</param>
<param>
<key>_coordinate</key>
@@ -569,7 +569,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(512, 148)</value>
+ <value>(784, 148)</value>
</param>
<param>
<key>_rotation</key>
@@ -597,6 +597,77 @@
</param>
</block>
<block>
+ <key>dpd_memless_poly</key>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(576, 99)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>id</key>
+ <value>dpd_memless_poly_0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a1</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>a2</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a3</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a4</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a5</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a6</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a7</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>a8</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
<key>logpwrfft_x</key>
<param>
<key>avg_alpha</key>
@@ -632,7 +703,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(1048, 585)</value>
+ <value>(848, 329)</value>
</param>
<param>
<key>_rotation</key>
@@ -2453,7 +2524,7 @@
</param>
<param>
<key>_coordinate</key>
- <value>(512, 462)</value>
+ <value>(304, 350)</value>
</param>
<param>
<key>_rotation</key>
@@ -2618,7 +2689,7 @@
</connection>
<connection>
<source_block_id>blocks_file_source_0</source_block_id>
- <sink_block_id>blocks_multiply_const_vxx_1</sink_block_id>
+ <sink_block_id>dpd_memless_poly_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
@@ -2635,6 +2706,12 @@
<sink_key>1</sink_key>
</connection>
<connection>
+ <source_block_id>dpd_memless_poly_0</source_block_id>
+ <sink_block_id>blocks_multiply_const_vxx_1</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
<source_block_id>logpwrfft_x_0</source_block_id>
<sink_block_id>blks2_tcp_sink_1_0</sink_block_id>
<source_key>0</source_key>
diff --git a/run.ipynb b/run.ipynb
index 4f243d8..2a1c78b 100644
--- a/run.ipynb
+++ b/run.ipynb
@@ -42,6 +42,27 @@
"metadata": {},
"outputs": [],
"source": [
+ "sig = np.fromfile(\"/home/andreas/dab/dab_normalized_c64.dat\", dtype=np.complex64)\n",
+ "\n",
+ "#coefs = [0, -0.05, 0, 0, 0.05]\n",
+ "coefs = [0, 0, 0, 0, 0]\n",
+ "res = sig\n",
+ "for idx, coef in enumerate(coefs):\n",
+ " res += sig * np.abs(sig)**(idx+1) * coef #+1 because first correction term is squared\n",
+ "\n",
+ "res = res / np.max(res)\n",
+ "\n",
+ "sig.tofile(\"./input.dat\")\n",
+ "del res\n",
+ "del sig"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
"sync = tcp_sync.UhdSyncMsg(packet_size=4*8192,\n",
" packet_type=\"\".join([\"f\"]*8192))\n",
"async = tcp_async.UhdAsyncMsg()"
@@ -92,6 +113,15 @@
"metadata": {},
"outputs": [],
"source": [
+ "top."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
"import peakutils\n",
"def score(msg, frequency_0, frequency_1, samp_rate):\n",
" frequency_0_idx = np.round(frequency_0 / samp_rate * fft_size).astype(int)\n",
@@ -157,6 +187,20 @@
"execution_count": null,
"metadata": {},
"outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"def meas(i):\n",
" import sys\n",
@@ -178,7 +222,8 @@
"metadata": {},
"outputs": [],
"source": [
- "res = [meas(i) for i in range(89)]"
+ "top.set_txgain(85)\n",
+ "mydab.calc_signal_sholder_ratio(fft, fft_size, samp_rate, plot=True)"
]
},
{
@@ -187,10 +232,7 @@
"metadata": {},
"outputs": [],
"source": [
- "plt.plot(res)\n",
- "plt.title(\"DAB sholders\")\n",
- "plt.xlabel(\"tx gain [db]\")\n",
- "plt.ylabel(\"signal - sholder [db]\")"
+ "res = [meas(i) for i in range(89)]"
]
},
{
@@ -199,42 +241,10 @@
"metadata": {},
"outputs": [],
"source": [
- "top.set_txgain(84)\n",
- "for el in l:\n",
- " t2 = time.time()\n",
- " 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)"
+ "plt.plot(res)\n",
+ "plt.title(\"DAB sholders\")#, coefs = [0, -0.05, 0, 0, 0.05]\")\n",
+ "plt.xlabel(\"tx gain [db]\")\n",
+ "plt.ylabel(\"signal - sholder [db]\")"
]
},
{
@@ -261,80 +271,6 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": [
- "path = gen_source.gen_file(frequency_0=frequency_0,\n",
- " frequency_1=frequency_1,\n",
- " x1 = 0,\n",
- " x2 = 0,\n",
- " x3 = 0,\n",
- " x4 = 0,\n",
- " samp_rate=samp_rate,\n",
- " path='./np_twotone')\n",
- "a_load = np.fromfile(path, dtype=np.complex64)\n",
- "plt.plot(a_load.real[0:100])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "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": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
"source": []
},
{