Sunday, July 28, 2019

Re: [Discuss-gnuradio] Units of data saved by filesink

import pylab as plt
import os
import numpy as np

def main():

srate = 4000000.0
fftsize = 8192
infile = 'counts-check.dat'

size = os.path.getsize(infile) / 4
shape = (fftsize, size/fftsize)
x = np.memmap(infile, dtype='float32', mode = 'r', shape=shape)

sum_counts = 0
i = 0

for count1 in range(size/fftsize):
for count2 in range(fftsize):
sum_counts += (x[count2, count1])#/100.0
i += 1

avg = float(sum_counts) / float(i)
#conversion = 0.0196 / avg
print avg #conversion

'''freqPlot = np.mean(x, axis=0)
#print freqPlot
fmin = (169010000-(srate/2))/1000000
fmax = (169010000+(srate/2))/1000000
fidx = np.linspace(fmin, fmax, freqPlot.size)

plt.plot(freqPlot) #fidx, freqPlot
plt.show()'''

if __name__ == "__main__":
main()

Hi Marcus L. and Marcus M., 

Thanks for the tips, really appreciate the advice / help from both of you. Marcus L., thanks so much for the practical calibration advice, that will come in handy. Marcus M., thanks also for your tips. Not sure what I was thinking with the "watts squared" thing -- duh! Also, to respond to a point in your previous email, I realize that WX GUI is deprecated, but as a result of the fact that my project requires I work on an old RedHat computer on National Radio Astronomy Observatory servers, according to the system administrator I am limited to working from GNU Radio version 3.7.11 -- which doesn't have all the QT GUI functionality I need. Thus the outdated WX GUI choice, and my inability to use the ZeroMQ blocks.

So, I've got another question for you all. I've reattached my original flowgraph (ettus-filesink.grc, modified slightly). I have been stepping through each stage and recording data samples (i.e., I first attached the lower channel from the De-Interleave block straight to a filesink, saved the file and read it out using a python program, such as the one attached, then connected the FFT block, saved the data, etc.). The point of this exercise being to determine how the counts (which are, presumably, proportional to voltage) change after each processing step. After the samples are run through the FFT block, the counts values are smaller than the input by about 1/fftsize (8192 in this case), which makes sense to me, but then, after the stream is passed through the Complex to Mag^2 block, the count values go from around 10^-9 to roughly 0.01 (the values are slightly different, but the order of magnitude is what I'm asking about here). Why is this the case? When I use a system as in counts-conversion-test.grc, the output is completely different (~10^-5) than that for Complex to Mag^2, even though to my understanding they should be doing the same thing, though maybe this is not the case. I would appreciate hearing any insights you all have to share about this.

Thanks very much for your time and help -- have a good evening!

Best,
Ellie

On Thu, Jul 25, 2019 at 1:36 PM Müller, Marcus (CEL) <mueller@kit.edu> wrote:
On Thu, 2019-07-25 at 13:24 -0400, Ellie White wrote:
> Hi Marcus,
>
> Good to know. So how would you recommend I should convert these values to, say, watts?

I described exactly that in my other email.

> (I guess perhaps it would be watts squared due to the mag to mag squared block).

No. Amplitudes are proportional to voltage, squared amplitudes to
power. Physics!

>  I assume I would first have to determine what the SDR considers full scale -- do you have any suggestions on how to do that?
>

Calibration with a known power source.

No comments:

Post a Comment