aboutsummaryrefslogtreecommitdiffstats
path: root/receive_tcp.ipynb
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-04-02 10:46:49 +0100
committerandreas128 <Andreas>2017-04-02 10:46:49 +0100
commit2aa99f6275e2530a8dd4d3be270e9d7a3633cd66 (patch)
tree9bb6c05b6e17e3c00c4d68660cb47f846c4d66ba /receive_tcp.ipynb
parent3ee39e3ae187e76b252b5758c12bd35e5707e187 (diff)
downloadODR-StaticPrecorrection-2aa99f6275e2530a8dd4d3be270e9d7a3633cd66.tar.gz
ODR-StaticPrecorrection-2aa99f6275e2530a8dd4d3be270e9d7a3633cd66.tar.bz2
ODR-StaticPrecorrection-2aa99f6275e2530a8dd4d3be270e9d7a3633cd66.zip
Add two tone and mer measure
Diffstat (limited to 'receive_tcp.ipynb')
-rw-r--r--receive_tcp.ipynb324
1 files changed, 300 insertions, 24 deletions
diff --git a/receive_tcp.ipynb b/receive_tcp.ipynb
index 8c2cb79..5352b50 100644
--- a/receive_tcp.ipynb
+++ b/receive_tcp.ipynb
@@ -20,6 +20,8 @@
"import src.signal_gen as sg\n",
"import src.tcp_sync as ts\n",
"import src.dab_tuning_lib as dt\n",
+ "import pandas as pd\n",
+ "from tqdm import tqdm\n",
"reload(sg)\n",
"reload(du)\n",
"reload(dt)"
@@ -34,7 +36,20 @@
},
"outputs": [],
"source": [
- "import src.SendDictTcp as sdt"
+ "use_fft=False"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
+ "outputs": [],
+ "source": [
+ "if use_fft: t1 = ts.UhdSyncMsg(port=47009, packet_size=4*16384, packet_type=\"f\"*16384)\n",
+ "else: t1 = ts.UhdSyncMsg(port=47009, packet_size=4*1, packet_type=\"f\")"
]
},
{
@@ -46,7 +61,7 @@
},
"outputs": [],
"source": [
- "t1 = ts.UhdSyncMsg(port=47009, packet_size=4*16384, packet_type=\"f\"*16384)"
+ "import src.SendDictTcp as sdt"
]
},
{
@@ -69,7 +84,35 @@
"editable": true
},
"outputs": [],
- "source": []
+ "source": [
+ "sender.send({\"txgain\":80})\n",
+ "sender.send({\"rxgain\":15})\n",
+ "sender.send({\"a1\":0.8})\n",
+ "sender.send({\"a2\":0.0})\n",
+ "sender.send({\"a3\":0.0})\n",
+ "sender.send({\"a4\":0.0})\n",
+ "sender.send({\"a5\":0.0})\n",
+ "sender.send({\"a6\":0.0})\n",
+ "sender.send({\"a7\":0.0})\n",
+ "sender.send({\"a8\":0.0})"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
+ "outputs": [],
+ "source": [
+ "t1.has_msg()\n",
+ "t = time.time()\n",
+ "t1.get_msgs(10000)\n",
+ "print( time.time() - t)\n",
+ "t = time.time()\n",
+ "t1.get_msgs(10000)"
+ ]
},
{
"cell_type": "code",
@@ -80,7 +123,19 @@
},
"outputs": [],
"source": [
- "sender.send({\"txgain\":60})"
+ "reload(dt)\n",
+ "sender.send({\"txgain\":81})\n",
+ "sender.send({\"rxgain\":15})\n",
+ "sender.send({\"a1\":0.8})\n",
+ "sender.send({\"a2\":0.0})\n",
+ "sender.send({\"a3\":0.0})\n",
+ "sender.send({\"a4\":0.0})\n",
+ "sender.send({\"a5\":0.0})\n",
+ "sender.send({\"a6\":0.0})\n",
+ "sender.send({\"a7\":0.0})\n",
+ "sender.send({\"a8\":0.0})\n",
+ "t1.has_msg()\n",
+ "np.mean(t1.get_msgs(10000))"
]
},
{
@@ -92,7 +147,7 @@
},
"outputs": [],
"source": [
- "sender.send({\"a1\":1})"
+ "reload(dt)"
]
},
{
@@ -103,6 +158,50 @@
"editable": true
},
"outputs": [],
+ "source": [
+ "def measure_sholders(verbose = False, raw_data=False, std_max=0.025):\n",
+ " for i in range(20):\n",
+ " try:\n",
+ " if verbose: print(\"%d measurement\" % i)\n",
+ " t1.has_msg()\n",
+ " msgs = t1.get_msgs_fft(20000)\n",
+ " #sholders = [dt.calc_signal_sholder_ratio(np.array(msg), 8000000) for msg in msgs]\n",
+ " #sholders = [dt.calc_max_in_freq_range(np.array(msg), 8000000, 1000000, 1900000, debug=False) for msg in msgs]\n",
+ " #sholders = [dt.calc_mean_in_freq_range(np.array(msg), 8000000, 1000000, 1900000, debug=False) for msg in msgs]\n",
+ " sholders = np.array(msgs)\n",
+ " std = np.std(sholders)\n",
+ " mean = np.mean(sholders)\n",
+ " std_perc = std/np.abs(mean)\n",
+ " if verbose == 2:\n",
+ " print( {\"mean\":mean, \"std\":std, \"std_perc\":std_perc})\n",
+ " if std_perc > std_max:\n",
+ " if verbose: print(\"%.4f std/mean\" % (std_perc))\n",
+ " continue\n",
+ " else:\n",
+ " if raw_data: return sholders\n",
+ " else: return np.mean(sholders)\n",
+ " except Exception as e:\n",
+ " print e\n",
+ " raise Exception(\"Variance of measurement to high\")\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
+ "outputs": [],
+ "source": [
+ "a = np.array(measure_sholders(verbose=2, std_max=100, raw_data=True)).flatten()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": []
},
{
@@ -114,18 +213,8 @@
},
"outputs": [],
"source": [
- "def measure_sholders():\n",
- " for i in range(10):\n",
- " t1.has_msg()\n",
- " msgs = t1.get_msgs(20)\n",
- " sholders = [dt.calc_signal_sholder_ratio(np.array(msg), 8000000) for msg in msgs]\n",
- " std = np.std(sholders)\n",
- " mean = np.mean(sholders)\n",
- " if std/mean < 0.05:\n",
- " continue\n",
- " else:\n",
- " return np.mean(sholders)\n",
- " raise Exception(\"Variance of measurement to high\")"
+ "b = a[a<0.04]\n",
+ "plt.hist(b, bins=100);"
]
},
{
@@ -137,7 +226,33 @@
},
"outputs": [],
"source": [
- "measure_sholders()"
+ "from tqdm import tqdm_notebook\n",
+ "\n",
+ "sender.send({\"txgain\":83})\n",
+ "sender.send({\"rxgain\":15})\n",
+ "sender.send({\"a1\":0.8})\n",
+ "\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.5, 0.5, num=10)):\n",
+ " for a3 in tqdm_notebook([0]):\n",
+ " for a4 in tqdm_notebook([0]):\n",
+ "#for a2 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ "# for a3 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ "# for a4 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(verbose=0, std_max=100, raw_data=True)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a2.csv\")\n",
+ "print(time.time() - t)"
]
},
{
@@ -148,7 +263,26 @@
"editable": true
},
"outputs": [],
- "source": []
+ "source": [
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a3.csv\")\n",
+ "print(time.time() - t)"
+ ]
},
{
"cell_type": "code",
@@ -159,7 +293,24 @@
},
"outputs": [],
"source": [
- "t1.has_msg()"
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a4.csv\")\n",
+ "print(time.time() - t)"
]
},
{
@@ -180,7 +331,69 @@
"editable": true
},
"outputs": [],
- "source": []
+ "source": [
+ "from tqdm import tqdm_notebook\n",
+ "\n",
+ "sender.send({\"txgain\":81})\n",
+ "sender.send({\"rxgain\":15})\n",
+ "sender.send({\"a1\":0.8})\n",
+ "\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a2_81.csv\")\n",
+ "print(time.time() - t)\n",
+ "\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a3_81.csv\")\n",
+ "print(time.time() - t)\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a4_81.csv\")\n",
+ "print(time.time() - t)"
+ ]
},
{
"cell_type": "code",
@@ -190,7 +403,69 @@
"editable": true
},
"outputs": [],
- "source": []
+ "source": [
+ "from tqdm import tqdm_notebook\n",
+ "\n",
+ "sender.send({\"txgain\":85})\n",
+ "sender.send({\"rxgain\":15})\n",
+ "sender.send({\"a1\":0.8})\n",
+ "\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a2_85.csv\")\n",
+ "print(time.time() - t)\n",
+ "\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a3_85.csv\")\n",
+ "print(time.time() - t)\n",
+ "res = []\n",
+ "err = []\n",
+ "t = time.time()\n",
+ "for a2 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a3 in tqdm_notebook(np.linspace(-0.2, 0.2, num=5)):\n",
+ " for a4 in tqdm_notebook(np.linspace(-0.5, 0.5, num=21)):\n",
+ " try:\n",
+ " sender.send({\"a2\":a2})\n",
+ " sender.send({\"a3\":a3})\n",
+ " sender.send({\"a4\":a4})\n",
+ " losses = measure_sholders(raw_data=True, std=0.03)\n",
+ " for i, loss in enumerate(losses):\n",
+ " res.append({\"a2\":a2, \"a3\":a3, \"a4\":a4, \"loss\":loss, \"run\":i})\n",
+ " except Exception as e:\n",
+ " err.append(e)\n",
+ " df = pd.DataFrame(res)\n",
+ " df.to_csv(\"/tmp/sholder_a4_85.csv\")\n",
+ "print(time.time() - t)"
+ ]
},
{
"cell_type": "code",
@@ -201,8 +476,9 @@
},
"outputs": [],
"source": [
- "#top.stop()\n",
- "#top.wait()"
+ "sender.send({\"txgain\":20})\n",
+ "sender.send({\"rxgain\":15})\n",
+ "sender.send({\"a1\":0.1})"
]
},
{