[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9169 - in gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9169 - in gnuradio/branches/features/experimental-gui: . plotter |
Date: |
Mon, 4 Aug 2008 12:55:28 -0600 (MDT) |
Author: jblum
Date: 2008-08-04 12:55:28 -0600 (Mon, 04 Aug 2008)
New Revision: 9169
Modified:
gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
gnuradio/branches/features/experimental-gui/waterfall_window.py
Log:
waterfall plotter numpy speedup
Modified:
gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
===================================================================
--- gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
2008-08-04 14:53:32 UTC (rev 9168)
+++ gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
2008-08-04 18:55:28 UTC (rev 9169)
@@ -26,15 +26,14 @@
import gltext
LEGEND_LEFT_PAD = 7
-LEGEND_RIGHT_PAD = 3
LEGEND_NUM_BLOCKS = 256
-LEGEND_NUM_LABELS = 8
+LEGEND_NUM_LABELS = 9
LEGEND_WIDTH = 8
LEGEND_FONT_SIZE = 8
LEGEND_BORDER_COLOR_SPEC = (0, 0, 0) #black
PADDING = 35, 60, 40, 60 #top, right, bottom, left
-def _get_rbga(red_pts, green_pts, blue_pts, alpha_pts):
+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.
The scaling for red, green, blue, alpha are specified in piece-wise
functions.
@@ -42,6 +41,7 @@
The x and y values of the coordinates range from 0 to 1.
The coordinates must be specified so that x increases with the index
value.
Resulting values are calculated along the line formed between 2
coordinates.
+ @param *_pts an array of x,y coordinates for each color element
@return array of rbga values (4 bytes) each
"""
def _fcn(x, pw):
@@ -53,7 +53,7 @@
return [numpy.array(map(
lambda pw: int(255*_fcn(i/255.0, pw)),
(red_pts, green_pts, blue_pts, alpha_pts),
- ), numpy.uint8) for i in range(0, 256)
+ ), numpy.uint8).tostring() for i in range(0, 256)
]
COLORS = {
@@ -61,25 +61,21 @@
red_pts = [(0, 0), (.5, 0), (1, 1)],
green_pts = [(0, 0), (.5, 1), (1, 0)],
blue_pts = [(0, 1), (.5, 0), (1, 0)],
- alpha_pts = [(0, 0), (1, 0)],
),
'rgb2': _get_rbga(
#http://xtide.ldeo.columbia.edu/~krahmann/coledit/screen.jpg
red_pts = [(0, 0), (3.0/8, 0), (5.0/8, 1), (7.0/8, 1), (1, .5)],
green_pts = [(0, 0), (1.0/8, 0), (3.0/8, 1), (5.0/8, 1),
(7.0/8, 0), (1, 0)],
blue_pts = [(0, .5), (1.0/8, 1), (3.0/8, 1), (5.0/8, 0), (1,
0)],
- alpha_pts = [(0, 0), (1, 0)],
),
'rgb3': _get_rbga(
red_pts = [(0, 0), (1.0/3.0, 0), (2.0/3.0, 0), (1, 1)],
green_pts = [(0, 0), (1.0/3.0, 0), (2.0/3.0, 1), (1, 0)],
blue_pts = [(0, 0), (1.0/3.0, 1), (2.0/3.0, 0), (1, 0)],
- alpha_pts = [(0, 0), (1, 0)],
),
'gray': _get_rbga(
red_pts = [(0, 0), (1, 1)],
green_pts = [(0, 0), (1, 1)],
blue_pts = [(0, 0), (1, 1)],
- alpha_pts = [(0, 0), (1, 0)],
),
}
@@ -149,25 +145,26 @@
"""
if not self._color_mode: return
legend_height = self.height-self.padding_top-self.padding_bottom
- block_height = float(legend_height)/LEGEND_NUM_BLOCKS
- label_spacing = float(legend_height)/(LEGEND_NUM_LABELS-1)
- x = self.width-self.padding_right + LEGEND_LEFT_PAD
#draw each legend block
+ 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))]
- glColor4f(*map(lambda c: c/255.0, color))
+ glColor4f(*map(lambda c: ord(c)/255.0, color))
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
+ glColor3f(*LEGEND_BORDER_COLOR_SPEC)
+ self._draw_rect(x, self.padding_top, LEGEND_WIDTH,
legend_height, fill=False)
#draw each legend label
+ label_spacing = float(legend_height)/(LEGEND_NUM_LABELS-1)
+ x = self.width - (self.padding_right - LEGEND_LEFT_PAD -
LEGEND_WIDTH)/2
for i in range(LEGEND_NUM_LABELS):
proportion = i/float(LEGEND_NUM_LABELS-1)
dB = proportion*(self._maximum - self._minimum) +
self._minimum
- y = self.height - i*label_spacing - self.padding_bottom
- label_spacing/4
- txt = gltext.Text('%ddB'%int(dB),
font_size=LEGEND_FONT_SIZE)
- txt.draw_text(wx.Point(x+LEGEND_WIDTH+LEGEND_RIGHT_PAD,
y))
- #draw rectangle around color scale border
- glColor3f(*LEGEND_BORDER_COLOR_SPEC)
- self._draw_rect(x, self.padding_top, LEGEND_WIDTH,
legend_height, fill=False)
+ y = self.height - i*label_spacing - self.padding_bottom
+ txt = gltext.Text('%ddB'%int(dB),
font_size=LEGEND_FONT_SIZE, centered=True)
+ txt.draw_text(wx.Point(x, y))
def _resize_buffer(self):
"""!
@@ -220,12 +217,10 @@
self._resize_buffer()
#normalize the samples to min/max
samples = (samples - minimum)*float(255/(maximum-minimum))
- samples = numpy.minimum(samples, 255) #clip
- samples = numpy.maximum(samples, 0) #clip
+ samples = numpy.clip(samples, 0, 255) #clip
samples = numpy.array(samples, numpy.uint8)
#convert the samples to RGBA data
- color_array = COLORS[self._color_mode]
- data = numpy.array([color_array[sample] for sample in
samples]).tostring()
+ data = numpy.choose(samples,
COLORS[self._color_mode]).tostring()
self._buffer = (data +
self._buffer)[:self._num_lines*self._fft_size*4]
#selective update, dont update for sub-pixel counts
if self._counter == 0: self.update()
Modified: gnuradio/branches/features/experimental-gui/waterfall_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-04 14:53:32 UTC (rev 9168)
+++ gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-08-04 18:55:28 UTC (rev 9169)
@@ -42,7 +42,7 @@
COLOR_MODES = (
('RGB1', 'rgb1'),
('RGB2', 'rgb2'),
- ('RGB3', 'rgb3'),
+ ('RGB3', 'rgb3'),
('Gray', 'gray'),
)
DYNAMIC_RANGE_KEY = 'dynamic_range'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9169 - in gnuradio/branches/features/experimental-gui: . plotter,
jblum <=