aboutsummaryrefslogtreecommitdiffstats
path: root/two_tone_tuner.ipynb
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-01-22 00:51:47 +0000
committerandreas128 <Andreas>2017-01-22 00:51:47 +0000
commita88e67cb485d6b4b7bc21aa3c9dedbab37190cb9 (patch)
tree2158dc19cd17b72b7a96a602f59bdfb5951cd814 /two_tone_tuner.ipynb
parent62d6affd9fd9c5d45305cd5880c16696c0744044 (diff)
downloadODR-StaticPrecorrection-a88e67cb485d6b4b7bc21aa3c9dedbab37190cb9.tar.gz
ODR-StaticPrecorrection-a88e67cb485d6b4b7bc21aa3c9dedbab37190cb9.tar.bz2
ODR-StaticPrecorrection-a88e67cb485d6b4b7bc21aa3c9dedbab37190cb9.zip
am-am am-pm diagram in syncmeasurement.ipynb
Diffstat (limited to 'two_tone_tuner.ipynb')
-rw-r--r--two_tone_tuner.ipynb85
1 files changed, 46 insertions, 39 deletions
diff --git a/two_tone_tuner.ipynb b/two_tone_tuner.ipynb
index af96f5a..1d6f6cb 100644
--- a/two_tone_tuner.ipynb
+++ b/two_tone_tuner.ipynb
@@ -12,6 +12,7 @@
"import time\n",
"import src.gen_source as gen_source\n",
"import src.two_tone_lib as tt\n",
+ "import src.dab_tuning_lib as dt\n",
"\n",
"import src.tcp_async as tcp_async\n",
"import src.tcp_sync as tcp_sync\n",
@@ -31,6 +32,7 @@
" reload(tcp_sync)\n",
" reload(gen_source)\n",
" reload(tt)\n",
+ " reload(td)\n",
"except:\n",
" pass"
]
@@ -106,24 +108,34 @@
"metadata": {},
"outputs": [],
"source": [
- "def measure(param):\n",
- " x2, x3, x4, x5, x6, x7, x8 = param\n",
+ "def measure(param, debug = False):\n",
+ " #x2, x3, x4, x5, x6, x7, x8 = param\n",
+ " x1, x2, x3, x4, x5, x6, x7, x8 = param + [1]\n",
" \n",
" repeat = True\n",
" while repeat:\n",
" #tt.gen_two_tone(debug = True, predist=tt.predist_poly, par=(x2, x3, x4))\n",
" \n",
- " top.dpd_memless_poly_0.set_a1(0.8)\n",
- " top.dpd_memless_poly_0.set_a2(x2)\n",
- " top.dpd_memless_poly_0.set_a3(x3)\n",
- " top.dpd_memless_poly_0.set_a4(x4)\n",
- " top.dpd_memless_poly_0.set_a5(x5)\n",
- " top.dpd_memless_poly_0.set_a6(x6)\n",
- " top.dpd_memless_poly_0.set_a7(x7)\n",
- " top.dpd_memless_poly_0.set_a8(x8)\n",
+ " #top.dpd_memless_poly_0.set_a1(0.8)\n",
+ " #top.dpd_memless_poly_0.set_a2(x2)\n",
+ " #top.dpd_memless_poly_0.set_a3(x3)\n",
+ " #top.dpd_memless_poly_0.set_a4(x4)\n",
+ " #top.dpd_memless_poly_0.set_a5(x5)\n",
+ " #top.dpd_memless_poly_0.set_a6(x6)\n",
+ " #top.dpd_memless_poly_0.set_a7(x7)\n",
+ " #top.dpd_memless_poly_0.set_a8(x8)\n",
+ " \n",
+ " top.dpd_lut_0.set_a1(x1)\n",
+ " top.dpd_lut_0.set_a2(x2)\n",
+ " top.dpd_lut_0.set_a3(x3)\n",
+ " top.dpd_lut_0.set_a4(x4)\n",
+ " top.dpd_lut_0.set_a5(x5)\n",
+ " top.dpd_lut_0.set_a6(x6)\n",
+ " top.dpd_lut_0.set_a7(x7)\n",
+ " top.dpd_lut_0.set_a8(1)\n",
" \n",
" sync.has_msg()\n",
- " np.array(sync.get_msgs(1))\n",
+ " np.array(sync.get_msgs(3))\n",
" msgs = np.array(sync.get_msgs(5))\n",
" msgs = [np.fft.fftshift(msg) for msg in msgs]\n",
" \n",
@@ -135,7 +147,8 @@
" mean_msg = a.mean(axis = 0)\n",
" suffix = \"x_2_%.3f_x_3_%.3f_x_4_%.3fx_5_%.3fx_6_%.3fx_7_%.3fx_8_%.3f\" % \\\n",
" (x2, x3, x4, x5, x6, x7, x8)\n",
- " sig_to_noise = tt.analyse_power_spec(mean_msg, debug=True, debug_path=\"/tmp/out\", suffix=suffix)\n",
+ " sig_to_noise = tt.analyse_power_spec(mean_msg, debug=debug, debug_path=\"/tmp/out\", suffix=suffix)\n",
+ " #sig_to_noise = dt.calc_signal_sholder_ratio(mean_msg, sampling_rate=8000000, debug=debug, debug_path=\"/tmp/out\", suffix=suffix)\n",
" print(sig_to_noise, x2, x3, x4, x5, x6, x7, x8)\n",
" repeat = False\n",
" \n",
@@ -151,13 +164,14 @@
"def simple_opt(pars, i, d, func):\n",
" par = pars[i]\n",
" test_pars = []\n",
- " for x in [-1, 0, 1]:\n",
+ " for x in [-3, -2, -1, 0, 1, 2, 3]:\n",
+ " debug = x == 0\n",
" new_par = list(pars)\n",
" new_par[i] = par + x * d \n",
- " test_pars.append(new_par)\n",
- " res = [func(par_new) for par_new in test_pars]\n",
+ " test_pars.append([new_par, debug])\n",
+ " res = [func(par_new, debug) for par_new, debug in test_pars]\n",
" sel = np.argmax(res)\n",
- " best_par = test_pars[sel]\n",
+ " best_par = zip(*test_pars)[0][sel]\n",
" return best_par\n",
"\n",
"#pars = [1,1,1]\n",
@@ -172,14 +186,7 @@
"metadata": {},
"outputs": [],
"source": [
- "top.set_txgain(85)\n",
- "top.set_rxgain(5)\n",
- "\n",
- "pars = np.zeros(7)\n",
- "\n",
- "for i in range(10000):\n",
- " i_rand = np.random.randint(0, len(pars))\n",
- " pars = simple_opt(pars, i_rand, 0.005, measure)\n"
+ "#top.blocks_file_source_0.open(\"../dab_normalized_c64.dat\", True)"
]
},
{
@@ -187,23 +194,23 @@
"execution_count": null,
"metadata": {},
"outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
- "top.set_txgain(85)\n",
+ "reload(dt)\n",
+ "top.set_txgain(84)\n",
+ "top.set_rxgain(5)\n",
"\n",
- "params = []\n",
- "for x2 in np.linspace(-0.1, 0.1, num = 11):\n",
- " for x3 in np.linspace(-0.1, 0.1, num = 11):\n",
- " for x4 in np.linspace(-0.1, 0.1, num = 11):\n",
- " params.append((x2, x3, x4))\n",
- " \n",
- "t_start = time.time()\n",
- "for idx, param in enumerate(params):\n",
- " measure(param)\n",
- " time_per_element = (time.time() - t_start) / (idx + 1)\n",
- " print (\"Time per Element \" + str(time_per_element) +\n",
- " \", total: \" + str(time_per_element * len(params)),\n",
- " \", left: \" + str(time_per_element * (len(params) - 1 - idx))\n",
- " )"
+ "pars = np.array(range(1,8))/8.\n",
+ "\n",
+ "for i in range(10000):\n",
+ " i_rand = np.random.randint(0, len(pars))\n",
+ " pars = simple_opt(pars, i_rand, 0.05, measure)"
]
},
{