I am in deep deep trouble. And it would be really great if somebody come
up
with any sort of help.

I am trying to collect the raw data using USRP2. I used the
gr_file_sink(itemsize, “filename”) for this. The “filename” is a binary
file
and so it cant be seen/open. I googled in the internet to find a way of
converting the binary file to something else. I found that there is one
thing named read_float_binary.m and read_complex_binary.m to convert the
data into a matlab file. This function is written in C++. I realized
that I
have to use this function but dont know how to do it. Should I use this
function directly to the python program or in the gr_file_sink.cc
program.

It would be really helpful if somebody writes the exact command for
this.

This is really urgent and I will appreciate it very much if somebody
comes
forward.

data into a matlab file. This function is written in C++. I realized that I
have to use this function but dont know how to do it. Should I use this
function directly to the python program or in the gr_file_sink.cc program.

It would be really helpful if somebody writes the exact command for this.

This is really urgent and I will appreciate it very much if somebody comes
forward.

Thank you
Those files (read_float_binary.m and read_complex_binary.m) are MATLAB
macros, intended to
be used directly by MatLab. If you don’t know how to use MatLab,
this is likely the wrong list
to get high-quality help in that direction. Just sayin’

–
Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium http://www.sbrac.org

Those files (read_float_binary.m and read_complex_binary.m) are MATLAB
macros, intended to be used directly by MatLab.

Did you mean that, the binary file which will be created by the
gr_file_sink, is needed Matlab to open?
Ok, then I will take the file to another PC where Matlab is installed
and
will try to open it.
However, I was looking for some way to directly convert the file into
.txt
or any other readable format using the python program.

However, I was looking for some way to directly convert the file into .txt
or any other readable format using the python program.
Ah, I got the impression you were looking for a quick way to read the
files into MatLab.

They’re native-binary floating-point data, either “float” or “complex
float”.

In Python there’s a plethora of ways of handling that, but numpy would
be the best bet, and I see that Josh
has already recommended numpy.fromfile.

For significant storage-size and performance reasons, the “file sink”
blocks in Gnu Radio store their data in the native
floating-point format. Although for low-speed data, one might
consider Josh’ new python-blocks stuff, which could
do conversions on-the-fly into a number of different formats,
including printable ones.

–
Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium http://www.sbrac.org

Thank you. In fact I am a very newcomer to use gnuradio.
I tried to follow your advice.
I wrote the code in python like,
numpy.fromfile(observed_data, dtype=float, count=-1, sep=’’)

Here, observed_data is the file which is created using the gr_file_sink
command.
However, it gives an error called “NameError: global name ‘numpy’ is not
defined”.

I want numpy to convert the binary file to a readable one.

Any idea?

numpy.fromfile returns an array of “floats” within Python. It doesn’t
convert your input file, merely
make it convenient to manipulate the contents as a Python array of
floats.

Once its in that format, you can use Python to format it for you:

The output file does not contain anything. I have really no idea why these
things are happening.
I thought that using numpy.formfile, I will be able to read the converted
binary file…however…its not happening.

Am a little bit sad…

Is your input file non-zero length?

and since you’re using complex64, assuming you’ve read your file into
‘a’:

f = open(“outputfile”, “w”)
for n in range(0,len(a)):
x = str(a[n].real) + " " + str(a[n].imag)+ “\n”
f.write (x)

f.close()

Will produce a readable-text file for output.

–
Principal Investigator
Shirleys Bay Radio Astronomy Consortium http://www.sbrac.org

file = open ("outputfile", "w")
for n in range(0, len(thingy)):
x = str(thingy[n].real) + " " + str(thingy[n].imag)+ "\n"
file.write(x)
file.close()
self.connect(self.u, s2v, c2mag, collect_raw_data)

What do you think what should be the output of the above alogrithm.
I am getting two output files for this algorithm.
One is “observed_data” which contains some unreadable characters. I
think
this is a binary file. I have to convert this binary file to understand
the
raw data.
The other one is “output” which contains nothing. I guess this file
should
contain the converted data of “observed_data” file.

a = numpy.fromfile(“observed_data”, dtype=numpy.complex64, count=-1,
sep=’’)
file = open (“outputfile”, “w”)
for n in range(0,len(a)):
outstr = ("%f" % a[n]) + “\n”
file.write (outstr)

file.close()

The output file does not contain anything. I have really no idea why
these
things are happening.
I thought that using numpy.formfile, I will be able to read the
converted
binary file…however…its not happening.

Am a little bit sad…

Josh B.-2 wrote:

Hello,
and so it cant be seen/open. I googled in the internet to find a way
function directly to the python program or in the gr_file_sink.cc
Those files (read_float_binary.m and read_complex_binary.m) are http://www.sbrac.org

The crucial item we were all missing was that you were trying to do this inside a Gnu Radio flowgraph.

Let the flow-graph run, then use an independant Python program after
the fact to convert your
data file.

From your code, it’s clear that you’re confused about how all this
works, and probably software-design
and programming in general. I suspect that you’re a student, and that
you have an overdue assignment
and you don’t even know where to start. From the code-segment you
provided, I’m guessing that your
programming and software design background is extremely limited.
While people on this list are
generally pretty generous with their time and knowledge, the
assumption is that our good will
won’t be abused. Using the people on this list as a means to complete
your academic assignments for
you is definitely an abuse of that good will.

–
Principal Investigator
Shirleys Bay Radio Astronomy Consortium http://www.sbrac.org