discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug & SNR routine


From: George Katsimaglis
Subject: bug & SNR routine
Date: Fri, 4 Nov 2022 09:16:21 +0000 (UTC)

Hello,

1) In Log Power FFT documentation 'Create a log10(abs(fft)) stream chain, with real or complex input.' it seems that is missing the ^2.

2) I write a generic SNR routine as a Python block. It seems OK.


import numpy as np
from gnuradio import gr

class my_snr(gr.decim_block): # decimation = fft_size
    """SNR calculation by George SV1BDS"""

    def __init__(self, fft_size = 1024 ):  # only default arguments here
        """arguments to this function show up as parameters in GRC"""
        gr.decim_block.__init__(
            self,
            name='SNR',   # will show up in GRC
            in_sig=[np.complex64],
            out_sig=[np.float32],
            decim = fft_size
        )
        self.set_relative_rate(1.0/fft_size)
        self.fft_size = fft_size

    def work(self, input_items, output_items):
        """SNR routine"""
        a = np.asarray(input_items[0][:])
        f = np.fft.fft(a)
        x =  10*np.log10(np.real(f*np.conj(f)))
        output_items[0][:] = np.amax(x)-np.mean(x)  
        return 1
          
Is it of general interest to include it in GNURadio ?

Best regards


reply via email to

[Prev in Thread] Current Thread [Next in Thread]