在GNU无线电中实现自定义信号源
我正在尝试在GNU无线电中实现自定义信号源,该电台必须发出带有频带的白色高斯噪声,围绕频率f
,具有双面带宽bw ,如图所示,图片
为此,我应该实现带通滤波器并将其应用于高斯随机变量。滤波器的输出读取
龙头是滤波器系数的位置,并且 是过滤器输入。在我的情况下,TAPS是通过使用
band-pass滤波器的TAPS
gnu无线电块获得的,并且将输入设置为随机高斯变量。
为了获取过滤器的输出,我应该编写工作
函数看起来像
def work(self, input_items, output_items):
samp_rate = self.get_samp_rate()
f0 = self.get_f0()
BW = self.get_BW()
my_BP_filter = filter.fir_filter_fff(
1,
firdes.band_pass(
1,
samp_rate,
f0 - 0.5*BW,
f0 + 0.5*BW,
BW*1e-2,
firdes.WIN_HAMMING,
6.76
)
)
taps = my_BP_filter.taps()
ntaps = len(taps)
min_array = min(output_items[0], taps, key=len)
max_array = max(output_items[0], taps, key=len)
min_len, max_len = len(min_array), len(max_array)
noise = np.random.normal(loc=0.0, scale=1.0, size=min_len)
t = 0.0
for idx_out in range(len(output_items[0])):
for idx_taps, val_taps in enumerate(taps):
t += val_taps * noise[len(noise)-1-idx_taps]
output_items[0][idx_out] = t
return len(output_items[0])
,但代码非常慢。我如何具有与显示图片相似的输出(通过以下结构获得)?
I am trying to implement a custom signal source in GNU Radio, which must emit a band-passed white gaussian noise, centered around a frequency f
, having a two-sided bandwidth BW
, as shown in the picture
To do so, I should implement a bandpass filter and apply it to Gaussian random variables. The output of the filter reads
where the taps are the filter coefficients, and
is the filter input. The taps in my case are obtained by using the Band-pass Filter Taps
block of GNU Radio, and the input is set to random Gaussian variables.
To get the output of my filter, I should write a work
function looking like
def work(self, input_items, output_items):
samp_rate = self.get_samp_rate()
f0 = self.get_f0()
BW = self.get_BW()
my_BP_filter = filter.fir_filter_fff(
1,
firdes.band_pass(
1,
samp_rate,
f0 - 0.5*BW,
f0 + 0.5*BW,
BW*1e-2,
firdes.WIN_HAMMING,
6.76
)
)
taps = my_BP_filter.taps()
ntaps = len(taps)
min_array = min(output_items[0], taps, key=len)
max_array = max(output_items[0], taps, key=len)
min_len, max_len = len(min_array), len(max_array)
noise = np.random.normal(loc=0.0, scale=1.0, size=min_len)
t = 0.0
for idx_out in range(len(output_items[0])):
for idx_taps, val_taps in enumerate(taps):
t += val_taps * noise[len(noise)-1-idx_taps]
output_items[0][idx_out] = t
return len(output_items[0])
but the code is extremely slow. How can I have a similar output to the shown picture (obtained with the following construction) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您肯定(Capital D)不想在
Work
中反复重新恢复A(新的)过滤器。请记住,在连续的大量数据上,工作被称为数千次。
因此,那是一个根本的建筑错误:您需要一个过滤器,它在工作呼叫之间保持其状态。
另外,您绝不能编写取决于数据的“视图”的信号处理,即无尽的样本流如何恰好到达您的块。想象一下这个很长的数字流:
您的工作被列出了,例如,您的第一个
工作
将值-4000到-2000,第二个,第二个至-1990,第三个-1989至2000年,2001年至2466年,您会明白这一想法。或者,它完全不同,并且在第一个呼叫
工作
时,您会在第二-2000至-1500的第二个-1499至-500上看到-4000至-2001第四-499至0,在第五1至2466中。然后,您的
min_aray
,max_len
取决于信号的打包方式。 这很糟糕,因为它改变了您的数学。我会建议实施什么,但是整个块对我来说确实没有意义。这是不必要的 - 在噪声源上使用现有的带通滤波器也是如此 - 如果我推荐如何做到这一点,我建议您自己实施相同的东西,没有什么不同:两个块,一个产生噪声,使用现有过滤器的源代码为例,使用正确实现的带通滤波器将其构成第二个块。
You Definitely (capital D) do not want to repeatedly reinstantiate a (make a new) filter in
work
.Remember, work is called thousands of times, on consecutive chunks of data.
So, that's a fundamental architectural mistake there: you need one filter, which maintains its state between calls to work.
Also, you must never write signal processing that depends on the "view" of your data, i.e. how the endless stream of samples happens to arrive at your block. Imagine this very long stream of numbers:
Your work gets called on a chunking of that, e.g. your first
work
gets the values -4000 to -2000, your second the -1999 to -1990, the third the -1989 to 2000, the fourth the 2001 to 2466, you get the idea.Or, it goes completely different, and on the first call to
work
, you see -4000 to -2001, on the second -2000 to -1500, on the third -1499 to -500, on the fourth -499 to 0, on the fifth 1 to 2466.Then, your
min_aray
, andmax_len
depend on how the signal was packaged. That is bad, as it changes the math you do.I'd advice on what to implement, but the whole block really makes no sense to me. It is unnecessary – using an existing band-pass filter on a noise source does the same – and if I were to recommend how to do it, I'd recommend implementing the same yourself, not anything different: Two blocks, one generating the noise, a second block shaping it with a properly implemented bandpass filter, using the source code of the existing filter as example.