From 5d2f01fe71b736f2f5bb8a57bb2f4cd383290e9f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 3 Dec 2021 00:29:03 +0100 Subject: Fix bug when tag is aligned with inp block --- tests/correlator/correlator.grc | 12 ++++++------ tests/correlator/correlator.py | 2 +- tests/correlator/epy_block_0.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/correlator/correlator.grc b/tests/correlator/correlator.grc index 57c1762..5a73092 100644 --- a/tests/correlator/correlator.grc +++ b/tests/correlator/correlator.grc @@ -408,7 +408,7 @@ blocks: block_tags: 'False' comment: '' epsilon: '1.0' - freq_offset: '0.0001' + freq_offset: '0.0002' maxoutbuf: '0' minoutbuf: '0' noise_voltage: '0.2' @@ -541,7 +541,7 @@ blocks: \ rad and freq={freq*1e3: .4f} milli rad / sample\")\n\n # compute block\ \ values\n return sphase * np.ones(nsamples) + freq * np.arange(0, nsamples)\n\ \n def work(self, input_items, output_items):\n # FIXME: replace class\ - \ counter with local variable\n # self.counter = self.nitems_written(0)\n\ + \ counter with local variable\n self.counter = self.nitems_written(0)\n\ \n # nicer aliases\n inp = input_items[0]\n out = output_items[0]\n\ \n # read phase tags\n is_phase = lambda tag: pmt.to_python(tag.key)\ \ == \"phase_est\"\n tags = list(filter(is_phase, self.get_tags_in_window(0,\ @@ -555,10 +555,10 @@ blocks: \ the remainder from the previous call\n nfront = tags[0].offset - self.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 else np.zeros(nfront)\n\n # compute values at\ - \ the end\n nback = len(inp) - (tags[-1].offset - self.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\n # compute\ + \ if self.last and nfront else np.zeros(nfront)\n\n # compute\ + \ values at the end\n nback = len(inp) - (tags[-1].offset - self.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\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 self.counter += len(inp)\n\ diff --git a/tests/correlator/correlator.py b/tests/correlator/correlator.py index e080dbc..536ac00 100755 --- a/tests/correlator/correlator.py +++ b/tests/correlator/correlator.py @@ -343,7 +343,7 @@ class correlator(gr.top_block, Qt.QWidget): self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(15, 1, .002, 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.2, - frequency_offset=0.0001, + frequency_offset=0.0002, epsilon=1.0, taps=[-1.4 + .4j], noise_seed=243, diff --git a/tests/correlator/epy_block_0.py b/tests/correlator/epy_block_0.py index 9cb25bb..abf4486 100644 --- a/tests/correlator/epy_block_0.py +++ b/tests/correlator/epy_block_0.py @@ -41,7 +41,7 @@ class blk(gr.sync_block): def work(self, input_items, output_items): # FIXME: replace class counter with local variable - # self.counter = self.nitems_written(0) + self.counter = self.nitems_written(0) # nicer aliases inp = input_items[0] @@ -65,7 +65,7 @@ class blk(gr.sync_block): nfront = tags[0].offset - self.counter print(f"Processing {nfront} samples at the front of the buffer") start = self.block_phase(self.last, tags[0])[-nfront:] \ - if self.last else np.zeros(nfront) + if self.last and nfront else np.zeros(nfront) # compute values at the end nback = len(inp) - (tags[-1].offset - self.counter) -- cgit v1.2.1