diff options
author | Martin Braun <martin@gnuradio.org> | 2020-12-18 11:42:24 +0100 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-12-19 01:01:11 +0100 |
commit | 7e112bfd12731073ac2970aa97f789abeb6f7e88 (patch) | |
tree | bfb884f40111d4ddb4735d1c2f15d3dcb672f2f2 /gr-digital | |
parent | 76f05e7585e23541eaab0890b8dc90296903795b (diff) |
digital: ofdm: Fix whitespace in OFDM chanest block
Both the C++ and Python files have really weird whitespace issues,
making them hard to read. This makes the whitespace usage for consistent
with usual formatting, and fixes some Doxygen issues.
Signed-off-by: Martin Braun <martin@gnuradio.org>
Diffstat (limited to 'gr-digital')
3 files changed, 49 insertions, 60 deletions
diff --git a/gr-digital/include/gnuradio/digital/ofdm_chanest_vcvc.h b/gr-digital/include/gnuradio/digital/ofdm_chanest_vcvc.h index 259215b020..94b541c3c2 100644 --- a/gr-digital/include/gnuradio/digital/ofdm_chanest_vcvc.h +++ b/gr-digital/include/gnuradio/digital/ofdm_chanest_vcvc.h @@ -17,10 +17,9 @@ namespace gr { namespace digital { -/*! - * \brief Estimate channel and coarse frequency offset for OFDM from preambles +/*! Estimate channel and coarse frequency offset for OFDM from preambles * \ingroup ofdm_blk - * \ingroup syncronizers_blk + * \ingroup synchronizers_blk * * Input: OFDM symbols (in frequency domain). The first one (or two) symbols are expected * to be synchronisation symbols, which are used to estimate the coarse freq offset @@ -33,14 +32,14 @@ namespace digital { * synchronisation symbols are attached to the first data symbol. All other tags are * propagated as expected. * - * Note: The vector on ofdm_sync_eq_taps is already frequency-corrected, whereas the rest - * is not. + * Note: The vector on ofdm_sync_eq_taps is already frequency-corrected, whereas + * the rest is not. * * This block assumes the frequency offset is even (i.e. an integer multiple of 2). * - * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for - * OFDM", Communications, IEEE Transactions on, 1997. [2] K.D. Kammeyer, - * "Nachrichtenuebertragung," Chapter. 16.3.2. + * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization + * for OFDM", Communications, IEEE Transactions on, 1997. + * [2] K.D. Kammeyer, "Nachrichtenuebertragung," Chapter. 16.3.2. */ class DIGITAL_API ofdm_chanest_vcvc : virtual public block { @@ -48,23 +47,31 @@ public: typedef std::shared_ptr<ofdm_chanest_vcvc> sptr; /*! - * \param sync_symbol1 First synchronisation symbol in the frequency domain. Its - * length must be the FFT length. For Schmidl & Cox synchronisation, every second - * sub-carrier has to be zero. \param sync_symbol2 Second synchronisation symbol in - * the frequency domain. Must be equal to the FFT length, or zero length if only one - * synchronisation symbol is used. Using this symbol is how synchronisation is - * described in [1]. Leaving this empty forces us to interpolate the equalizer taps. - * If you are using an unusual sub-carrier configuration (e.g. - * because of OFDMA), this sync symbol is used to identify the active sub-carriers. If - * you only have one synchronisation symbol, set the active sub-carriers to a non-zero - * value in here, and also set \p force_one_sync_symbol parameter - * to true. \param n_data_symbols The number of data symbols following each set of - * synchronisation symbols. Must be at least 1. \param eq_noise_red_len If non-zero, - * noise reduction for the equalizer taps is done according to [2]. In this case, it - * is the channel influence time in number of samples. A good value is usually the - * length of the cyclic prefix. \param max_carr_offset Limit the number of - * sub-carriers the frequency offset can maximally be. Leave this zero to try all - * possibilities. \param force_one_sync_symbol See \p sync_symbol2. + * \param sync_symbol1 First synchronisation symbol in the frequency domain. + * Its length must be the FFT length. For Schmidl & Cox + * synchronisation, every second sub-carrier has to be zero. + * \param sync_symbol2 Second synchronisation symbol in the frequency domain. + * Must be equal to the FFT length, or zero length if + * only one synchronisation symbol is used. Using this + * symbol is how synchronisation is described in [1]. + * Leaving this empty forces us to interpolate the + * equalizer taps. + * If you are using an unusual sub-carrier configuration + * (e.g. because of OFDMA), this sync symbol is used to + * identify the active sub-carriers. If you only have + * one synchronisation symbol, set the active sub-carriers + * to a non-zero value in here, and set \p force_one_sync_symbol + * parameter to true. + * \param n_data_symbols The number of data symbols following each set of + * synchronisation symbols. Must be at least 1. + * \param eq_noise_red_len If non-zero, noise reduction for the equalizer + * taps is done according to [2]. In this case, it + * is the channel influence time in number of samples. + * A good value is usually the length of the cyclic prefix. + * \param max_carr_offset Limit the number of sub-carriers the frequency + * offset can maximally be. Leave this zero to try + * all possibilities. + * \param force_one_sync_symbol See \p sync_symbol2. */ static sptr make(const std::vector<gr_complex>& sync_symbol1, const std::vector<gr_complex>& sync_symbol2, diff --git a/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc b/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc index bf77ebd0ae..009d6b2e66 100644 --- a/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc +++ b/gr-digital/python/digital/bindings/ofdm_chanest_vcvc_python.cc @@ -13,8 +13,8 @@ /* If manual edits are made, the following tags should be modified accordingly. */ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(ofdm_chanest_vcvc.h) */ -/* BINDTOOL_HEADER_FILE_HASH(82caca03752b79f24d3d33c573cf570b) */ +/* BINDTOOL_HEADER_FILE(ofdm_chanest_vcvc.h) */ +/* BINDTOOL_HEADER_FILE_HASH(a4f2516ae6c6cc38e9cf81673542ef76) */ /***********************************************************************************/ #include <pybind11/complex.h> diff --git a/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py b/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py index c69d2af984..f51aca8fc7 100644 --- a/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py +++ b/gr-digital/python/digital/qa_ofdm_chanest_vcvc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2012-2014 Free Software Foundation, Inc. # # This file is part of GNU Radio @@ -7,9 +7,6 @@ # # - -import sys -import numpy import random import numpy @@ -21,9 +18,9 @@ def shift_tuple(vec, N): """ Shifts a vector by N elements. Fills up with zeros. """ if N > 0: return (0,) * N + tuple(vec[0:-N]) - else: - N = -N - return tuple(vec[N:]) + (0,) * N + # else: + N = -N + return tuple(vec[N:]) + (0,) * N def rand_range(min_val, max_val): @@ -103,7 +100,7 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): for tag in tags: if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': carr_offset_hat = pmt.to_long(tag.value) - self.assertEqual(pmt.to_long(tag.value), carr_offset) + self.assertEqual(carr_offset_hat, carr_offset) def test_003_channel_no_carroffset(self): """ Add a channel, check if it's correctly estimated """ @@ -215,12 +212,7 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): self.assertEqual(chan_est, chanest_exp) self.assertEqual( sink.data(), - list( - numpy.multiply( - shift_tuple( - data_symbol, - carr_offset), - channel))) + list(numpy.multiply(shift_tuple(data_symbol, carr_offset), channel))) def test_999_all_at_once(self): """docstring for test_999_all_at_once""" @@ -306,15 +298,9 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): shift_tuple(sync_sym2, carr_offset) + \ shift_tuple(data_sym, carr_offset) channel = [ - rand_range( - min_chan_ampl, - max_chan_ampl) * - numpy.exp( - 1j * - rand_range( - 0, - 2 * - numpy.pi)) for x in range(fft_len)] + rand_range(min_chan_ampl, max_chan_ampl) * + numpy.exp(1j * rand_range(0, 2 * numpy.pi)) + for x in range(fft_len)] src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) noise = analog.noise_source_c(analog.GR_GAUSSIAN, wgn_amplitude) @@ -323,8 +309,8 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): sink = blocks.vector_sink_c(fft_len) top_block.connect(src, chan, (add, 0), chanest, sink) top_block.connect( - noise, blocks.stream_to_vector( - gr.sizeof_gr_complex, fft_len), (add, 1)) + noise, + blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), (add, 1)) top_block.run() channel_est = None carr_offset_hat = 0 @@ -341,15 +327,11 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): shifted_carrier_mask = shift_tuple(carrier_mask, carr_offset) for i in range(fft_len): if shifted_carrier_mask[i] and channel_est[i]: - self.assertAlmostEqual( - channel[i], channel_est[i], places=0) + self.assertAlmostEqual(channel[i], channel_est[i], places=0) rx_sym_est[i] = (sink.data()[i] / channel_est[i]).real - return ( - carr_offset, list( - shift_tuple( - rx_sym_est, -carr_offset_hat))) + return carr_offset, list(shift_tuple(rx_sym_est, -carr_offset_hat)) bit_errors = 0 - for k in range(n_iter): + for _ in range(n_iter): sync_sym = [(random.randint(0, 1) * 2 - 1) * syncsym_mask[i] for i in range(fft_len)] ref_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] @@ -357,7 +339,7 @@ class qa_ofdm_chanest_vcvc (gr_unittest.TestCase): data_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] for i in range(fft_len)] data_sym[26] = 1 - (carr_offset, rx_sym) = run_flow_graph(sync_sym, ref_sym, data_sym) + (_, rx_sym) = run_flow_graph(sync_sym, ref_sym, data_sym) rx_sym_est = [0, ] * fft_len for i in range(fft_len): if carrier_mask[i] == 0: |