3

I am working on GNU-radio with USRP E310. I have recorded 500MHz signal in File format with extension .fc32. Below are some details I know about the generated file.

It is a complex binary file. A floating point data stream is saved as 32 bits in the file, one after the other. A complex signal has 32 bits for the real part and 32 bits for the imaginary part. Reading back a complex number means reading in 32 bits, saving that to the real part of a complex data structure, and then reading in the next 32 bits as the imaginary part of the data structure.

A one-line Python command to read the entire file into a numpy array is:

f = scipy.fromfile(open("loopback1.fc32"), dtype=scipy.complex64)

I have tried to write down the basic code but I wish to improve it such that I can plot the recorded signal (with amplitude, time) and use it for further analysis. It would be really helpful if someone can share the edited code.

import numpy, scipy
import os
import matplotlib.pyplot as plt

path = r'D:\FilePath\2016425'
os.chdir(path)

samples = scipy.fromfile(open("loopback1.fc32"), dtype=scipy.complex64)

digital_power_of_samples = numpy.abs(samples)**2
mean_power = digital_power_of_samples.mean()
max_power = max(digital_power_of_samples)

print (mean_power, max_power)
print (numpy.var(samples.real), numpy.var(samples.imag))

real = numpy.real(samples)
imag = numpy.imag(samples)
plt.ylim([-1,1])
plt.xlim([-1,1])
plt.plot(real, imag)
plt.show()

For the above program I receive the output plot between real-imag and,

0.00623067 0.0075818
0.00312979 0.00310087

I am quite new to Python programming. Any suggestions are welcome. Thank you.

ali_m
  • 71,714
  • 23
  • 223
  • 298
Bhushan
  • 39
  • 1
  • 3
  • Hi Bhushan, nice to meet you here, too! So, StackOverflow is typically very precise when it comes to questions. You should really explain what you're seeing, what you want to see, and how that's wrong! – Marcus Müller Apr 27 '16 at 15:09
  • @MarcusMüller Nice to see you too !! Thanks a lot for your suggestion. I have already solved the issue. I will consider your suggestion next time. – Bhushan Apr 28 '16 at 08:41
  • 4
    If you've solved the issue, it'd be polite to add an answer yourself here! Answering your own questions is highly encouraged on StackOverflow. Letting questions you don't care about anymore stand around is not. – Marcus Müller Apr 28 '16 at 11:45

0 Answers0