commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8737 - gnuradio/branches/developers/jblum/gr-wxglgui/


From: jblum
Subject: [Commit-gnuradio] r8737 - gnuradio/branches/developers/jblum/gr-wxglgui/src/python
Date: Fri, 27 Jun 2008 00:46:58 -0600 (MDT)

Author: jblum
Date: 2008-06-27 00:46:57 -0600 (Fri, 27 Jun 2008)
New Revision: 8737

Modified:
   gnuradio/branches/developers/jblum/gr-wxglgui/src/python/fftsink.py
Log:
proper x_per_div calculation

Modified: gnuradio/branches/developers/jblum/gr-wxglgui/src/python/fftsink.py
===================================================================
--- gnuradio/branches/developers/jblum/gr-wxglgui/src/python/fftsink.py 
2008-06-27 04:29:07 UTC (rev 8736)
+++ gnuradio/branches/developers/jblum/gr-wxglgui/src/python/fftsink.py 
2008-06-27 06:46:57 UTC (rev 8737)
@@ -33,7 +33,7 @@
 # Constants
 ##################################################
 DEFAULT_FFT_RATE = gr.prefs().get_long('wxgui', 'fft_rate', 15)
-DIV_LEVELS = (1, 2, 5, 10, 20)
+DIV_LEVELS = (1, 2, 5, 10, 20, 50)
 
 ##################################################
 # FFT window control panel
@@ -146,19 +146,18 @@
                self.peak_hold = peak_hold
                self.set_average = set_average
                self.peak_vals = []
-               #determine units
-               if sample_rate > 5e9:
-                       units = 'GHz'
-                       power = 9
-               elif sample_rate > 5e6:
-                       units = 'MHz'
-                       power = 6
-               elif sample_rate > 5e3:
-                       units = 'KHz'
-                       power = 3
-               else:
-                       units = 'Hz'
-                       power = 0
+               #determine best fitting x_per_div
+               x_divs = 8.0 #appoximate 
+               if real: x_width = sample_rate/2.0
+               else: x_width = sample_rate
+               exp = math.floor(math.log10(x_width/x_divs))            
+               x_per_divs = numpy.array((1, 2, 5, 10))*10**exp         
+               x_per_div = x_per_divs[numpy.argmin(numpy.abs(x_per_divs - 
x_width/x_divs))]                    
+               #calculate units and scalar
+               if exp >= 9: units, power = 'GHz', 9
+               elif exp >= 6: units, power = 'MHz', 6
+               elif exp >= 3: units, power = 'KHz', 3
+               else: units, power = 'Hz', 0
                scalar = 10**(-1*power)
                #init panel and plot 
                wx.Panel.__init__(self, parent, -1)                             
  
@@ -167,13 +166,13 @@
                        self.plotter.set_x_grid(
                                scalar*baseband_freq, 
                                scalar*baseband_freq + scalar*sample_rate/2.0, 
-                               scalar*int(sample_rate/16),
+                               scalar*x_per_div,
                        ) 
                else:
                        self.plotter.set_x_grid(
                                scalar*baseband_freq - scalar*sample_rate/2.0, 
                                scalar*baseband_freq + scalar*sample_rate/2.0, 
-                               scalar*int(sample_rate/8),
+                               scalar*x_per_div,
                        )
                #setup the box with plot and controls
                self.control_panel = control_panel(self)
@@ -186,7 +185,7 @@
                
        def plot(self, samples):
                #peak hold calculation
-               if self.peak_hold and len(peak_vals) != len(samples): 
self.peak_vals = samples
+               if self.peak_hold and len(self.peak_vals) != len(samples): 
self.peak_vals = samples
                if self.peak_hold: self.peak_hold = numpy.maximum(samples, 
self.peak_vals)
                #plot the fft
                self.plotter.set_waveform(
@@ -446,7 +445,7 @@
        vbox = wx.BoxSizer(wx.VERTICAL)
        test_app_block(frame, vbox)
        frame.SetSizerAndFit(vbox)
-       frame.SetSize(wx.Size(800, 600))
+       frame.SetSize(wx.Size(800, 500))
        frame.Show()
        app.MainLoop()
 





reply via email to

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