diff options
author | Nao Pross <np@0hm.ch> | 2021-12-09 17:46:06 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-12-09 17:46:17 +0100 |
commit | 4b4589a3d6264059b6e0949681ec697605fb990c (patch) | |
tree | 484b33ece38cc653291323c77393c6002689a0ca /tests | |
parent | Create phase correction block in gr-fadingui (diff) | |
download | Fading-4b4589a3d6264059b6e0949681ec697605fb990c.tar.gz Fading-4b4589a3d6264059b6e0949681ec697605fb990c.zip |
Remove unnecessary (out of date) FIXME
Diffstat (limited to 'tests')
-rw-r--r-- | tests/correlator/correlator.grc | 89 | ||||
-rwxr-xr-x | tests/correlator/correlator.py | 6 | ||||
-rw-r--r-- | tests/correlator/epy_block_0.py | 15 |
3 files changed, 41 insertions, 69 deletions
diff --git a/tests/correlator/correlator.grc b/tests/correlator/correlator.grc index ff09a40..9fc6699 100644 --- a/tests/correlator/correlator.grc +++ b/tests/correlator/correlator.grc @@ -144,7 +144,7 @@ blocks: id: variable parameters: comment: '' - value: '[0x1f, 0x35] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3] ' + value: '[0x1f, 0x35] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3, 0x21] ' states: bus_sink: false bus_source: false @@ -251,7 +251,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [672, 1252.0] + coordinate: [512, 1252.0] rotation: 0 state: true - name: blocks_stream_mux_0 @@ -273,25 +273,6 @@ blocks: coordinate: [288, 256.0] rotation: 0 state: enabled -- name: blocks_tag_debug_0 - id: blocks_tag_debug - parameters: - affinity: '' - alias: '' - comment: '' - display: 'True' - filter: '""' - name: '' - num_inputs: '1' - type: byte - vlen: '1' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [1208, 1164.0] - rotation: 0 - state: disabled - name: blocks_tagged_stream_align_0 id: blocks_tagged_stream_align parameters: @@ -307,7 +288,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [928, 1260.0] + coordinate: [768, 1260.0] rotation: 0 state: true - name: blocks_throttle_0 @@ -464,22 +445,6 @@ blocks: coordinate: [1104, 808.0] rotation: 0 state: true -- name: digital_map_bb_0 - id: digital_map_bb - parameters: - affinity: '' - alias: '' - comment: '' - map: '[0, 1, 3, 2]' - maxoutbuf: '0' - minoutbuf: '0' - states: - bus_sink: false - bus_source: false - bus_structure: null - coordinate: [496, 1260.0] - rotation: 0 - state: enabled - name: digital_pfb_clock_sync_xxx_0 id: digital_pfb_clock_sync_xxx parameters: @@ -516,22 +481,24 @@ blocks: \ be propagated, we then output our own tags\n self.set_tag_propagation_policy(gr.TPP_DONT)\n\ \n # because we do block processing, we need to keep track of the last\ \ tag\n # of the previous block to correct the first values of the next\ - \ block\n self.last = None\n self.lastfreq = 0\n\n def block_phase(self,\ - \ start, end):\n \"\"\"\n Compute a vector for the phase and frequency\ - \ correction for the samples\n between two tags (start and end).\n\n\ - \ @param start Tag where the samples should start to be corrected\n \ - \ @param end Tag where to stop correcting\n\n @return A vector\ - \ of phase values for each sample. To correct the samples\n the\ - \ data should be multiplied with np.exp(-1j * phase)\n \"\"\"\n \ - \ # compute number of samples between tags\n nsamples = end.offset\ - \ - start.offset\n\n # unpack pmt values into start and end phase\n \ - \ sphase = pmt.to_python(start.value)\n ephase = pmt.to_python(end.value)\n\ + \ block\n self.last = None\n self.lastfreq = 0\n self.lastnback\ + \ = 0\n self.lastnsamples = 0\n\n def block_phase(self, start, end):\n\ + \ \"\"\"\n Compute a vector for the phase and frequency correction\ + \ for the samples\n between two tags (start and end).\n\n @param\ + \ start Tag where the samples should start to be corrected\n @param end\ + \ Tag where to stop correcting\n\n @return A vector of phase values\ + \ for each sample. To correct the samples\n the data should be\ + \ multiplied with np.exp(-1j * phase)\n \"\"\"\n # compute number\ + \ of samples between tags\n nsamples = end.offset - start.offset\n\n\ + \ # debugging, see last lines of self.work()\n self.lastnsamples\ + \ = nsamples\n\n # unpack pmt values into start and end phase\n \ + \ sphase = pmt.to_python(start.value)\n ephase = pmt.to_python(end.value)\n\ \n # compute frequency offset between start and end\n phasediff\ \ = (ephase - sphase) % (2 * np.pi)\n freq = phasediff / nsamples\n\n\ \ # save this one for the last block (see variable `end' in self.work)\n\ \ self.lastfreq = freq\n\n # debugging\n print(f\"Correction\ \ for chunk of {nsamples:2d} samples is \" \\\n f\"sphase={sphase:\ - \ .4f} rad and freq={freq*1e3: .4f} milli rad / sample\")\n\n # compute\ + \ .4f} rad and freq={freq*1e3: .4f}e-3 rad / sample\")\n\n # compute\ \ chunk values\n return sphase * np.ones(nsamples) + freq * np.arange(0,\ \ nsamples)\n\n def work(self, input_items, output_items):\n counter\ \ = self.nitems_written(0)\n\n # nicer aliases\n inp = input_items[0]\n\ @@ -550,19 +517,19 @@ blocks: \ but we can use the frequency of the last tag to approximate\n nback\ \ = len(inp) - (tags[-1].offset - counter)\n print(f\"Processing {nback}\ \ samples at the back of the buffer\")\n end = np.ones(nback) * pmt.to_python(tags[-1].value)\ - \ \\\n + self.lastfreq * np.arange(0, nback)\n\n # compute\ + \ \\\n + self.lastfreq * np.arange(0, nback)\n\n\n # compute\ \ the \"start\", using the last tag from the previous call\n nfront =\ \ tags[0].offset - counter\n print(f\"Processing {nfront} samples at\ \ the front of the buffer\")\n start = self.block_phase(self.last, tags[0])[-nfront:]\ \ \\\n if self.last and nfront else np.zeros(nfront)\n\n \ - \ # compute correction\n correction = np.exp(-1j * np.concatenate([start,\ - \ middle, end]))\n length = len(correction)\n\n # write outputs\n\ - \ out[:length] = inp[:length] * correction\n\n # save last tag\ - \ for next call\n self.last = tags[-1]\n\n # add tags\n \ - \ for tag in tags:\n self.add_item_tag(0, tag.offset, pmt.intern(\"\ - frame_start\"), pmt.PMT_T)\n\n # FIXME: should return `length' but then\ - \ the last sample is not\n # included and self.last does something\ - \ weird\n return len(out)\n" + \ # debugging\n if nfront + self.lastnback != self.lastnsamples:\n\ + \ print(f\"Something went wrong: {self.lastnback + nfront} != self.lastnsamples\"\ + )\n self.lastnback = nback\n\n # compute correction\n correction\ + \ = np.exp(-1j * np.concatenate([start, middle, end]))\n length = len(correction)\n\ + \n # write outputs\n out[:length] = inp[:length] * correction\n\ + \n # save last tag for next call\n self.last = tags[-1]\n\n \ + \ # add tags\n for tag in tags:\n self.add_item_tag(0,\ + \ tag.offset, pmt.intern(\"frame_start\"), pmt.PMT_T)\n\n return len(out)\n" affinity: '' alias: '' comment: '' @@ -602,7 +569,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1232, 1264.0] + coordinate: [1072, 1264.0] rotation: 0 state: true - name: fir_filter_xxx_1 @@ -1384,7 +1351,6 @@ connections: - [blocks_null_source_0, '0', blocks_stream_mux_0, '0'] - [blocks_repack_bits_bb_0, '0', blocks_tagged_stream_align_0, '0'] - [blocks_stream_mux_0, '0', digital_constellation_modulator_0, '0'] -- [blocks_tagged_stream_align_0, '0', blocks_tag_debug_0, '0'] - [blocks_tagged_stream_align_0, '0', epy_block_1, '0'] - [blocks_throttle_0, '0', virtual_sink_0, '0'] - [blocks_vector_source_x_0, '0', blocks_stream_mux_0, '1'] @@ -1393,7 +1359,7 @@ connections: - [digital_cma_equalizer_cc_0, '0', fir_filter_xxx_1, '0'] - [digital_cma_equalizer_cc_0, '0', qtgui_const_sink_x_0, '0'] - [digital_cma_equalizer_cc_0, '0', qtgui_time_sink_x_1_1, '0'] -- [digital_constellation_decoder_cb_0, '0', digital_map_bb_0, '0'] +- [digital_constellation_decoder_cb_0, '0', blocks_repack_bits_bb_0, '0'] - [digital_constellation_modulator_0, '0', channels_channel_model_0, '0'] - [digital_constellation_modulator_0, '0', qtgui_time_sink_x_1_0, '0'] - [digital_corr_est_cc_0, '0', digital_costas_loop_cc_0, '0'] @@ -1401,7 +1367,6 @@ connections: - [digital_corr_est_cc_0, '0', qtgui_time_sink_x_0_0_0, '0'] - [digital_corr_est_cc_0, '1', blocks_complex_to_magphase_0_0, '0'] - [digital_costas_loop_cc_0, '0', qtgui_const_sink_x_0_0, '1'] -- [digital_map_bb_0, '0', blocks_repack_bits_bb_0, '0'] - [digital_pfb_clock_sync_xxx_0, '0', digital_cma_equalizer_cc_0, '0'] - [epy_block_0, '0', qtgui_const_sink_x_0_0, '0'] - [epy_block_0, '0', virtual_sink_3, '0'] diff --git a/tests/correlator/correlator.py b/tests/correlator/correlator.py index d9dedb2..3f3b8fc 100755 --- a/tests/correlator/correlator.py +++ b/tests/correlator/correlator.py @@ -80,7 +80,7 @@ class correlator(gr.top_block, Qt.QWidget): self.nfilts = nfilts = 32 self.excess_bw = excess_bw = .35 self.timing_loop_bw = timing_loop_bw = 2 * np.pi / 100 - self.testvec = testvec = [0x1f, 0x35] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3] + self.testvec = testvec = [0x1f, 0x35] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3, 0x21] self.samp_rate = samp_rate = int(1.5e6) self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 45*nfilts) self.revconj_access_code_symbols = revconj_access_code_symbols = [(1.4142135623730951+1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (-1.4142135623730951+1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951-1.4142135623730951j), (1.4142135623730951+1.4142135623730951j), (-1.4142135623730951+1.4142135623730951j)] @@ -332,7 +332,6 @@ class correlator(gr.top_block, Qt.QWidget): self.epy_block_1 = epy_block_1.blk() self.epy_block_0 = epy_block_0.blk() self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, rrc_taps, nfilts, 16, 1.5, 1) - self.digital_map_bb_0 = digital.map_bb([0, 1, 3, 2]) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2 * 3.141592653589793 / 100, 4, False) self.digital_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, .9, digital.THRESHOLD_ABSOLUTE) self.digital_constellation_modulator_0 = digital.generic_mod( @@ -377,7 +376,7 @@ class correlator(gr.top_block, Qt.QWidget): self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) - self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_map_bb_0, 0)) + self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_magphase_0_0, 0)) @@ -385,7 +384,6 @@ class correlator(gr.top_block, Qt.QWidget): self.connect((self.digital_corr_est_cc_0, 0), (self.epy_block_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 1)) - self.connect((self.digital_map_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.epy_block_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.epy_block_0, 0), (self.qtgui_const_sink_x_0_0, 0)) diff --git a/tests/correlator/epy_block_0.py b/tests/correlator/epy_block_0.py index aa3065a..7821b3e 100644 --- a/tests/correlator/epy_block_0.py +++ b/tests/correlator/epy_block_0.py @@ -26,6 +26,8 @@ class blk(gr.sync_block): # of the previous block to correct the first values of the next block self.last = None self.lastfreq = 0 + self.lastnback = 0 + self.lastnsamples = 0 def block_phase(self, start, end): """ @@ -41,6 +43,9 @@ class blk(gr.sync_block): # compute number of samples between tags nsamples = end.offset - start.offset + # debugging, see last lines of self.work() + self.lastnsamples = nsamples + # unpack pmt values into start and end phase sphase = pmt.to_python(start.value) ephase = pmt.to_python(end.value) @@ -54,7 +59,7 @@ class blk(gr.sync_block): # debugging print(f"Correction for chunk of {nsamples:2d} samples is " \ - f"sphase={sphase: .4f} rad and freq={freq*1e3: .4f} milli rad / sample") + f"sphase={sphase: .4f} rad and freq={freq*1e3: .4f}e-3 rad / sample") # compute chunk values return sphase * np.ones(nsamples) + freq * np.arange(0, nsamples) @@ -92,12 +97,18 @@ class blk(gr.sync_block): end = np.ones(nback) * pmt.to_python(tags[-1].value) \ + self.lastfreq * np.arange(0, nback) + # compute the "start", using the last tag from the previous call nfront = tags[0].offset - counter print(f"Processing {nfront} samples at the front of the buffer") start = self.block_phase(self.last, tags[0])[-nfront:] \ if self.last and nfront else np.zeros(nfront) + # debugging + if nfront + self.lastnback != self.lastnsamples: + print(f"Something went wrong: {self.lastnback + nfront} != self.lastnsamples") + self.lastnback = nback + # compute correction correction = np.exp(-1j * np.concatenate([start, middle, end])) length = len(correction) @@ -112,6 +123,4 @@ class blk(gr.sync_block): for tag in tags: self.add_item_tag(0, tag.offset, pmt.intern("frame_start"), pmt.PMT_T) - # FIXME: should return `length' but then the last sample is not - # included and self.last does something weird return len(out) |