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.