[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9249 - in gnuradio/branches/developers/jblum/glwxgui/
From: |
jblum |
Subject: |
[Commit-gnuradio] r9249 - in gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python: . plotter |
Date: |
Mon, 11 Aug 2008 22:40:31 -0600 (MDT) |
Author: jblum
Date: 2008-08-11 22:40:31 -0600 (Mon, 11 Aug 2008)
New Revision: 9249
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fftsink_gl.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/numbersink_gl.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
Log:
some fixes, self tests
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -69,6 +69,7 @@
self, 'Avg Alpha',
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
parent.ext_controller, parent.avg_alpha_key,
+ formatter=lambda x: ': %.4f'%x,
)
parent.ext_controller.subscribe(parent.average_key,
self.avg_alpha_slider.Enable)
control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
@@ -248,15 +249,17 @@
#update the x grid
if self.real:
self.plotter.set_x_grid(
- scalar*baseband_freq,
- scalar*baseband_freq + scalar*sample_rate/2.0,
- scalar*x_per_div,
+ baseband_freq,
+ baseband_freq + sample_rate/2.0,
+ x_per_div,
+ scalar,
)
else:
self.plotter.set_x_grid(
- scalar*baseband_freq - scalar*sample_rate/2.0,
- scalar*baseband_freq + scalar*sample_rate/2.0,
- scalar*x_per_div,
+ baseband_freq - sample_rate/2.0,
+ baseband_freq + sample_rate/2.0,
+ x_per_div,
+ scalar,
)
#update x units
self.plotter.set_x_label('Frequency', x_units)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fftsink_gl.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fftsink_gl.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fftsink_gl.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -122,3 +122,51 @@
_fft_chain = blks2.logpwrfft_c
_item_size = gr.sizeof_gr_complex
_real = False
+
+# ----------------------------------------------------------------
+# Standalone test app
+# ----------------------------------------------------------------
+
+import wx
+from gnuradio.wxgui import stdgui2
+
+class test_app_block (stdgui2.std_top_block):
+ def __init__(self, frame, panel, vbox, argv):
+ stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
+
+ fft_size = 256
+
+ # build our flow graph
+ input_rate = 20.48e3
+
+ # Generate a complex sinusoid
+ #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2e3, 1)
+ src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1)
+
+ # We add these throttle blocks so that this demo doesn't
+ # suck down all the CPU available. Normally you wouldn't use these.
+ thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)
+
+ sink1 = fft_sink_c (panel, title="Complex Data", fft_size=fft_size,
+ sample_rate=input_rate, baseband_freq=100e3,
+ ref_level=0, y_per_div=20, y_divs=10)
+ vbox.Add (sink1.win, 1, wx.EXPAND)
+
+ self.connect(src1, thr1, sink1)
+
+ #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1)
+ src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1)
+ thr2 = gr.throttle(gr.sizeof_float, input_rate)
+ sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2,
+ sample_rate=input_rate, baseband_freq=100e3,
+ ref_level=0, y_per_div=20, y_divs=10)
+ vbox.Add (sink2.win, 1, wx.EXPAND)
+
+ self.connect(src2, thr2, sink2)
+
+def main ():
+ app = stdgui2.stdapp (test_app_block, "FFT Sink Test App")
+ app.MainLoop ()
+
+if __name__ == '__main__':
+ main ()
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -66,6 +66,7 @@
self, 'Avg Alpha',
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
parent.ext_controller, parent.avg_alpha_key,
+ formatter=lambda x: ': %.4f'%x,
)
parent.ext_controller.subscribe(parent.average_key,
self.avg_alpha_slider.Enable)
control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/numbersink_gl.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/numbersink_gl.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/numbersink_gl.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -137,3 +137,46 @@
class number_sink_c(_number_sink_base):
_item_size = gr.sizeof_gr_complex
_real = False
+
+# ----------------------------------------------------------------
+# Standalone test app
+# ----------------------------------------------------------------
+
+import wx
+from gnuradio.wxgui import stdgui2
+
+class test_app_flow_graph (stdgui2.std_top_block):
+ def __init__(self, frame, panel, vbox, argv):
+ stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
+
+ # build our flow graph
+ input_rate = 20.48e3
+
+ # Generate a real and complex sinusoids
+ src1 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2.21e3, 1)
+ src2 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2.21e3, 1)
+
+ # We add these throttle blocks so that this demo doesn't
+ # suck down all the CPU available. Normally you wouldn't use these.
+ thr1 = gr.throttle(gr.sizeof_float, input_rate)
+ thr2 = gr.throttle(gr.sizeof_gr_complex, input_rate)
+
+ sink1 = number_sink_f (panel, unit='V',label="Real Data",
avg_alpha=0.001,
+ sample_rate=input_rate, minval=-1, maxval=1,
+ ref_level=0, decimal_places=3)
+ vbox.Add (sink1.win, 1, wx.EXPAND)
+ sink2 = number_sink_c (panel, unit='V',label="Complex Data",
avg_alpha=0.001,
+ sample_rate=input_rate, minval=-1, maxval=1,
+ ref_level=0, decimal_places=3)
+ vbox.Add (sink2.win, 1, wx.EXPAND)
+
+ self.connect (src1, thr1, sink1)
+ self.connect (src2, thr2, sink2)
+
+def main ():
+ app = stdgui2.stdapp (test_app_flow_graph, "Number Sink Test App")
+ app.MainLoop ()
+
+if __name__ == '__main__':
+ main ()
+
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -153,31 +153,35 @@
self.changed(True)
self.unlock()
- def set_x_grid(self, x_min, x_max, x_step):
+ def set_x_grid(self, x_min, x_max, x_step, x_scalar=1.0):
"""!
Set the x grid parameters.
@param x_min the left-most value
@param x_max the right-most value
@param x_step the grid spacing
+ @param x_scalar the scalar factor
"""
self.lock()
self.x_min = float(x_min)
self.x_max = float(x_max)
self.x_step = float(x_step)
+ self.x_scalar = float(x_scalar)
self.changed(True)
self.unlock()
- def set_y_grid(self, y_min, y_max, y_step):
+ def set_y_grid(self, y_min, y_max, y_step, y_scalar=1.0):
"""!
Set the y grid parameters.
@param y_min the bottom-most value
@param y_max the top-most value
@param y_step the grid spacing
+ @param y_scalar the scalar factor
"""
self.lock()
self.y_min = float(y_min)
self.y_max = float(y_max)
self.y_step = float(y_step)
+ self.y_scalar = float(y_scalar)
self.changed(True)
self.unlock()
@@ -198,9 +202,9 @@
##################################################
# Draw Grid X
##################################################
- for tick in self._get_ticks(self.x_min, self.x_max,
self.x_step):
+ for tick in self._get_ticks(self.x_min, self.x_max,
self.x_step, self.x_scalar):
scaled_tick =
(self.width-self.padding_left-self.padding_right)*\
- (tick-self.x_min)/(self.x_max-self.x_min) +
self.padding_left
+
(tick/self.x_scalar-self.x_min)/(self.x_max-self.x_min) + self.padding_left
glColor3f(*GRID_LINE_COLOR_SPEC)
self._draw_line(
(scaled_tick, self.padding_top, 0),
@@ -210,9 +214,9 @@
##################################################
# Draw Grid Y
##################################################
- for tick in self._get_ticks(self.y_min, self.y_max,
self.y_step):
+ for tick in self._get_ticks(self.y_min, self.y_max,
self.y_step, self.y_scalar):
scaled_tick =
(self.height-self.padding_top-self.padding_bottom)*\
- (1 - (tick-self.y_min)/(self.y_max-self.y_min))
+ self.padding_top
+ (1 -
(tick/self.y_scalar-self.y_min)/(self.y_max-self.y_min)) + self.padding_top
glColor3f(*GRID_LINE_COLOR_SPEC)
self._draw_line(
(self.padding_left, scaled_tick, 0),
@@ -255,21 +259,24 @@
#format
if tick == 0: exp = 0
else: exp = int(math.floor(math.log10(abs(tick))))
- old_exp = exp
- exp = exp - exp%3
- base = tick/10**exp
- if abs(old_exp) >= 3: tick_str = '%ge%d'%(base, exp)
+ exp_mod = exp%3
+ exp_dif = exp - exp_mod
+ base = tick/10**exp_dif
+ if abs(exp) >= 3:
+ formatter = '%%.%df'%(2-exp_mod)
+ tick_str = '%se%d'%(formatter%base, exp_dif)
else: tick_str = '%g'%tick
#draw
txt = gltext.Text(tick_str, font_size=TICK_TEXT_FONT_SIZE,
centered=True)
txt.draw_text(wx.Point(*coor))
- def _get_ticks(self, min, max, step):
+ def _get_ticks(self, min, max, step, scalar):
"""!
Determine the positions for the ticks.
@param min the lower bound
@param max the upper bound
@param step the grid spacing
+ @param scalar the grid scaling
@return a list of tick positions between min and max
"""
#cast to float
@@ -283,7 +290,7 @@
#determine the start and stop value
start = int(math.ceil(min/step))
stop = int(math.floor(max/step))
- return [i*step for i in range(start, stop+1)]
+ return [i*step*scalar for i in range(start, stop+1)]
def _draw_line(self, coor1, coor2):
"""!
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -36,7 +36,7 @@
SLIDER_STEPS = 100
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
DEFAULT_FRAME_RATE = 30
-DEFAULT_WIN_SIZE = (600, 400)
+DEFAULT_WIN_SIZE = (600, 300)
DIV_LEVELS = (1, 2, 5, 10, 20)
MIN_DYNAMIC_RANGE, MAX_DYNAMIC_RANGE = 10, 200
COLOR_MODES = (
@@ -77,6 +77,7 @@
self, 'Avg Alpha',
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
parent.ext_controller, parent.avg_alpha_key,
+ formatter=lambda x: ': %.4f'%x,
)
parent.ext_controller.subscribe(parent.average_key,
self.avg_alpha_slider.Enable)
control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
@@ -273,15 +274,17 @@
#update the x grid
if self.real:
self.plotter.set_x_grid(
- scalar*baseband_freq,
- scalar*baseband_freq + scalar*sample_rate/2.0,
- scalar*x_per_div,
+ baseband_freq,
+ baseband_freq + sample_rate/2.0,
+ x_per_div,
+ scalar,
)
else:
self.plotter.set_x_grid(
- scalar*baseband_freq - scalar*sample_rate/2.0,
- scalar*baseband_freq + scalar*sample_rate/2.0,
- scalar*x_per_div,
+ baseband_freq - sample_rate/2.0,
+ baseband_freq + sample_rate/2.0,
+ x_per_div,
+ scalar,
)
#update x units
self.plotter.set_x_label('Frequency', x_units)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
2008-08-12 00:49:13 UTC (rev 9248)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfallsink_gl.py
2008-08-12 04:40:31 UTC (rev 9249)
@@ -124,3 +124,49 @@
_fft_chain = blks2.logpwrfft_c
_item_size = gr.sizeof_gr_complex
_real = False
+
+# ----------------------------------------------------------------
+# Standalone test app
+# ----------------------------------------------------------------
+
+import wx
+from gnuradio.wxgui import stdgui2
+
+class test_top_block (stdgui2.std_top_block):
+ def __init__(self, frame, panel, vbox, argv):
+ stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
+
+ fft_size = 512
+
+ # build our flow graph
+ input_rate = 20.000e3
+
+ # Generate a complex sinusoid
+ self.src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
+ #src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000)
+
+ # We add these throttle blocks so that this demo doesn't
+ # suck down all the CPU available. Normally you wouldn't use these.
+ self.thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)
+
+ sink1 = waterfall_sink_c (panel, title="Complex Data",
fft_size=fft_size,
+ sample_rate=input_rate, baseband_freq=100e3)
+ self.connect(self.src1, self.thr1, sink1)
+ vbox.Add (sink1.win, 1, wx.EXPAND)
+
+ # generate a real sinusoid
+ self.src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
+ self.thr2 = gr.throttle(gr.sizeof_float, input_rate)
+ sink2 = waterfall_sink_f (panel, title="Real Data", fft_size=fft_size,
+ sample_rate=input_rate, baseband_freq=100e3)
+ self.connect(self.src2, self.thr2, sink2)
+ vbox.Add (sink2.win, 1, wx.EXPAND)
+
+
+def main ():
+ app = stdgui2.stdapp (test_top_block, "Waterfall Sink Test App")
+ app.MainLoop ()
+
+if __name__ == '__main__':
+ main ()
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9249 - in gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python: . plotter,
jblum <=