discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] GL sinks freeze


From: Josh Blum
Subject: Re: [Discuss-gnuradio] GL sinks freeze
Date: Sat, 26 Dec 2009 22:52:04 -0500
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

I fixed it on my computer, it seems numpy.choose changed implementation since the upgrade to 9.10 (or maybe i was misusing it). I replaced the numpy.choose call with a python for loop. Its probably slower than a numpy table look up. But lets just see if this also fixes the problem for you.

It seems the gnuradio.org server is on vacation again. Attached is the diff, try it out.

-Josh
diff --git a/gr-wxgui/src/python/plotter/waterfall_plotter.py 
b/gr-wxgui/src/python/plotter/waterfall_plotter.py
index d32b0ca..f83e27e 100644
--- a/gr-wxgui/src/python/plotter/waterfall_plotter.py
+++ b/gr-wxgui/src/python/plotter/waterfall_plotter.py
@@ -26,6 +26,7 @@ import common
 import numpy
 import gltext
 import math
+import struct
 
 LEGEND_LEFT_PAD = 7
 LEGEND_NUM_BLOCKS = 256
@@ -37,6 +38,9 @@ MIN_PADDING = 0, 60, 0, 0 #top, right, bottom, left
 
 ceil_log2 = lambda x: 2**int(math.ceil(math.log(x)/math.log(2)))
 
+pack_color   = lambda x: struct.pack('BBBB', *x)
+unpack_color = lambda s: struct.unpack('BBBB', s)
+
 def _get_rbga(red_pts, green_pts, blue_pts, alpha_pts=[(0, 0), (1, 0)]):
        """
        Get an array of 256 rgba values where each index maps to a color.
@@ -53,10 +57,10 @@ def _get_rbga(red_pts, green_pts, blue_pts, alpha_pts=[(0, 
0), (1, 0)]):
                        #linear interpolation
                        if x <= x2: return float(y1 - y2)/(x1 - x2)*(x - x1) + 
y1
                raise Exception
-       return [numpy.array(map(
+       return [pack_color(map(
                        lambda pw: int(255*_fcn(i/255.0, pw)),
                        (red_pts, green_pts, blue_pts, alpha_pts),
-               ), numpy.uint8).tostring() for i in range(0, 256)
+               )) for i in range(0, 256)
        ]
 
 COLORS = {
@@ -179,8 +183,8 @@ class waterfall_plotter(grid_plotter_base):
                block_height = float(legend_height)/LEGEND_NUM_BLOCKS
                x = self.width - self.padding_right + LEGEND_LEFT_PAD
                for i in range(LEGEND_NUM_BLOCKS):
-                       color = 
COLORS[self._color_mode][int(255*i/float(LEGEND_NUM_BLOCKS-1))]
-                       GL.glColor4f(*map(lambda c: ord(c)/255.0, color))
+                       color = 
unpack_color(COLORS[self._color_mode][int(255*i/float(LEGEND_NUM_BLOCKS-1))])
+                       GL.glColor4f(*numpy.array(color)/255.0)
                        y = self.height - (i+1)*block_height - 
self.padding_bottom
                        self._draw_rect(x, y, LEGEND_WIDTH, block_height)
                #draw rectangle around color scale border
@@ -261,7 +265,7 @@ class waterfall_plotter(grid_plotter_base):
                samples = numpy.clip(samples, 0, 255) #clip
                samples = numpy.array(samples, numpy.uint8)
                #convert the samples to RGBA data
-               data = numpy.choose(samples, 
COLORS[self._color_mode]).tostring()
+               data = ''.join([COLORS[self._color_mode][sample] for sample in 
samples])
                self._buffer.append(data)
                self._waterfall_cache.changed(True)
                self.unlock()

reply via email to

[Prev in Thread] Current Thread [Next in Thread]