discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] averaged power spectrum calculation


From: Juha Vierinen
Subject: [Discuss-gnuradio] averaged power spectrum calculation
Date: Thu, 22 Nov 2007 15:29:28 +0000

Hi,

I am attempting to calculate a simple averaged power spectrum and save
it to a file, but for some reason the averaging part does not work
(averaging uses single_pole_iir_filter, which is copied from some
example). I'm sure that my code has some simple bug. Here is the code:

def boxcar(wsize):
    window = [1.0 for i in range(wsize)]
    return window

fft_size = 2048
sample_rate = 2e6
fft_rate = 1.0

fg = gr.flow_graph()
src = gr.noise_source_c(gr.GR_UNIFORM,5000.0)
N = int(math.floor(sample_rate/fft_size/fft_rate))
head = gr.head(gr.sizeof_gr_complex, int(N*fft_size))
s2p = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size)
fft = gr.fft_vcc(fft_size, True, boxcar(fft_size))
c2mag = gr.complex_to_mag(fft_size)
avg = gr.single_pole_iir_filter_ff(1.0, fft_size)
tail = gr.skiphead(gr.sizeof_float*fft_size, N-1)
sink = gr.file_sink (fft_size*gr.sizeof_float, "test.dat")
fg.connect(src, head, s2p, fft, c2mag, avg, tail, sink)
fg.run()

The avg block should simply sum up all the vectors that come out of
Mod(fft(signal)), but this doesn't seem to happen. It almost seems as
if nothing is done in the avg block. What am I doing wrong?

juha




reply via email to

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