discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] FW: using numpy


From: Josh Blum
Subject: Re: [Discuss-gnuradio] FW: using numpy
Date: Thu, 14 Aug 2008 06:54:59 -0700
User-agent: Thunderbird 2.0.0.0 (X11/20070326)

You need to start the flow graph, let it run for a few seconds/milliseconds, then get the data.

Try making these changes:

        import time

        fg = gr.top_block()
        .....
        mult1  = gr.multiply_ff()
        fg.connect(src, (mult1, 0))
        fg.connect(cos_wav, (mult1, 1))

        gate_I = gr.vector_sink_f()
        fg.connect (mult1, gate_I)
        
        fg.start()
        time.sleep(XXX) #enough time to collect data
        fg.stop()

        I_data = numpy.array(gate_I.data())


-Josh

Narayanan, Sivaramasubramanian (R&T) wrote:
Hi,

        This is a piece of code in my project I need help and
clarification on.

        fg = gr.flow_graph()
        .....
        mult1  = gr.multiply_ff()
        fg.connect(src, (mult1, 0))
        fg.connect(cos_wav, (mult1, 1))

        gate_I = gr.vector_sink_f()
        fg.connect (mult1, gate_I)

        I_data = numpy.array(gate_I.data())

I am using numpy.array to get an array on which I need to do some
operations like sum() etc. If I am executing this code in the pycrust
interpreter line by line, I am able to get the data in I_data. But when
I write the same code in a .py file and execute, I am not getting any
data.

Even if I copy these set of lines and execute in pycrust using the
'paste plus' option, this doesn't workout.

In my code, I need to convert a gr.float vector to an numpy array and
the  array (or list) back to gr.float vector (using
gr.vector_source_f()). Please let me know why this problems happen and
the precautions to be taken while doing such data type conversions.

Thanks a lot.
Regards,
N Sivaram


_______________________________________________
Discuss-gnuradio mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio




reply via email to

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