From 62d6affd9fd9c5d45305cd5880c16696c0744044 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Mon, 9 Jan 2017 14:53:17 +0000 Subject: Plot whole spectrum for two tone analyse --- __init__.py | 0 grc/live_analyse_anti_signal.grc | 361 ++++++++++++++++++++++++++++++++++++++- live_analyse.grc | 359 +++++++++++++++++++++++++++++++++++++- src/two_tone_lib.py | 12 +- two_tone_tuner.ipynb | 13 +- 5 files changed, 730 insertions(+), 15 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/grc/live_analyse_anti_signal.grc b/grc/live_analyse_anti_signal.grc index 7727732..47a740c 100644 --- a/grc/live_analyse_anti_signal.grc +++ b/grc/live_analyse_anti_signal.grc @@ -906,7 +906,7 @@ freq - f2 + (f2-f1) + f1 - (f2-f1) _coordinate @@ -1322,7 +1322,7 @@ _coordinate - (984, 156) + (704, 156) _rotation @@ -1443,6 +1443,349 @@ 1 + + qtgui_const_sink_x + + autoscale + False + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (920, 197) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_const_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + 0 + + + style1 + 0 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "red" + + + label10 + + + + marker10 + 0 + + + style10 + 0 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + 0 + + + style2 + 0 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "red" + + + label3 + + + + marker3 + 0 + + + style3 + 0 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "red" + + + label4 + + + + marker4 + 0 + + + style4 + 0 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "red" + + + label5 + + + + marker5 + 0 + + + style5 + 0 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "red" + + + label6 + + + + marker6 + 0 + + + style6 + 0 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "red" + + + label7 + + + + marker7 + 0 + + + style7 + 0 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "red" + + + label8 + + + + marker8 + 0 + + + style8 + 0 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "red" + + + label9 + + + + marker9 + 0 + + + style9 + 0 + + + width9 + 1 + + + name + "" + + + nconnections + 2 + + + size + 1024 + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + complex + + + update_time + 0.10 + + + xmax + 2 + + + xmin + -2 + + + ymax + 2 + + + ymin + -2 + + qtgui_freq_sink_x @@ -1487,7 +1830,7 @@ _coordinate - (976, 262) + (928, 278) gui_hint @@ -4742,6 +5085,12 @@ 0 0 + + blocks_multiply_const_vxx_1 + qtgui_const_sink_x_0 + 0 + 1 + blocks_multiply_const_vxx_1 qtgui_freq_sink_x_0_0_0 @@ -4778,6 +5127,12 @@ 0 0 + + uhd_usrp_source_0 + qtgui_const_sink_x_0 + 0 + 0 + uhd_usrp_source_0 qtgui_freq_sink_x_0_0 diff --git a/live_analyse.grc b/live_analyse.grc index 04bedef..3646ae2 100644 --- a/live_analyse.grc +++ b/live_analyse.grc @@ -949,7 +949,7 @@ _coordinate - (264, 45) + (216, 61) _rotation @@ -1051,7 +1051,7 @@ _coordinate - (736, 52) + (744, 68) _rotation @@ -1243,6 +1243,349 @@ a_8 + + qtgui_const_sink_x + + autoscale + False + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (936, 401) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_const_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + 0 + + + style1 + 0 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "red" + + + label10 + + + + marker10 + 0 + + + style10 + 0 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + 0 + + + style2 + 0 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "red" + + + label3 + + + + marker3 + 0 + + + style3 + 0 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "red" + + + label4 + + + + marker4 + 0 + + + style4 + 0 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "red" + + + label5 + + + + marker5 + 0 + + + style5 + 0 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "red" + + + label6 + + + + marker6 + 0 + + + style6 + 0 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "red" + + + label7 + + + + marker7 + 0 + + + style7 + 0 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "red" + + + label8 + + + + marker8 + 0 + + + style8 + 0 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "red" + + + label9 + + + + marker9 + 0 + + + style9 + 0 + + + width9 + 1 + + + name + "" + + + nconnections + 2 + + + size + 1024 + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + complex + + + update_time + 0.10 + + + xmax + 2 + + + xmin + -2 + + + ymax + 2 + + + ymin + -2 + + qtgui_freq_sink_x @@ -4494,6 +4837,12 @@ 0 0 + + blocks_multiply_const_vxx_1 + qtgui_const_sink_x_0 + 0 + 0 + blocks_multiply_const_vxx_1 qtgui_freq_sink_x_0_0_0 @@ -4536,6 +4885,12 @@ 0 0 + + uhd_usrp_source_0 + qtgui_const_sink_x_0 + 0 + 1 + uhd_usrp_source_0 qtgui_freq_sink_x_0_0 diff --git a/src/two_tone_lib.py b/src/two_tone_lib.py index df7d53f..a3c9675 100644 --- a/src/two_tone_lib.py +++ b/src/two_tone_lib.py @@ -9,8 +9,8 @@ def gen_two_tone(path = "./input.dat", predist = None, par = None, debug = False assert(t_both / period2 % 1 == 0) t = np.arange(0,t_both) - sin1 = np.sin(t * 2 * np.pi * 1./period1) - sin2 = np.sin(t * 2 * np.pi * 1./period2) + sin1 = np.exp(t * 2j * np.pi * 1./period1) + sin2 = np.exp(t * 2j * np.pi * 1./period2) sig = sin1 + sin2 if predist is None: @@ -52,18 +52,18 @@ def analyse_power_spec(spec, debug = False, debug_path="", suffix=""): second_peak = spec_start + 2114 delta_freq = 66 peak_other = [] - if debug: plt.plot(spec[spec_start:spec_end]) + if debug: plt.plot(spec) for x in [c * delta_freq + delta_freq//2 for c in range(spec_start//delta_freq)]: start = spec_start + x end = spec_start + x + delta_freq peak = spec[start:end].max() - if debug: plt.plot((start-spec_start,end-spec_start), (peak, peak)) + if debug: plt.plot((start,end), (peak, peak)) if start < first_peak and end > first_peak: peak_1 = peak - if debug: plt.plot((start-spec_start,end-spec_start), (peak+1, peak+1)) + if debug: plt.plot((start,end), (peak+1, peak+1)) elif start < second_peak and end > second_peak: peak_2 = peak - if debug: plt.plot((start-spec_start,end-spec_start), (peak+1, peak+1)) + if debug: plt.plot((start,end), (peak+1, peak+1)) else: peak_other.append(peak) mean_signal = (peak_1 + peak_2) / 2 diff --git a/two_tone_tuner.ipynb b/two_tone_tuner.ipynb index 6564068..af96f5a 100644 --- a/two_tone_tuner.ipynb +++ b/two_tone_tuner.ipynb @@ -80,7 +80,8 @@ "metadata": {}, "outputs": [], "source": [ - "top.set_txgain(85)" + "top.set_txgain(85)\n", + "top.set_rxgain(15)" ] }, { @@ -88,7 +89,9 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "tt.gen_two_tone(debug = True)" + ] }, { "cell_type": "code", @@ -170,11 +173,13 @@ "outputs": [], "source": [ "top.set_txgain(85)\n", + "top.set_rxgain(5)\n", + "\n", "pars = np.zeros(7)\n", "\n", - "for i in range(100):\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)\n" + " pars = simple_opt(pars, i_rand, 0.005, measure)\n" ] }, { -- cgit v1.2.3