# M.data in usrp\_spectrum\_sense.py

**URL:** <https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268>\
**Category:** GNU Radio\
**Created:** [June 10, 2015, 9:51pm UTC](https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268 "2015-06-10T21:51:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 10, 2015, 9:51pm UTC](https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268/1 "2015-06-10T21:51:17Z")

</div>

I have been running usrp\_spectrum\_sense.py for hours now and I cannot  
figure out where it is getting its power\_db from. I narrowed it down to  
m.data. My end goal is to have the program scan frequencies from a  
desired  
list that I have created and output its power. usrp\_spectrum\_sense.py  
scans  
frequencies in a range and I have been successful in reading a file of  
known frequencies in usrp\_spectrum\_sense.py. I what to be able to pass a  
list of frenquencies (floats) into the program and let it scan for the  
power. But the program computes power from m.data and now from its own  
variable ‘freq’. Can someone explain to me what these numbers (m.data)  
are?

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 10, 2015, 11:02pm UTC](https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268/2 "2015-06-10T23:02:34Z")

</div>

Hi Ashraf,

that’s no real power – it’s the absolute magnitude of the FFT in each  
bin, in dB relative to 1.  
If you need numbers in real power (ie. numbers on your screen that  
directly relate to a signal power in real physics), you will need to  
calibrate your system with an external signal of which you know the  
(physical) power of. This will only apply for a short time, for a given  
configuration of frequency, sampling rate, gain.  
I don’t know what you mean with m.data, but I think you’re on to nothing  
correct.

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 11, 2015, 2:22pm UTC](https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268/3 "2015-06-11T14:22:15Z")

</div>

m.data is what they use to calculate power\_db (i.e. power\_db = 10\*  
math.log10(m.data[i\_bin]/tb.usrp\_rate) - noise\_floor\_db) from this code  
[https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp\_spectrum\_sense.py](https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp_spectrum_sense.py)

line 303.  
How would I calibrate my system with an external signal? I don’t  
understand  
what you mean by this.

On Wed, Jun 10, 2015 at 5:01 PM, Marcus Müller  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 11, 2015, 4:06pm UTC](https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268/4 "2015-06-11T16:06:14Z")

</div>

ah! the meaning of m.data is explained a few lines before, line 284[1]:

> m.data are the mag\_squared of the fft output

As I explained, the value that gets displayed is just the squared  
magnitude of the FFT – that means that values displayed are somehow  
proportional to the powers in individual frequency spans, but they are  
/just proportional/ – which means the relationship between the dB  
displayed (dB relative to the digital value of 1) and real world power  
(relative to for example 1mW, which could then be displayed as dBm) is  
something that you will have to calibrate yourself.

Best regards,  
Marcus

[1]  
[https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp\_spectrum\_sense.py#L284](https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp_spectrum_sense.py#L284)

---

<div class="post-metadata">

**Author:** ![Ashraf\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@Ashraf\_Y](https://www.ruby-forum.com/u/Ashraf_Y)\
**Post date:** [June 12, 2015, 9:34am UTC](https://www.ruby-forum.com/t/m-data-in-usrp-spectrum-sense-py/242268/5 "2015-06-12T09:34:17Z")

</div>

Hi Ashraf,

> Oh I see. That can be done, I believe. Thank you so much for helping  
> me understand.  
> You’re welcome!  
> I do have another question about modify usrp\_spectrum\_sense.py  
> And that would be?

Greetings,  
Marcus
