aboutsummaryrefslogtreecommitdiffstats
path: root/run.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'run.ipynb')
-rw-r--r--run.ipynb166
1 files changed, 51 insertions, 115 deletions
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": []
},
{