diff options
author | Nao Pross <np@0hm.ch> | 2021-12-03 17:54:07 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-12-03 18:04:29 +0100 |
commit | 0cb8ac7bd0e88d6d26c1fda3abcf0977c2e8150b (patch) | |
tree | e1854df3bb4cf7ba38fe3f9f691c2b895eb291d3 /tests/correlator/epy_block_0.py | |
parent | Improve frequency LPF (diff) | |
download | Fading-0cb8ac7bd0e88d6d26c1fda3abcf0977c2e8150b.tar.gz Fading-0cb8ac7bd0e88d6d26c1fda3abcf0977c2e8150b.zip |
Fix bug that makes jump estimated frequency to unreasonably high values
Diffstat (limited to '')
-rw-r--r-- | tests/correlator/epy_block_0.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/correlator/epy_block_0.py b/tests/correlator/epy_block_0.py index e7599c9..a581a3a 100644 --- a/tests/correlator/epy_block_0.py +++ b/tests/correlator/epy_block_0.py @@ -25,7 +25,7 @@ class blk(gr.sync_block): # filter to avoid werid jumps in the correction. to do that, there are # two buffers with an index self.index = 0 - self.length = 7 + self.length = 5 self.freq = np.zeros(self.length) def lpf_freq(self, new_sample): @@ -46,12 +46,20 @@ class blk(gr.sync_block): # compute frequency offset between start and end # and run it through a low pass filter (mean) - freq = (sphase - ephase) / nsamples - freq = self.lpf_freq(freq) + phasediff = ephase - sphase + + if phasediff > np.pi: + phasediff -= 2*np.pi + + elif phasediff < -np.pi: + phasediff += 2*np.pi + + freq = phasediff / nsamples + # freq = self.lpf_freq(freq) # debugging print(f"Correction for block of {nsamples:2d} samples is " \ - f"phase={sphase: .4f} rad and freq={freq*1e3: .4f} milli rad / sample") + f"sphase={sphase: .4f} rad and freq={freq*1e3: .4f} milli rad / sample") # compute block values return sphase * np.ones(nsamples) + freq * np.arange(0, nsamples) |