Search code examples
pythongnuradiognuradio-companion

How to set filter stopband attenuation for a block in gnuradio companion?


I would like to set the stopband attenuation value for a bandpass filter in GNU Radio Companion. The standard Band Pass Filter block does not allow to set this parameter, but uses a default.

Does anybody know how this could be done?

I tried the following:

  • searched for various filter blocks and filter tap calculator blocks in GNU Radio Companion: could not find any that allows to set this parameter, even though the underlying filter coefficient calculator functions have such input.
  • created an Embedded Python Block and tried to use it to wrap the filter coefficient calculator (gnuradio.filter.optfir.complex_band_pass) that allows setting this parameter and the filter (gnuradio.filter.fft_filter_ccc) that uses the coefficients to do the filtering. Somehow the filter's work method cannot be called properly from the wrapper block's work method.

Solution

  • you don't need to write an embedded block to use the Filter design tools GNU Radio brings – you can just use Python as the "taps" parameter of an existing FIR filter block (instead of just typing in your filter tap vector, e.g. [1,2,3,4]), i.e., add an "Import" block, where you from gnuradio.filter import optfir, and use optfir.whatever(...) as "Taps" parameter.

    Other than that, GNU Radio's forte is not designing specialized filters, honestly :) I do recomment the excellent pyFDA; I'd install it locally using

    python3 -m venv filter-design
    source ./filter-design/bin/activate
    pip3 install pyfda
    pyfdax
    

    and use it to design your favorite filter, if you don't need to re-design it programmatically on the fly.