From 02e4cf6ab3ea3f55cfcd904d462fd3c494af8593 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Wed, 14 Dec 2016 16:22:48 +0100 Subject: Add live analyse for sholders of dab signal --- .gitignore | 92 ++ live_analyse.grc | 1348 ++++---------------------- live_analyse_py.grc | 2655 +++++++++++++++++++++++++++++++++++++++++++++++++++ run.ipynb | 176 +++- src/gen_source.py | 85 +- 5 files changed, 3169 insertions(+), 1187 deletions(-) create mode 100644 live_analyse_py.grc diff --git a/.gitignore b/.gitignore index 9c37b59..cbdc681 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,95 @@ Session.vim *~ # auto-generated tag files tags + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +.venv/ +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject diff --git a/live_analyse.grc b/live_analyse.grc index 5b3db4b..737798e 100644 --- a/live_analyse.grc +++ b/live_analyse.grc @@ -135,33 +135,6 @@ 1 - - variable - - comment - - - - _enabled - True - - - _coordinate - (88, 237) - - - _rotation - 0 - - - id - freq - - - value - 222e6 - - variable_qtgui_range @@ -170,78 +143,15 @@ value - 2000000 - - - _enabled - True - - - _coordinate - (336, 568) - - - gui_hint - - - - _rotation 0 - - id - high - - - label - - - - min_len - 200 - - - orient - Qt.Horizontal - - - start - 50000 - - - step - 1 - - - stop - 2000000 - - - rangeType - float - - - widget - counter_slider - - - - variable_qtgui_range - - comment - - - - value - 50000 - _enabled True _coordinate - (168, 568) + (256, 417) gui_hint @@ -253,11 +163,11 @@ id - low + file_gain label - + file_gain min_len @@ -269,15 +179,15 @@ start - 50000 + 0 step - 1 + 0.000001 stop - 2000000 + 1 rangeType @@ -300,88 +210,7 @@ _coordinate - (8, 301) - - - _rotation - 0 - - - id - rxgain - - - value - variable_qtgui_rxgain - - - - variable - - comment - - - - _enabled - True - - - _coordinate - (8, 85) - - - _rotation - 0 - - - id - samp_rate - - - value - 4e6 - - - - variable - - comment - - - - _enabled - True - - - _coordinate - (88, 165) - - - _rotation - 0 - - - id - source_ampl - - - value - variable_qtgui_source_ampl - - - - variable - - comment - - - - _enabled - True - - - _coordinate - (8, 237) + (88, 237) _rotation @@ -389,11 +218,11 @@ id - txgain + freq value - variable_qtgui_txgain + 222e6 @@ -412,7 +241,7 @@ _coordinate - (8, 553) + (16, 417) gui_hint @@ -424,7 +253,7 @@ id - variable_qtgui_rxgain + rxgain label @@ -460,26 +289,18 @@ - variable_qtgui_range + variable comment - - value - 1 - _enabled True _coordinate - (160, 401) - - - gui_hint - + (8, 85) _rotation @@ -487,39 +308,11 @@ id - variable_qtgui_source_ampl - - - label - source_ampl - - - min_len - 200 - - - orient - Qt.Horizontal - - - start - 0 - - - step - 0.05 - - - stop - 1 - - - rangeType - float + samp_rate - widget - counter_slider + value + 8e6 @@ -530,7 +323,7 @@ value - 83 + 1 _enabled @@ -538,7 +331,7 @@ _coordinate - (8, 400) + (376, 417) gui_hint @@ -550,11 +343,11 @@ id - variable_qtgui_txgain + sig_gain label - txgain + sig_gain min_len @@ -570,11 +363,11 @@ step - 1 + 0.001 stop - 89 + 100 rangeType @@ -593,7 +386,7 @@ value - 500 + 20 _enabled @@ -601,7 +394,7 @@ _coordinate - (168, 688) + (136, 417) gui_hint @@ -613,11 +406,11 @@ id - width + txgain label - + txgain min_len @@ -629,7 +422,7 @@ start - 1 + 0 step @@ -637,7 +430,7 @@ stop - 5000000 + 100 rangeType @@ -649,7 +442,7 @@ - analog_const_source_x + blocks_file_source alias @@ -658,10 +451,6 @@ comment - - const - 0 - affinity @@ -670,9 +459,13 @@ _enabled True + + file + /home/andreas/dab/dab_normalized_c64.dat + _coordinate - (512, 92) + (264, 21) _rotation @@ -680,7 +473,7 @@ id - analog_const_source_x_0 + blocks_file_source_0 maxoutbuf @@ -694,9 +487,17 @@ type complex + + repeat + True + + + vlen + 1 + - blocks_add_xx + blocks_message_burst_source alias @@ -715,7 +516,7 @@ _coordinate - (696, 121) + (560, 329) _rotation @@ -723,11 +524,7 @@ id - blocks_add_xx_1 - - - type - complex + blocks_message_burst_source_0 maxoutbuf @@ -738,8 +535,8 @@ 0 - num_inputs - 2 + type + byte vlen @@ -747,7 +544,7 @@ - blocks_complex_to_arg + blocks_multiply_const_vxx alias @@ -756,6 +553,10 @@ comment + + const + file_gain + affinity @@ -766,7 +567,7 @@ _coordinate - (968, 321) + (552, 52) _rotation @@ -774,7 +575,11 @@ id - blocks_complex_to_arg_0 + blocks_multiply_const_vxx_1 + + + type + complex maxoutbuf @@ -790,505 +595,7 @@ - blocks_complex_to_mag_squared - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (800, 225) - - - _rotation - 0 - - - id - blocks_complex_to_mag_squared_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - vlen - 1 - - - - blocks_complex_to_mag_squared - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (792, 401) - - - _rotation - 0 - - - id - blocks_complex_to_mag_squared_0_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - vlen - 1 - - - - blocks_file_sink - - append - False - - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - file - fft_sink - - - _coordinate - (1312, 599) - - - _rotation - 0 - - - id - blocks_file_sink_0 - - - type - float - - - unbuffered - False - - - vlen - 8192 - - - - blocks_file_source - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - file - /home/andreas/dab/ODR-StaticPrecorrection/np_twotone - - - _coordinate - (344, 141) - - - _rotation - 0 - - - id - blocks_file_source_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - type - complex - - - repeat - True - - - vlen - 1 - - - - blocks_message_burst_source - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (896, 785) - - - _rotation - 0 - - - id - blocks_message_burst_source_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - type - byte - - - vlen - 1 - - - - blocks_moving_average_xx - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (1168, 302) - - - _rotation - 0 - - - id - blocks_moving_average_xx_0 - - - length - decim - - - max_iter - 4000 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - scale - 1 - - - type - float - - - - blocks_moving_average_xx - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (976, 206) - - - _rotation - 0 - - - id - blocks_moving_average_xx_0_0 - - - length - decim - - - max_iter - 4000 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - scale - 1 - - - type - float - - - - blocks_moving_average_xx - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (1168, 382) - - - _rotation - 0 - - - id - blocks_moving_average_xx_0_1 - - - length - decim - - - max_iter - 4000 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - scale - 1 - - - type - float - - - - blocks_multiply_conjugate_cc - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (792, 305) - - - _rotation - 0 - - - id - blocks_multiply_conjugate_cc_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - vlen - 1 - - - - blocks_multiply_const_vxx - - alias - - - - comment - - - - const - 1 - - - affinity - - - - _enabled - True - - - _coordinate - (536, 148) - - - _rotation - 0 - - - id - blocks_multiply_const_vxx_1 - - - type - complex - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - vlen - 1 - - - - blocks_null_sink + blocks_null_sink alias @@ -1311,7 +618,7 @@ _coordinate - (1384, 225) + (984, 329) _rotation @@ -1319,11 +626,11 @@ id - blocks_null_sink_0 + blocks_null_sink_0_2 type - float + byte num_inputs @@ -1335,65 +642,34 @@ - blocks_null_sink + qtgui_freq_sink_x - alias - + autoscale + False - bus_conns - [[0,],] + average + 1.0 - comment - + bw + samp_rate - affinity + alias - _enabled - True - - - _coordinate - (1552, 321) - - - _rotation + fc 0 - id - blocks_null_sink_0_0 - - - type - float - - - num_inputs - 1 - - - vlen - 1 - - - - blocks_null_sink - - alias + comment - bus_conns - [[0,],] - - - comment - + ctrlpanel + False affinity @@ -1404,307 +680,252 @@ True - _coordinate - (1552, 401) - - - _rotation - 0 - - - id - blocks_null_sink_0_1 - - - type - float - - - num_inputs - 1 - - - vlen - 1 - - - - blocks_null_sink - - alias - - - - bus_conns - [[0,],] + fftsize + 16000 - comment - + _coordinate + (704, 222) - affinity + gui_hint - - _enabled - True - - - _coordinate - (1320, 785) - _rotation 0 - id - blocks_null_sink_0_2 - - - type - byte + grid + False - num_inputs - 1 + id + qtgui_freq_sink_x_0_0 - vlen - 1 + legend + True - - - fir_filter_xxx - alias - + alpha1 + 1.0 - comment - + color1 + "blue" - affinity + label1 - decim - decim + width1 + 1 - _enabled - True + alpha10 + 1.0 - _coordinate - (1328, 309) + color10 + "dark blue" - _rotation - 0 + label10 + - id - fir_filter_xxx_0 + width10 + 1 - maxoutbuf - 0 + alpha2 + 1.0 - minoutbuf - 0 + color2 + "red" - samp_delay - 0 + label2 + - taps - [1] + width2 + 1 - type - fff + alpha3 + 1.0 - - - fir_filter_xxx - alias - + color3 + "green" - comment + label3 - affinity - + width3 + 1 - decim - decim + alpha4 + 1.0 - _enabled - True + color4 + "black" - _coordinate - (1136, 213) + label4 + - _rotation - 0 + width4 + 1 - id - fir_filter_xxx_0_0 + alpha5 + 1.0 - maxoutbuf - 0 + color5 + "cyan" - minoutbuf - 0 + label5 + - samp_delay - 0 + width5 + 1 - taps - [1] + alpha6 + 1.0 - type - fff + color6 + "magenta" - - - fir_filter_xxx - alias + label6 - comment - + width6 + 1 - affinity - + alpha7 + 1.0 - decim - decim + color7 + "yellow" - _enabled - True + label7 + - _coordinate - (1328, 389) + width7 + 1 - _rotation - 0 + alpha8 + 1.0 - id - fir_filter_xxx_0_1 + color8 + "dark red" - maxoutbuf - 0 + label8 + - minoutbuf - 0 + width8 + 1 - samp_delay - 0 + alpha9 + 1.0 - taps - [1] + color9 + "dark green" - type - fff + label9 + - - - logpwrfft_x - avg_alpha - 1.0 + width9 + 1 - average - False + maxoutbuf + 0 - alias - + minoutbuf + 0 - comment - + name + "" - affinity - + nconnections + 1 - _enabled + showports True - fft_size - 8192 + freqhalf + True - frame_rate - 30 + tr_chan + 0 - _coordinate - (1048, 585) + tr_level + 0.0 - _rotation - 0 + tr_mode + qtgui.TRIG_MODE_FREE - id - logpwrfft_x_0 + tr_tag + "" type complex - maxoutbuf - 0 + update_time + 0.1 - minoutbuf - 0 + wintype + firdes.WIN_BLACKMAN_hARRIS - ref_scale - 2 + ymax + 10 - sample_rate - samp_rate + ymin + -140 @@ -1719,7 +940,7 @@ bw - samp_rate/decimate + samp_rate alias @@ -1747,11 +968,11 @@ fftsize - 8192 + 16000 _coordinate - (1008, 478) + (1056, 38) gui_hint @@ -1767,7 +988,7 @@ id - qtgui_freq_sink_x_0_0 + qtgui_freq_sink_x_0_0_0 legend @@ -1994,65 +1215,6 @@ -140 - - rational_resampler_xxx - - alias - - - - comment - - - - affinity - - - - decim - decimate - - - _enabled - True - - - fbw - 0 - - - _coordinate - (776, 471) - - - _rotation - 0 - - - id - rational_resampler_xxx_0_0 - - - interp - 1 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - taps - - - - type - ccc - - uhd_amsg_source @@ -2077,7 +1239,7 @@ _coordinate - (504, 785) + (232, 329) _rotation @@ -2768,7 +1930,7 @@ _coordinate - (808, 111) + (1056, 119) _rotation @@ -3843,7 +3005,7 @@ _coordinate - (512, 462) + (256, 222) _rotation @@ -3994,48 +3156,6 @@ - - analog_const_source_x_0 - blocks_add_xx_1 - 0 - 0 - - - blocks_add_xx_1 - blocks_complex_to_mag_squared_0 - 0 - 0 - - - blocks_add_xx_1 - blocks_multiply_conjugate_cc_0 - 0 - 0 - - - blocks_add_xx_1 - uhd_usrp_sink_0 - 0 - 0 - - - blocks_complex_to_arg_0 - blocks_moving_average_xx_0 - 0 - 0 - - - blocks_complex_to_mag_squared_0 - blocks_moving_average_xx_0_0 - 0 - 0 - - - blocks_complex_to_mag_squared_0_0 - blocks_moving_average_xx_0_1 - 0 - 0 - blocks_file_source_0 blocks_multiply_const_vxx_1 @@ -4048,63 +3168,15 @@ 0 0 - - blocks_moving_average_xx_0 - fir_filter_xxx_0 - 0 - 0 - - - blocks_moving_average_xx_0_0 - fir_filter_xxx_0_0 - 0 - 0 - - - blocks_moving_average_xx_0_1 - fir_filter_xxx_0_1 - 0 - 0 - - - blocks_multiply_conjugate_cc_0 - blocks_complex_to_arg_0 - 0 - 0 - blocks_multiply_const_vxx_1 - blocks_add_xx_1 - 0 - 1 - - - fir_filter_xxx_0 - blocks_null_sink_0_0 - 0 - 0 - - - fir_filter_xxx_0_0 - blocks_null_sink_0 - 0 - 0 - - - fir_filter_xxx_0_1 - blocks_null_sink_0_1 - 0 - 0 - - - logpwrfft_x_0 - blocks_file_sink_0 + qtgui_freq_sink_x_0_0_0 0 0 - rational_resampler_xxx_0_0 - qtgui_freq_sink_x_0_0 + blocks_multiply_const_vxx_1 + uhd_usrp_sink_0 0 0 @@ -4116,25 +3188,7 @@ uhd_usrp_source_0 - blocks_complex_to_mag_squared_0_0 - 0 - 0 - - - uhd_usrp_source_0 - blocks_multiply_conjugate_cc_0 - 0 - 1 - - - uhd_usrp_source_0 - logpwrfft_x_0 - 0 - 0 - - - uhd_usrp_source_0 - rational_resampler_xxx_0_0 + qtgui_freq_sink_x_0_0 0 0 diff --git a/live_analyse_py.grc b/live_analyse_py.grc new file mode 100644 index 0000000..aada771 --- /dev/null +++ b/live_analyse_py.grc @@ -0,0 +1,2655 @@ + + + + Wed Oct 28 18:49:28 2015 + + options + + author + + + + window_size + 2000,2000 + + + category + Custom + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + no_gui + + + hier_block_src_path + .: + + + id + live_analyse_py + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + thread_safe_setters + + + + title + + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 165) + + + _rotation + 0 + + + id + decim + + + value + 4000 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (88, 301) + + + _rotation + 0 + + + id + decimate + + + value + 1 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (88, 237) + + + _rotation + 0 + + + id + freq + + + value + 222e6 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 301) + + + _rotation + 0 + + + id + rxgain + + + value + 20 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 85) + + + _rotation + 0 + + + id + samp_rate + + + value + 8e6 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 237) + + + _rotation + 0 + + + id + txgain + + + value + 50 + + + + analog_const_source_x + + alias + + + + comment + + + + const + 0 + + + affinity + + + + _enabled + True + + + _coordinate + (896, 76) + + + _rotation + 0 + + + id + analog_const_source_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + complex + + + + blks2_tcp_sink + + addr + 127.0.0.1 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (1256, 838) + + + _rotation + 0 + + + id + blks2_tcp_sink_1 + + + type + byte + + + server + True + + + port + 47010 + + + vlen + 1 + + + + blks2_tcp_sink + + addr + 127.0.0.1 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (1368, 599) + + + _rotation + 0 + + + id + blks2_tcp_sink_1_0 + + + type + float + + + server + True + + + port + 47009 + + + vlen + 8192 + + + + blocks_add_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (1112, 121) + + + _rotation + 0 + + + id + blocks_add_xx_1 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_file_source + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + /home/andreas/dab/dab_run.dat + + + _coordinate + (312, 141) + + + _rotation + 0 + + + id + blocks_file_source_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + complex + + + repeat + True + + + vlen + 1 + + + + blocks_message_burst_source + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (904, 857) + + + _rotation + 0 + + + id + blocks_message_burst_source_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + byte + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 1 + + + affinity + + + + _enabled + True + + + _coordinate + (512, 148) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_1 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + logpwrfft_x + + avg_alpha + 1.0 + + + average + False + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + fft_size + 8192 + + + frame_rate + 30 + + + _coordinate + (1048, 585) + + + _rotation + 0 + + + id + logpwrfft_x_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ref_scale + 2 + + + sample_rate + samp_rate + + + + uhd_amsg_source + + alias + + + + comment + + + + affinity + + + + dev_addr + + + + _enabled + True + + + _coordinate + (512, 857) + + + _rotation + 0 + + + id + uhd_amsg_source_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + uhd_usrp_sink + + alias + + + + ant0 + + + + bw0 + 0 + + + center_freq0 + freq + + + norm_gain0 + False + + + gain0 + txgain + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + norm_gain10 + False + + + gain10 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + norm_gain11 + False + + + gain11 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + norm_gain12 + False + + + gain12 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + norm_gain13 + False + + + gain13 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + norm_gain14 + False + + + gain14 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + norm_gain15 + False + + + gain15 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + norm_gain16 + False + + + gain16 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + norm_gain17 + False + + + gain17 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + norm_gain18 + False + + + gain18 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + norm_gain19 + False + + + gain19 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + norm_gain1 + False + + + gain1 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + norm_gain20 + False + + + gain20 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + norm_gain21 + False + + + gain21 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + norm_gain22 + False + + + gain22 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + norm_gain23 + False + + + gain23 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + norm_gain24 + False + + + gain24 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + norm_gain25 + False + + + gain25 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + norm_gain26 + False + + + gain26 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + norm_gain27 + False + + + gain27 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + norm_gain28 + False + + + gain28 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + norm_gain29 + False + + + gain29 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + norm_gain2 + False + + + gain2 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + norm_gain30 + False + + + gain30 + 0 + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + norm_gain31 + False + + + gain31 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + norm_gain3 + False + + + gain3 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + norm_gain4 + False + + + gain4 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + norm_gain5 + False + + + gain5 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + norm_gain6 + False + + + gain6 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + norm_gain7 + False + + + gain7 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + norm_gain8 + False + + + gain8 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + norm_gain9 + False + + + gain9 + 0 + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + "" + + + dev_args + "" + + + _enabled + True + + + _coordinate + (1232, 95) + + + _rotation + 0 + + + id + uhd_usrp_sink_0 + + + type + fc32 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + nchan + 1 + + + num_mboards + 1 + + + samp_rate + samp_rate + + + hide_cmd_port + False + + + stream_args + + + + stream_chans + [] + + + sync + + + + len_tag_name + + + + otw + + + + + uhd_usrp_source + + alias + + + + ant0 + + + + bw0 + 0 + + + center_freq0 + freq + + + dc_offs_enb0 + "" + + + iq_imbal_enb0 + "" + + + norm_gain0 + False + + + gain0 + rxgain + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + dc_offs_enb10 + "" + + + iq_imbal_enb10 + "" + + + norm_gain10 + False + + + gain10 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + dc_offs_enb11 + "" + + + iq_imbal_enb11 + "" + + + norm_gain11 + False + + + gain11 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + dc_offs_enb12 + "" + + + iq_imbal_enb12 + "" + + + norm_gain12 + False + + + gain12 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + dc_offs_enb13 + "" + + + iq_imbal_enb13 + "" + + + norm_gain13 + False + + + gain13 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + dc_offs_enb14 + "" + + + iq_imbal_enb14 + "" + + + norm_gain14 + False + + + gain14 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + dc_offs_enb15 + "" + + + iq_imbal_enb15 + "" + + + norm_gain15 + False + + + gain15 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + dc_offs_enb16 + "" + + + iq_imbal_enb16 + "" + + + norm_gain16 + False + + + gain16 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + dc_offs_enb17 + "" + + + iq_imbal_enb17 + "" + + + norm_gain17 + False + + + gain17 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + dc_offs_enb18 + "" + + + iq_imbal_enb18 + "" + + + norm_gain18 + False + + + gain18 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + dc_offs_enb19 + "" + + + iq_imbal_enb19 + "" + + + norm_gain19 + False + + + gain19 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + dc_offs_enb1 + "" + + + iq_imbal_enb1 + "" + + + norm_gain1 + False + + + gain1 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + dc_offs_enb20 + "" + + + iq_imbal_enb20 + "" + + + norm_gain20 + False + + + gain20 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + dc_offs_enb21 + "" + + + iq_imbal_enb21 + "" + + + norm_gain21 + False + + + gain21 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + dc_offs_enb22 + "" + + + iq_imbal_enb22 + "" + + + norm_gain22 + False + + + gain22 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + dc_offs_enb23 + "" + + + iq_imbal_enb23 + "" + + + norm_gain23 + False + + + gain23 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + dc_offs_enb24 + "" + + + iq_imbal_enb24 + "" + + + norm_gain24 + False + + + gain24 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + dc_offs_enb25 + "" + + + iq_imbal_enb25 + "" + + + norm_gain25 + False + + + gain25 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + dc_offs_enb26 + "" + + + iq_imbal_enb26 + "" + + + norm_gain26 + False + + + gain26 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + dc_offs_enb27 + "" + + + iq_imbal_enb27 + "" + + + norm_gain27 + False + + + gain27 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + dc_offs_enb28 + "" + + + iq_imbal_enb28 + "" + + + norm_gain28 + False + + + gain28 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + dc_offs_enb29 + "" + + + iq_imbal_enb29 + "" + + + norm_gain29 + False + + + gain29 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + dc_offs_enb2 + "" + + + iq_imbal_enb2 + "" + + + norm_gain2 + False + + + gain2 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + dc_offs_enb30 + "" + + + iq_imbal_enb30 + "" + + + norm_gain30 + False + + + gain30 + 0 + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + dc_offs_enb31 + "" + + + iq_imbal_enb31 + "" + + + norm_gain31 + False + + + gain31 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + dc_offs_enb3 + "" + + + iq_imbal_enb3 + "" + + + norm_gain3 + False + + + gain3 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + dc_offs_enb4 + "" + + + iq_imbal_enb4 + "" + + + norm_gain4 + False + + + gain4 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + dc_offs_enb5 + "" + + + iq_imbal_enb5 + "" + + + norm_gain5 + False + + + gain5 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + dc_offs_enb6 + "" + + + iq_imbal_enb6 + "" + + + norm_gain6 + False + + + gain6 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + dc_offs_enb7 + "" + + + iq_imbal_enb7 + "" + + + norm_gain7 + False + + + gain7 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + dc_offs_enb8 + "" + + + iq_imbal_enb8 + "" + + + norm_gain8 + False + + + gain8 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + dc_offs_enb9 + "" + + + iq_imbal_enb9 + "" + + + norm_gain9 + False + + + gain9 + 0 + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + "" + + + dev_args + "" + + + _enabled + True + + + _coordinate + (512, 462) + + + _rotation + 0 + + + id + uhd_usrp_source_0 + + + maxoutbuf + 0 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + minoutbuf + 0 + + + nchan + 1 + + + num_mboards + 1 + + + type + fc32 + + + samp_rate + samp_rate + + + hide_cmd_port + False + + + stream_args + + + + stream_chans + [] + + + sync + + + + otw + + + + + analog_const_source_x_0 + blocks_add_xx_1 + 0 + 0 + + + blocks_add_xx_1 + uhd_usrp_sink_0 + 0 + 0 + + + blocks_file_source_0 + blocks_multiply_const_vxx_1 + 0 + 0 + + + blocks_message_burst_source_0_0 + blks2_tcp_sink_1 + 0 + 0 + + + blocks_multiply_const_vxx_1 + blocks_add_xx_1 + 0 + 1 + + + logpwrfft_x_0 + blks2_tcp_sink_1_0 + 0 + 0 + + + uhd_amsg_source_0_0 + blocks_message_burst_source_0_0 + msg + msg + + + uhd_usrp_source_0 + logpwrfft_x_0 + 0 + 0 + + diff --git a/run.ipynb b/run.ipynb index 5c61960..4f243d8 100644 --- a/run.ipynb +++ b/run.ipynb @@ -11,6 +11,8 @@ "import numpy as np\n", "import time\n", "import src.gen_source as gen_source\n", + "from guppy import hpy \n", + "import mydab\n", "\n", "import tcp_async\n", "import tcp_sync\n", @@ -29,6 +31,7 @@ " reload(tcp_async)\n", " reload(tcp_sync)\n", " reload(gen_source)\n", + " reload(mydab)\n", "except:\n", " pass" ] @@ -124,38 +127,114 @@ "metadata": {}, "outputs": [], "source": [ - "top.set_txgain(85)\n", - "for x2 in np.linspace(-0.15, 0.15, num = 15):\n", + "import itertools\n", + "x = np.linspace(-0.1, 0.1, num = 5)\n", + "l = list(itertools.product(x,x,x,x,x))\n", + "mag = [sum(map(lambda x:x*x,el)) for el in l]\n", + "idx = list(np.argsort(mag))\n", + "l = list(np.array(l)[idx])\n", + "len(l)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "top.set_txgain(84)\n", + "sync.has_msg()\n", + "msgs = np.array(sync.get_msgs(2))\n", + "fft = np.fft.fftshift(msgs[0])\n", + "#plt.plot(fft)\n", + "#plt.plot((4000 - f, 4000 -f),(-180,-40))\n", + "\n", + "mydab.calc_signal_sholder_ratio(fft, fft_size, samp_rate)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def meas(i):\n", + " import sys\n", + " sys.stdout.write(str(i) + \" \")\n", + " top.set_txgain(i)\n", + " sync.has_msg()\n", + " msgs = np.array(sync.get_msgs(10))\n", + " \n", + " res = []\n", + " for msg in msgs:\n", + " fft = np.fft.fftshift(msg)\n", + " res.append(mydab.calc_signal_sholder_ratio(fft, fft_size, samp_rate))\n", + " return np.mean(res)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "res = [meas(i) for i in range(89)]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.plot(res)\n", + "plt.title(\"DAB sholders\")\n", + "plt.xlabel(\"tx gain [db]\")\n", + "plt.ylabel(\"signal - sholder [db]\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "top.set_txgain(84)\n", + "for el in l:\n", " t2 = time.time()\n", - " for x3 in np.linspace(-0.15, 0.15, num = 14):\n", - " for x4 in np.linspace(-0.15, 0.15, num = 7):\n", - " path = gen_source.gen_file(frequency_0=frequency_0,\n", - " frequency_1=frequency_1,\n", - " samp_rate=samp_rate,\n", - " x2 = x2,\n", - " x3 = x3,\n", - " x4 = x4,\n", - " path='./np_twotone')\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", - " inter_mod_avg = (np.max(score(msgs[0], frequency_0, frequency_1, samp_rate)) \n", - " + np.max(score(msgs[1], frequency_0, frequency_1, samp_rate)) \n", - " + np.max(score(msgs[2], frequency_0, frequency_1, samp_rate)) \n", - " + np.max(score(msgs[3], frequency_0, frequency_1, samp_rate)) \n", - " + np.max(score(msgs[4], frequency_0, frequency_1, samp_rate)))/5\n", - " msg = msgs[0]\n", - " \n", - " \n", - " print(\"inter_mod %.3f, x_2 %.3f, x_3 %.3f\" % (inter_mod_avg, x2, x3))\n", - " \n", - " plt.plot(msg)\n", - " plt.savefig(\"/tmp/out/inter_mod_%.3f_x_2_%.3f_x_3_%.3f_x_4_%.3f.png\" % (inter_mod_avg, x2, x3, x4))\n", - " plt.clf()\n", - " print(time.time() - t2)" + " 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)" ] }, { @@ -202,6 +281,41 @@ "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, diff --git a/src/gen_source.py b/src/gen_source.py index a8c2ef2..7620bc3 100644 --- a/src/gen_source.py +++ b/src/gen_source.py @@ -6,24 +6,91 @@ def complex_exp(freq, samp_rate, periods, phase_deg=0): t = np.arange(t_max) fac = t / samp_rate * freq phase = 1j * phase_deg/360*2*np.pi - ret = np.exp(phase + 1j * 2 * np.pi * fac - 1j * np.pi / 2, dtype=np.complex64) + ret = np.exp(phase + 1j * 2 * np.pi * fac - 1j * np.pi / 2, dtype=np.complex128) return ret ret = complex_exp(10,40,2) -def gen_file(frequency_0, frequency_1, x1 = 0, x2 = 0, x3 = 0, x4 = 0, samp_rate = 4000000, path = "./np_twotone"): - tone_0 = complex_exp(frequency_0, samp_rate, samp_rate/frequency_1) - tone_1 = complex_exp(frequency_1, samp_rate, samp_rate/frequency_0) +def gen_file(frequency_0, frequency_1, coefs = [], samp_rate = 4000000, path = "./np_twotone", count = 1): + tone_0 = complex_exp(frequency_0, samp_rate, samp_rate/frequency_1 * count) + tone_1 = complex_exp(frequency_1, samp_rate, samp_rate/frequency_0 * count) + + min_len = min(tone_0.shape[0], tone_1.shape[0]) + two_tone = (tone_0[0:min_len] + tone_1[0:min_len]) + res = two_tone + + for idx, coef in enumerate(coefs): + res += two_tone * np.abs(two_tone)**(idx+1) * coef #+1 because first correction term is squared + + res = res / np.max(res) * 0.9 + + res = res.astype(np.complex64) + res.tofile(path) + + a_load = np.fromfile(path, dtype=np.complex64) + assert(np.isclose(a_load, res).all()), "Inconsistent stored file" + + return path + +def gen_file_d(frequency_0, frequency_1, x1 = 0, x2 = 0, x3 = 0, x4 = 0, samp_rate = 4000000, path = "./np_twotone", count = 1): + tone_0 = complex_exp(frequency_0, samp_rate, samp_rate/frequency_1 * count) + tone_1 = complex_exp(frequency_1, samp_rate, samp_rate/frequency_0 * count) + + min_len = min(tone_0.shape[0], tone_1.shape[0]) + two_tone = (tone_0[0:min_len] + tone_1[0:min_len]) + + two_tone_1 = np.gradient(two_tone) + two_tone_2 = np.gradient(two_tone_1) + two_tone_3 = np.gradient(two_tone_2) + two_tone_4 = np.gradient(two_tone_3) + + two_tone = two_tone \ + + two_tone_1 * x1 \ + + two_tone_2 * x2 \ + + two_tone_3 * x3 \ + + two_tone_4 * x4 + + two_tone = two_tone / np.max(two_tone) * 0.9 + + two_tone = two_tone.astype(np.complex64) + two_tone.tofile(path) + + a_load = np.fromfile(path, dtype=np.complex64) + assert(np.isclose(a_load, two_tone).all()), "Inconsistent stored file" + + return path + +def gen_file_i(frequency_0, frequency_1, x1 = 0, x2 = 0, x3 = 0, x4 = 0, samp_rate = 4000000, path = "./np_twotone", count = 1): + if frequency_0 > frequency_1: + f = frequency_0 + frequency_1 = frequency_0 + frequency_0 = f + + tone_0 = complex_exp(frequency_0, samp_rate, samp_rate/frequency_1 * count) + tone_1 = complex_exp(frequency_1, samp_rate, samp_rate/frequency_0 * count) + + df = frequency_1 - frequency_0 + tone_0_0 = complex_exp(frequency_0 - df, samp_rate, samp_rate/frequency_1 * count, pahse = x2) + tone_0_1 = complex_exp(frequency_1 + df, samp_rate, samp_rate/frequency_1 * count, pahse = x2) + + + min_len = min(tone_0.shape[0], tone_1.shape[0]) + two_tone = (tone_0[0:min_len] + tone_1[0:min_len]) + + two_tone_1 = np.gradient(two_tone) + two_tone_2 = np.gradient(two_tone_1) + two_tone_3 = np.gradient(two_tone_2) + two_tone_4 = np.gradient(two_tone_3) - two_tone = (tone_0 + tone_1) two_tone = two_tone \ - + np.abs(two_tone)**1 * x1 \ - + np.abs(two_tone)**2 * x2 \ - + np.abs(two_tone)**3 * x3 \ - + np.abs(two_tone)**4 * x4 + + two_tone_1 * x1 \ + + two_tone_2 * x2 \ + + two_tone_3 * x3 \ + + two_tone_4 * x4 two_tone = two_tone / np.max(two_tone) * 0.9 + two_tone = two_tone.astype(np.complex64) two_tone.tofile(path) a_load = np.fromfile(path, dtype=np.complex64) -- cgit v1.2.3