summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2009-08-31 18:18:22 -0700
committerJosh Blum <josh@joshknows.com>2009-08-31 18:18:22 -0700
commit0c68c486ec09da471c27b6f4d658ae0ba8f861b7 (patch)
treed77864cb2bbb8e2d099d9d2d05da2ee823c53045
parent1aa216df204197b4849581dd4f42b2e7680eb72f (diff)
Modified log power fft block so ref scale is peak to peak.
Tweaked fft sink autoscale routine to come up with better numbers. Modified scope sink ac couple block to use constant tap. The previous tap calculation would cause failure for very small sample rates.
-rw-r--r--gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py4
-rw-r--r--gr-wxgui/src/python/fft_window.py20
-rw-r--r--gr-wxgui/src/python/scopesink_gl.py2
3 files changed, 15 insertions, 11 deletions
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
index cf8eb1be78..7ef40be40a 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py
@@ -55,9 +55,9 @@ class _logpwrfft_base(gr.hier_block2):
c2mag = gr.complex_to_mag(fft_size)
self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size)
self._log = gr.nlog10_ff(20, fft_size,
- -10*math.log10(fft_size) # Adjust for number of bins
+ -20*math.log10(fft_size) # Adjust for number of bins
-10*math.log10(window_power/fft_size) # Adjust for windowing loss
- -20*math.log10(ref_scale/2)) # Adjust for reference scale
+ -20*math.log10(ref_scale/2)+3.0) # Adjust for reference scale
self.connect(self, self._sd, fft, c2mag, self._avg, self._log, self)
self._average = average
diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py
index 0529e6a5d6..4c575f1a62 100644
--- a/gr-wxgui/src/python/fft_window.py
+++ b/gr-wxgui/src/python/fft_window.py
@@ -256,15 +256,19 @@ class fft_window(wx.Panel, pubsub.pubsub):
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])
+ #separate noise samples
+ noise_samps = numpy.sort(self.samples)[:len(self.samples)/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)
#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/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py
index b4ae0f3391..a5e3ca3ce3 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]