summaryrefslogtreecommitdiff
path: root/gr-wxgui
diff options
context:
space:
mode:
authorMatt Ettus2009-09-04 10:29:00 -0700
committerMatt Ettus2009-09-04 10:29:00 -0700
commite103e18f8b8111cd07edc2bb0294aa58a426e371 (patch)
tree429d96819fc8b04c965eda3a0c2b93f2e94f9080 /gr-wxgui
parent5965a434d0923738d49334eb5f3d74a259e7b431 (diff)
parent20006003431d7260b04964eb684b1746ffb0a85f (diff)
downloadgnuradio-e103e18f8b8111cd07edc2bb0294aa58a426e371.tar.gz
gnuradio-e103e18f8b8111cd07edc2bb0294aa58a426e371.tar.bz2
gnuradio-e103e18f8b8111cd07edc2bb0294aa58a426e371.zip
Merge branch 'master' into new_eth
Diffstat (limited to 'gr-wxgui')
-rw-r--r--gr-wxgui/src/python/common.py25
-rw-r--r--gr-wxgui/src/python/fft_window.py14
-rw-r--r--gr-wxgui/src/python/plotter/waterfall_plotter.py2
-rw-r--r--gr-wxgui/src/python/scopesink_gl.py2
-rw-r--r--gr-wxgui/src/python/waterfall_window.py12
5 files changed, 31 insertions, 24 deletions
diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py
index d555a1f05..9c97ce1ec 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
diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py
index 0529e6a5d..237c8940c 100644
--- a/gr-wxgui/src/python/fft_window.py
+++ b/gr-wxgui/src/python/fft_window.py
@@ -254,17 +254,11 @@ class fft_window(wx.Panel, pubsub.pubsub):
Set the dynamic range and reference level.
"""
if not len(self.samples): return
- #get the peak level (max of the samples)
- peak_level = numpy.max(self.samples)
- #get the noise floor (averge the smallest samples)
- noise_floor = numpy.average(numpy.sort(self.samples)[:len(self.samples)/4])
- #padding
- noise_floor -= abs(noise_floor)*.5
- peak_level += abs(peak_level)*.1
- #set the reference level to a multiple of y divs
- self[REF_LEVEL_KEY] = self[Y_DIVS_KEY]*math.ceil(peak_level/self[Y_DIVS_KEY])
+ min_level, max_level = common.get_min_max_fft(self.samples)
#set the range to a clean number of the dynamic range
- self[Y_PER_DIV_KEY] = common.get_clean_num((peak_level - noise_floor)/self[Y_DIVS_KEY])
+ self[Y_PER_DIV_KEY] = common.get_clean_num(1+(max_level - min_level)/self[Y_DIVS_KEY])
+ #set the reference level to a multiple of y per div
+ self[REF_LEVEL_KEY] = self[Y_PER_DIV_KEY]*round(.5+max_level/self[Y_PER_DIV_KEY])
def _reset_peak_vals(self, *args): self.peak_vals = EMPTY_TRACE
diff --git a/gr-wxgui/src/python/plotter/waterfall_plotter.py b/gr-wxgui/src/python/plotter/waterfall_plotter.py
index 2e0669961..d32b0ca0a 100644
--- a/gr-wxgui/src/python/plotter/waterfall_plotter.py
+++ b/gr-wxgui/src/python/plotter/waterfall_plotter.py
@@ -209,7 +209,7 @@ class waterfall_plotter(grid_plotter_base):
self._pointer = 0
if self._num_lines and self._fft_size:
GL.glBindTexture(GL.GL_TEXTURE_2D, self._waterfall_texture)
- data = numpy.zeros(self._num_lines*self._fft_size*4, numpy.uint8).tostring()
+ data = numpy.zeros(self._num_lines*ceil_log2(self._fft_size)*4, numpy.uint8).tostring()
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, ceil_log2(self._fft_size), self._num_lines, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, data)
self._resize_texture_flag = False
diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py
index b4ae0f339..a5e3ca3ce 100644
--- a/gr-wxgui/src/python/scopesink_gl.py
+++ b/gr-wxgui/src/python/scopesink_gl.py
@@ -50,7 +50,7 @@ class ac_couple_block(gr.hier_block2):
self.connect(self, lpf, mute, (sub, 1))
#subscribe
controller.subscribe(ac_couple_key, lambda x: mute.set_mute(not x))
- controller.subscribe(sample_rate_key, lambda x: lpf.set_taps(2.0/x))
+ controller.subscribe(sample_rate_key, lambda x: lpf.set_taps(0.05))
#initialize
controller[ac_couple_key] = ac_couple
controller[sample_rate_key] = controller[sample_rate_key]
diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py
index c00992e14..28e67a830 100644
--- a/gr-wxgui/src/python/waterfall_window.py
+++ b/gr-wxgui/src/python/waterfall_window.py
@@ -237,16 +237,10 @@ class waterfall_window(wx.Panel, pubsub.pubsub):
Does not affect the current data in the waterfall.
"""
if not len(self.samples): return
- #get the peak level (max of the samples)
- peak_level = numpy.max(self.samples)
- #get the noise floor (averge the smallest samples)
- noise_floor = numpy.average(numpy.sort(self.samples)[:len(self.samples)/4])
- #padding
- noise_floor -= abs(noise_floor)*.5
- peak_level += abs(peak_level)*.1
+ min_level, max_level = common.get_min_max_fft(self.samples)
#set the range and level
- self[REF_LEVEL_KEY] = peak_level
- self[DYNAMIC_RANGE_KEY] = peak_level - noise_floor
+ self[REF_LEVEL_KEY] = max_level
+ self[DYNAMIC_RANGE_KEY] = max_level - min_level
def handle_msg(self, msg):
"""