discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] How to use the read_float_binary.m function


From: hasanimam
Subject: Re: [Discuss-gnuradio] How to use the read_float_binary.m function
Date: Thu, 27 Oct 2011 20:00:03 -0700 (PDT)

To Josh and Marcus,

Well I tried all aspects.
Here is what I did,

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 Blum-2 wrote:
> 
> 
> 
> On 10/27/2011 07:09 PM, hasanimam wrote:
>> 
>> Well, I have been able to run the program somehow. The following code is
>> what
>> I used.
>> 
>> import numpy
>> 
>> numpy.fromfile("observed_data", dtype=float, count=-1, sep='')
>> 
> 
> See my previous email about the data type. I do not think you want to
> parse the data as a float64/double. Right?
> 
>> Now, the problem is that the file I am getting does not show anything. I
>> mean the characters in the file are still unreadable.
>> 
>> I want numpy to convert the binary file to a readable one.
>> 
>> Any idea?
>> 
>> hasanimam wrote:
>>>
>>> Hello Josh,
>>>
>>> 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".
>>>
>>> Do you have any idea about it?
>>>
>>> Thanks
>>>
>>> On Fri, Oct 28, 2011 at 10:16 AM, Josh Blum <address@hidden> wrote:
>>>
>>>>
>>>>
>>>> On 10/27/2011 06:14 PM, hasanimam wrote:
>>>>>
>>>>> Hello Marcus,
>>>>>
>>>>> I really appreciate your help.
>>>>>> 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.
>>>>
>>>> see numpy.fromfile, use the type numpy.complex64
>>>>
>>>> The data stored to file is just an array of std::complex<float> or
>>>> std::complex<int16>
>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Marcus D. Leech wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> 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 Leech
>>>>>> Principal Investigator
>>>>>> Shirleys Bay Radio Astronomy Consortium
>>>>>> http://www.sbrac.org
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Discuss-gnuradio mailing list
>>>>>> address@hidden
>>>>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Discuss-gnuradio mailing list
>>>> address@hidden
>>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>>
>>>
>>>
>>>
>>> -- 
>>> Hasan Rajib Imam
>>> University of Electro-Communication, Japan
>>> 1st year Masters Student
>>> Email: address@hidden
>>> Contact No: (+81)80-5004-5931
>>>
>>> _______________________________________________
>>> Discuss-gnuradio mailing list
>>> address@hidden
>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>
>>>
>> 
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-use-the-read_float_binary.m-function-tp32729533p32735733.html
Sent from the GnuRadio mailing list archive at Nabble.com.




reply via email to

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