summaryrefslogtreecommitdiff
path: root/gr-wxgui/src/python/common.py
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2009-09-02 14:18:28 -0700
committerJosh Blum <josh@joshknows.com>2009-09-02 14:18:28 -0700
commita70c291e3cd4fc3d51f2eebb6b39cdb9d46862da (patch)
tree4daa6284894acfe3ee4f0b3d6fe543d46a569760 /gr-wxgui/src/python/common.py
parenteb1d1b5cfb474b087d41337356efc0cdb7342f28 (diff)
waterfall and fft use a common autoscale function
Diffstat (limited to 'gr-wxgui/src/python/common.py')
-rw-r--r--gr-wxgui/src/python/common.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py
index d555a1f055..9c97ce1eca 100644
--- a/gr-wxgui/src/python/common.py
+++ b/gr-wxgui/src/python/common.py
@@ -137,6 +137,25 @@ def get_min_max(samples):
scale_factor = 3
mean = numpy.average(samples)
rms = numpy.max([scale_factor*((numpy.sum((samples-mean)**2)/len(samples))**.5), .1])
- min = mean - rms
- max = mean + rms
- return min, max
+ min_val = mean - rms
+ max_val = mean + rms
+ return min_val, max_val
+
+def get_min_max_fft(fft_samps):
+ """
+ Get the minimum and maximum bounds for an array of fft samples.
+ @param samples the array of real values
+ @return a tuple of min, max
+ """
+ #get the peak level (max of the samples)
+ peak_level = numpy.max(fft_samps)
+ #separate noise samples
+ noise_samps = numpy.sort(fft_samps)[:len(fft_samps)/2]
+ #get the noise floor
+ noise_floor = numpy.average(noise_samps)
+ #get the noise deviation
+ noise_dev = numpy.std(noise_samps)
+ #determine the maximum and minimum levels
+ max_level = peak_level
+ min_level = noise_floor - abs(2*noise_dev)
+ return min_level, max_level