From 770048b409f7ba0636abc74cecc8efaeb863afb4 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Fri, 6 Jan 2017 11:23:54 +0000 Subject: add plot --- live_analyse_py.grc | 89 ++++++++++++++++++++++++++-- run.ipynb | 166 ++++++++++++++++------------------------------------ 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 @@ _coordinate - (1368, 599) + (1240, 343) _rotation @@ -463,7 +463,7 @@ file - /home/andreas/dab/dab_run.dat + /home/andreas/dab/ODR-StaticPrecorrection/input.dat _coordinate @@ -569,7 +569,7 @@ _coordinate - (512, 148) + (784, 148) _rotation @@ -596,6 +596,77 @@ 1 + + dpd_memless_poly + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (576, 99) + + + _rotation + 0 + + + id + dpd_memless_poly_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + a1 + 1 + + + a2 + 0 + + + a3 + 0 + + + a4 + 0 + + + a5 + 0 + + + a6 + 0 + + + a7 + 0 + + + a8 + 0 + + logpwrfft_x @@ -632,7 +703,7 @@ _coordinate - (1048, 585) + (848, 329) _rotation @@ -2453,7 +2524,7 @@ _coordinate - (512, 462) + (304, 350) _rotation @@ -2618,7 +2689,7 @@ blocks_file_source_0 - blocks_multiply_const_vxx_1 + dpd_memless_poly_0 0 0 @@ -2634,6 +2705,12 @@ 0 1 + + dpd_memless_poly_0 + blocks_multiply_const_vxx_1 + 0 + 0 + logpwrfft_x_0 blks2_tcp_sink_1_0 diff --git a/run.ipynb b/run.ipynb index 4f243d8..2a1c78b 100644 --- a/run.ipynb +++ b/run.ipynb @@ -36,6 +36,27 @@ " pass" ] }, + { + "cell_type": "code", + "execution_count": null, + "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, @@ -86,6 +107,15 @@ "sync.has_msg()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "top." + ] + }, { "cell_type": "code", "execution_count": null, @@ -152,6 +182,20 @@ "mydab.calc_signal_sholder_ratio(fft, fft_size, samp_rate)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -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]\")" ] }, { @@ -256,80 +266,6 @@ "top.wait()" ] }, - { - "cell_type": "code", - "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, -- cgit v1.2.3