discuss-gnuradio
[Top][All Lists]
Advanced

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

Getting only bursts


From: Shane Flandermeyer
Subject: Getting only bursts
Date: Fri, 1 Nov 2019 18:12:25 -0500

Hello. I am new to this community and to creating my own blocks, and I'm trying to create a block for radar matched filtering. I am tagging all of my pulses with "SOB" and "EOB" for the start and end, respectively, and I'm wondering if there's a way to output only the full burst at each call to the work() function (for instance, if the waveform is 2000 samples long, then only those 2000 samples would be passed to the next block.) I'm setting the history to the size of the waveform so I can find the EOB tag then look backwards that many samples to get all the data I need, but that doesn't work. I eventually plan to add another input to the block that does the same thing but to the ideal transmitted waveform to make the filter, and advice on implementing that is also very much appreciated. My code is below. I hope my explanation isn't too vague. Thanks!

import numpy as np
from gnuradio import gr
import pmt

class matched_filter(gr.basic_block):
    def __init__(self, waveform_size):
        gr.basic_block.__init__(self,
            name="matched_filter",
            in_sig=[np.complex64],
            out_sig=[np.complex64])
        self.waveform_size = waveform_size
        self.set_history(self.waveform_size)

    def forecast(self, noutput_items, ninput_items_required):
        #setup size of input_items[i] for work call
        for i in range(len(ninput_items_required)):
            ninput_items_required[i] = noutput_items

    def general_work(self, input_items, output_items):
        in0 = input_items[0][:len(output_items[0])]
        out = output_items[0]
        tags = self.get_tags_in_window(0,0,len(in0))
        for tag in tags:
            key = pmt.to_python(tag.key)
            offset = tag.offset
            if key == "EOBRx":
                out = in0[(offset - self.nitems_read(0)): (offset - self.nitems_read()) + self.waveform_size - 1]
        self.consume(0, len(in0))        #self.consume_each(len(input_items[0]))
        return len(out)

reply via email to

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