From 3ad8f8ed993cccae7492bf0fa8519ebe15567101 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sat, 15 Jan 2011 17:15:11 -0500
Subject: Fix how the end of a file is handled.

---
 gr-utils/src/python/gr_plot_psd.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/gr_plot_psd.py
index 0e3dbecd94..b386d35ab2 100755
--- a/gr-utils/src/python/gr_plot_psd.py
+++ b/gr-utils/src/python/gr_plot_psd.py
@@ -60,8 +60,10 @@ class gr_plot_psd:
         rcParams['xtick.labelsize'] = self.axis_font_size
         rcParams['ytick.labelsize'] = self.axis_font_size
         
-        self.text_file     = figtext(0.10, 0.95, ("File: %s" % filename), weight="heavy", size=self.text_size)
-        self.text_file_pos = figtext(0.10, 0.92, "File Position: ", weight="heavy", size=self.text_size)
+        self.text_file     = figtext(0.10, 0.95, ("File: %s" % filename),
+                                     weight="heavy", size=self.text_size)
+        self.text_file_pos = figtext(0.10, 0.92, "File Position: ",
+                                     weight="heavy", size=self.text_size)
         self.text_block    = figtext(0.35, 0.92, ("Block Size: %d" % self.block_length),
                                      weight="heavy", size=self.text_size)
         self.text_sr       = figtext(0.60, 0.915, ("Sample Rate: %.2f" % self.sample_rate),
@@ -86,9 +88,9 @@ class gr_plot_psd:
     def get_data(self):
         self.position = self.hfile.tell()/self.sizeof_data
         self.text_file_pos.set_text("File Position: %d" % self.position)
-        self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
-        #print "Read in %d items" % len(self.iq)
-        if(len(self.iq) == 0):
+        try:
+            self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
+        except MemoryError:
             print "End of File"
         else:
             tstep = 1.0 / self.sample_rate
-- 
cgit v1.2.3


From 7b5095514204a524afbf6fd97bb70511519e5b35 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sat, 15 Jan 2011 17:21:14 -0500
Subject: Using .min and .max on scipy arrays instead of min() max(); seems to
 be more portable.

---
 gr-utils/src/python/gr_plot_psd.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/gr_plot_psd.py
index b386d35ab2..1b653d61ae 100755
--- a/gr-utils/src/python/gr_plot_psd.py
+++ b/gr-utils/src/python/gr_plot_psd.py
@@ -94,7 +94,7 @@ class gr_plot_psd:
             print "End of File"
         else:
             tstep = 1.0 / self.sample_rate
-            self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))]
+            self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
 
             self.iq_psd, self.freq = self.dopsd(self.iq)
             
@@ -154,13 +154,14 @@ class gr_plot_psd:
         imags = self.iq.imag
         self.plot_iq[0].set_data([self.time, reals])
         self.plot_iq[1].set_data([self.time, imags])
-        self.sp_iq.set_xlim(min(self.time), max(self.time))
-        self.sp_iq.set_ylim([1.5*min([min(reals), min(imags)]),
-                             1.5*max([max(reals), max(imags)])])
+        self.sp_iq.set_xlim(self.time.min(), self.time.max())
+        self.sp_iq.set_ylim([1.5*min([reals.min(), imags.min()]),
+                             1.5*max([reals.max(), imags.max()])])
 
     def draw_psd(self):
         self.plot_psd[0].set_data([self.freq, self.iq_psd])
-        self.sp_psd.set_ylim([min(self.iq_psd)-10, max(self.iq_psd)+10])
+        self.sp_psd.set_ylim([self.iq_psd.min()-10, self.iq_psd.max()+10])
+        self.sp_psd.set_xlim([self.freq.min(), self.freq.max()])
 
     def draw_spec(self):
         overlap = self.specfftsize/4
@@ -168,7 +169,7 @@ class gr_plot_psd:
         self.sp_spec.clear()
         self.sp_spec.specgram(self.iq, self.specfftsize, self.sample_rate,
                               window = lambda d: d*winfunc(self.specfftsize),
-                              noverlap = overlap, xextent=[min(self.time), max(self.time)])
+                              noverlap = overlap, xextent=[self.time.min(), self.time.max()])
 
     def update_plots(self):
         self.draw_time()
@@ -194,8 +195,8 @@ class gr_plot_psd:
             iq_psd, freq = self.dopsd(iq)
             
             self.plot_psd[0].set_data(freq, iq_psd)
-            self.sp_psd.axis([min(freq), max(freq),
-                              min(iq_psd)-10, max(iq_psd)+10])
+            self.sp_psd.axis([freq.min(), freq.max(),
+                              iq_psd.min()-10, iq_psd.max()+10])
 
             draw()
 
-- 
cgit v1.2.3


From 4f4268311488f88c2f20f31ba9d4615b522b946a Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sat, 15 Jan 2011 17:48:02 -0500
Subject: Fixing up other plotting tools for data read errors.

---
 gr-utils/src/python/gr_plot_const.py | 26 +++++++++++++-------------
 gr-utils/src/python/gr_plot_fft.py   | 28 ++++++++++++++--------------
 gr-utils/src/python/gr_plot_iq.py    | 25 +++++++++++++------------
 gr-utils/src/python/gr_plot_psd.py   |  2 +-
 gr-utils/src/python/plot_data.py     | 20 ++++++++++----------
 5 files changed, 51 insertions(+), 50 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/gr_plot_const.py b/gr-utils/src/python/gr_plot_const.py
index ec2272c744..9e4920776e 100755
--- a/gr-utils/src/python/gr_plot_const.py
+++ b/gr-utils/src/python/gr_plot_const.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007,2008 Free Software Foundation, Inc.
+# Copyright 2007,2008,2011 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -80,15 +80,15 @@ class draw_constellation:
 
     def get_data(self):
         self.text_file_pos.set_text("File Position: %d" % (self.hfile.tell()//self.sizeof_data))
-        iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
-        #print "Read in %d items" % len(iq)
-        if(len(iq) == 0):
+        try:
+            iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
+        except MemoryError:
             print "End of File"
         else:
-            self.reals = [r.real for r in iq]
-            self.imags = [i.imag for i in iq]
+            self.reals = scipy.array([r.real for r in iq])
+            self.imags = scipy.array([i.imag for i in iq])
 
-            self.time = [i*(1/self.sample_rate) for i in range(len(self.reals))]
+            self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.reals))])
             
     def make_plots(self):
         # if specified on the command-line, set file pointer
@@ -117,9 +117,9 @@ class draw_constellation:
         self.plot_const += self.sp_const.plot([self.reals[self.indx],], [self.imags[self.indx],], 'mo', ms=12)
 
         # Adjust axis
-        self.sp_iq.axis([min(self.time), max(self.time),
-                         1.5*min([min(self.reals), min(self.imags)]),
-                         1.5*max([max(self.reals), max(self.imags)])])
+        self.sp_iq.axis([self.time.min(), self.time.max(),
+                         1.5*min([self.reals.min(), self.imags.min()]),
+                         1.5*max([self.reals.max(), self.imags.max()])])
         self.sp_const.axis([-2, 2, -2, 2])
 
         draw()
@@ -127,9 +127,9 @@ class draw_constellation:
     def update_plots(self):
         self.plot_iq[0].set_data([self.time, self.reals])
         self.plot_iq[1].set_data([self.time, self.imags])
-        self.sp_iq.axis([min(self.time), max(self.time),
-                         1.5*min([min(self.reals), min(self.imags)]),
-                         1.5*max([max(self.reals), max(self.imags)])])
+        self.sp_iq.axis([self.time.min(), self.time.max(),
+                         1.5*min([self.reals.min(), self.imags.min()]),
+                         1.5*max([self.reals.max(), self.imags.max()])])
 
         self.plot_const[0].set_data([self.reals, self.imags])
         self.sp_const.axis([-2, 2, -2, 2])
diff --git a/gr-utils/src/python/gr_plot_fft.py b/gr-utils/src/python/gr_plot_fft.py
index a9c1417f9b..bb21f3dcda 100755
--- a/gr-utils/src/python/gr_plot_fft.py
+++ b/gr-utils/src/python/gr_plot_fft.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007,2008 Free Software Foundation, Inc.
+# Copyright 2007,2008,2011 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -81,15 +81,15 @@ class gr_plot_fft:
     def get_data(self):
         self.position = self.hfile.tell()/self.sizeof_data
         self.text_file_pos.set_text("File Position: %d" % (self.position))
-        self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
-        #print "Read in %d items" % len(self.iq)
-        if(len(self.iq) == 0):
+        try:
+            self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
+        except MemoryError:
             print "End of File"
         else:
             self.iq_fft = self.dofft(self.iq)
             
             tstep = 1.0 / self.sample_rate
-            self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))]
+            self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
 
             self.freq = self.calc_freq(self.time, self.sample_rate)
 
@@ -102,9 +102,9 @@ class gr_plot_fft:
 
     def calc_freq(self, time, sample_rate):
         N = len(time)
-        Fs = 1.0 / (max(time) - min(time))
+        Fs = 1.0 / (time.max() - time.min())
         Fn = 0.5 * sample_rate
-        freq = [-Fn + i*Fs for i in xrange(N)]
+        freq = scipy.array([-Fn + i*Fs for i in xrange(N)])
         return freq
         
     def make_plots(self):
@@ -139,14 +139,14 @@ class gr_plot_fft:
         imags = self.iq.imag
         self.plot_iq[0].set_data([self.time, reals])
         self.plot_iq[1].set_data([self.time, imags])
-        self.sp_iq.set_xlim(min(self.time), max(self.time))
-        self.sp_iq.set_ylim([1.5*min([min(reals), min(imags)]),
-                             1.5*max([max(reals), max(imags)])])
+        self.sp_iq.set_xlim(self.time.min(), self.time.max())
+        self.sp_iq.set_ylim([1.5*min([reals.min(), imags.min()]),
+                             1.5*max([reals.max(), imags.max()])])
 
     def draw_fft(self):
         self.plot_fft[0].set_data([self.freq, self.iq_fft])
-        self.sp_fft.set_xlim(min(self.freq), max(self.freq))
-        self.sp_fft.set_ylim([min(self.iq_fft)-10, max(self.iq_fft)+10])
+        self.sp_fft.set_xlim(self.freq.min(), self.freq.max())
+        self.sp_fft.set_ylim([self.iq_fft.min()-10, self.iq_fft.max()+10])
 
     def update_plots(self):
         self.draw_time()
@@ -170,8 +170,8 @@ class gr_plot_fft:
             freq = self.calc_freq(time, self.sample_rate)
             
             self.plot_fft[0].set_data(freq, iq_fft)
-            self.sp_fft.axis([min(freq), max(freq),
-                              min(iq_fft)-10, max(iq_fft)+10])
+            self.sp_fft.axis([freq.min(), freq.max(),
+                              iq_fft.min()-10, iq_fftmax()+10])
 
             draw()
 
diff --git a/gr-utils/src/python/gr_plot_iq.py b/gr-utils/src/python/gr_plot_iq.py
index 371ce3b799..316e60a757 100755
--- a/gr-utils/src/python/gr_plot_iq.py
+++ b/gr-utils/src/python/gr_plot_iq.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007,2008 Free Software Foundation, Inc.
+# Copyright 2007,2008,2011 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -78,14 +78,14 @@ class draw_iq:
 
     def get_data(self):
         self.text_file_pos.set_text("File Position: %d" % (self.hfile.tell()//self.sizeof_data))
-        self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
-        #print "Read in %d items" % len(self.iq)
-        if(len(self.iq) == 0):
+        try:
+            self.iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
+        except MemoryError:
             print "End of File"
         else:
-            self.reals = [r.real for r in self.iq]
-            self.imags = [i.imag for i in self.iq]
-            self.time = [i*(1/self.sample_rate) for i in range(len(self.reals))]
+            self.reals = scipy.array([r.real for r in self.iq])
+            self.imags = scipy.array([i.imag for i in self.iq])
+            self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.reals))])
             
     def make_plots(self):
         # if specified on the command-line, set file pointer
@@ -99,16 +99,17 @@ class draw_iq:
         self.sp_iq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold")
         self.sp_iq.set_ylabel("Amplitude (V)", fontsize=self.label_font_size, fontweight="bold")
         self.plot_iq = plot(self.time, self.reals, 'bo-', self.time, self.imags, 'ro-')
-        self.sp_iq.set_ylim([1.5*min([min(self.reals), min(self.imags)]),
-                             1.5*max([max(self.reals), max(self.imags)])])
-        
+        self.sp_iq.set_ylim([1.5*min([self.reals.min(), self.imags.min()]),
+                             1.5*max([self.reals.max(), self.imags.max()])])
+        self.sp_iq.set_xlim(self.time.min(), self.time.max())
         draw()
 
     def update_plots(self):
         self.plot_iq[0].set_data([self.time, self.reals])
         self.plot_iq[1].set_data([self.time, self.imags])
-        self.sp_iq.set_ylim([1.5*min([min(self.reals), min(self.imags)]),
-                             1.5*max([max(self.reals), max(self.imags)])])
+        self.sp_iq.set_ylim([1.5*min([self.reals.min(), self.imags.min()]),
+                             1.5*max([self.reals.max(), self.imags.max()])])
+        self.sp_iq.set_xlim(self.time.min(), self.time.max())
         draw()
         
     def click(self, event):
diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/gr_plot_psd.py
index 1b653d61ae..d5bfca3892 100755
--- a/gr-utils/src/python/gr_plot_psd.py
+++ b/gr-utils/src/python/gr_plot_psd.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007,2008 Free Software Foundation, Inc.
+# Copyright 2007,2008,2011 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
diff --git a/gr-utils/src/python/plot_data.py b/gr-utils/src/python/plot_data.py
index 08cdd60306..15012e5893 100644
--- a/gr-utils/src/python/plot_data.py
+++ b/gr-utils/src/python/plot_data.py
@@ -1,5 +1,5 @@
 #
-# Copyright 2007,2008 Free Software Foundation, Inc.
+# Copyright 2007,2008,2011 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -81,13 +81,13 @@ class plot_data:
         
     def get_data(self, hfile):
         self.text_file_pos.set_text("File Position: %d" % (hfile.tell()//self.sizeof_data))
-        f = scipy.fromfile(hfile, dtype=self.datatype, count=self.block_length)
-        #print "Read in %d items" % len(self.f)
-        if(len(f) == 0):
+        try:
+            f = scipy.fromfile(hfile, dtype=self.datatype, count=self.block_length)
+        except MemoryError:
             print "End of File"
         else:
-            self.f = f
-            self.time = [i*(1/self.sample_rate) for i in range(len(self.f))]
+            self.f = scipy.array(f)
+            self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.f))])
         
     def make_plots(self):
         self.sp_f = self.fig.add_subplot(2,1,1, position=[0.075, 0.2, 0.875, 0.6])
@@ -107,8 +107,8 @@ class plot_data:
         
             # Subplot for real and imaginary parts of signal
             self.plot_f += plot(self.time, self.f, 'o-')
-            maxval = max(maxval, max(self.f))
-            minval = min(minval, min(self.f))
+            maxval = max(maxval, self.f.max())
+            minval = min(minval, self.f.min())
 
         self.sp_f.set_ylim([1.5*minval, 1.5*maxval])
 
@@ -122,8 +122,8 @@ class plot_data:
         for hf,p in zip(self.hfile,self.plot_f):
             self.get_data(hf)
             p.set_data([self.time, self.f])
-            maxval = max(maxval, max(self.f))
-            minval = min(minval, min(self.f))
+            maxval = max(maxval, self.f.max())
+            minval = min(minval, self.f.min())
 
         self.sp_f.set_ylim([1.5*minval, 1.5*maxval])
         
-- 
cgit v1.2.3


From a8e021e949fca067cf2df5a7cbb7c68ac21b8935 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sun, 16 Jan 2011 13:34:42 -0500
Subject: Fixing zooming capabilities. Time axis does not track any longer due
 to what looks like a matplotlib bug that resets the xlims after the zoom
 occurs.

---
 gr-utils/src/python/gr_plot_psd.py | 62 ++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/gr_plot_psd.py
index d5bfca3892..e88995b725 100755
--- a/gr-utils/src/python/gr_plot_psd.py
+++ b/gr-utils/src/python/gr_plot_psd.py
@@ -78,7 +78,7 @@ class gr_plot_psd:
         self.button_right = Button(self.button_right_axes, ">")
         self.button_right_callback = self.button_right.on_clicked(self.button_right_click)
 
-        self.xlim = self.sp_iq.get_xlim()
+        self.xlim = scipy.array(self.sp_iq.get_xlim())
 
         self.manager = get_current_fig_manager()
         connect('draw_event', self.zoom)
@@ -94,10 +94,11 @@ class gr_plot_psd:
             print "End of File"
         else:
             tstep = 1.0 / self.sample_rate
-            self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
+            #self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
+            self.time = scipy.array([tstep*(i) for i in xrange(len(self.iq))])
 
             self.iq_psd, self.freq = self.dopsd(self.iq)
-            
+          
     def dopsd(self, iq):
         ''' Need to do this here and plot later so we can do the fftshift '''
         overlap = self.psdfftsize/4
@@ -132,10 +133,10 @@ class gr_plot_psd:
         
         self.plot_iq  = self.sp_iq.plot([], 'bo-') # make plot for reals
         self.plot_iq += self.sp_iq.plot([], 'ro-') # make plot for imags
-        self.draw_time()                           # draw the plot
+        self.draw_time(self.time, self.iq)         # draw the plot
 
         self.plot_psd = self.sp_psd.plot([], 'b')  # make plot for PSD
-        self.draw_psd()                            # draw the plot
+        self.draw_psd(self.freq, self.iq_psd)      # draw the plot
 
 
         if self.dospec:
@@ -145,58 +146,59 @@ class gr_plot_psd:
             self.sp_spec.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold")
             self.sp_spec.set_ylabel("Frequency (Hz)", fontsize=self.label_font_size, fontweight="bold")
 
-            self.draw_spec()
+            self.draw_spec(self.time, self.iq)
         
         draw()
 
-    def draw_time(self):
-        reals = self.iq.real
-        imags = self.iq.imag
-        self.plot_iq[0].set_data([self.time, reals])
-        self.plot_iq[1].set_data([self.time, imags])
-        self.sp_iq.set_xlim(self.time.min(), self.time.max())
+    def draw_time(self, t, iq):
+        reals = iq.real
+        imags = iq.imag
+        self.plot_iq[0].set_data([t, reals])
+        self.plot_iq[1].set_data([t, imags])
+        self.sp_iq.set_xlim(t.min(), t.max())
         self.sp_iq.set_ylim([1.5*min([reals.min(), imags.min()]),
                              1.5*max([reals.max(), imags.max()])])
 
-    def draw_psd(self):
-        self.plot_psd[0].set_data([self.freq, self.iq_psd])
-        self.sp_psd.set_ylim([self.iq_psd.min()-10, self.iq_psd.max()+10])
-        self.sp_psd.set_xlim([self.freq.min(), self.freq.max()])
+    def draw_psd(self, f, p):
+        self.plot_psd[0].set_data([f, p])
+        self.sp_psd.set_ylim([p.min()-10, p.max()+10])
+        self.sp_psd.set_xlim([f.min(), f.max()])
 
-    def draw_spec(self):
+    def draw_spec(self, t, s):
         overlap = self.specfftsize/4
         winfunc = scipy.blackman
         self.sp_spec.clear()
-        self.sp_spec.specgram(self.iq, self.specfftsize, self.sample_rate,
+        self.sp_spec.specgram(s, self.specfftsize, self.sample_rate,
                               window = lambda d: d*winfunc(self.specfftsize),
-                              noverlap = overlap, xextent=[self.time.min(), self.time.max()])
+                              noverlap = overlap, xextent=[t.min(), t.max()])
 
     def update_plots(self):
-        self.draw_time()
-        self.draw_psd()
+        self.draw_time(self.time, self.iq)
+        self.draw_psd(self.freq, self.iq_psd)
 
         if self.dospec:
-            self.draw_spec()
+            self.draw_spec(self.time, self.iq)
 
-        self.xlim = self.sp_iq.get_xlim() # so zoom doesn't get called
+        self.xlim = scipy.array(self.sp_iq.get_xlim()) # so zoom doesn't get called
+        
         draw()
         
     def zoom(self, event):
         newxlim = scipy.array(self.sp_iq.get_xlim())
         curxlim = scipy.array(self.xlim)
-        if(newxlim.all() != curxlim.all()):
-            self.xlim = newxlim
-            xmin = max(0, int(ceil(self.sample_rate*(self.xlim[0] - self.position))))
-            xmax = min(int(ceil(self.sample_rate*(self.xlim[1] - self.position))), len(self.iq))
+        if(newxlim[0] != curxlim[0] or newxlim[1] != curxlim[1]):
+            #xmin = max(0, int(ceil(self.sample_rate*(newxlim[0] - self.position))))
+            #xmax = min(int(ceil(self.sample_rate*(newxlim[1] - self.position))), len(self.iq))
+            xmin = max(0, int(ceil(self.sample_rate*(newxlim[0]))))
+            xmax = min(int(ceil(self.sample_rate*(newxlim[1]))), len(self.iq))
 
             iq = self.iq[xmin : xmax]
             time = self.time[xmin : xmax]
 
             iq_psd, freq = self.dopsd(iq)
             
-            self.plot_psd[0].set_data(freq, iq_psd)
-            self.sp_psd.axis([freq.min(), freq.max(),
-                              iq_psd.min()-10, iq_psd.max()+10])
+            self.draw_psd(freq, iq_psd)
+            self.xlim = scipy.array(self.sp_iq.get_xlim())
 
             draw()
 
-- 
cgit v1.2.3


From ead0819388bc03555c9182f27176aac6ea2a8bbc Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Sun, 16 Jan 2011 13:40:20 -0500
Subject: Fixing up fft and constellation plot to better handle zooming.

---
 gr-utils/src/python/gr_plot_const.py |  2 +-
 gr-utils/src/python/gr_plot_fft.py   | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/gr_plot_const.py b/gr-utils/src/python/gr_plot_const.py
index 9e4920776e..5dd08c9a0d 100755
--- a/gr-utils/src/python/gr_plot_const.py
+++ b/gr-utils/src/python/gr_plot_const.py
@@ -138,7 +138,7 @@ class draw_constellation:
     def zoom(self, event):
         newxlim = scipy.array(self.sp_iq.get_xlim())
         curxlim = scipy.array(self.xlim)
-        if(newxlim.all() != curxlim.all()):
+        if(newxlim[0] != curxlim[0] or newxlim[1] != curxlim[1]):
             self.xlim = newxlim
             r = self.reals[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))]
             i = self.imags[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))]
diff --git a/gr-utils/src/python/gr_plot_fft.py b/gr-utils/src/python/gr_plot_fft.py
index bb21f3dcda..ba3901e03c 100755
--- a/gr-utils/src/python/gr_plot_fft.py
+++ b/gr-utils/src/python/gr_plot_fft.py
@@ -89,7 +89,8 @@ class gr_plot_fft:
             self.iq_fft = self.dofft(self.iq)
             
             tstep = 1.0 / self.sample_rate
-            self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
+            #self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))])
+            self.time = scipy.array([tstep*(i) for i in xrange(len(self.iq))])
 
             self.freq = self.calc_freq(self.time, self.sample_rate)
 
@@ -158,10 +159,12 @@ class gr_plot_fft:
     def zoom(self, event):
         newxlim = scipy.array(self.sp_iq.get_xlim())
         curxlim = scipy.array(self.xlim)
-        if(newxlim.all() != curxlim.all()):
+        if(newxlim[0] != curxlim[0] or newxlim[1] != curxlim[1]):
             self.xlim = newxlim
-            xmin = max(0, int(ceil(self.sample_rate*(self.xlim[0] - self.position))))
-            xmax = min(int(ceil(self.sample_rate*(self.xlim[1] - self.position))), len(self.iq))
+            #xmin = max(0, int(ceil(self.sample_rate*(self.xlim[0] - self.position))))
+            #xmax = min(int(ceil(self.sample_rate*(self.xlim[1] - self.position))), len(self.iq))
+            xmin = max(0, int(ceil(self.sample_rate*(self.xlim[0]))))
+            xmax = min(int(ceil(self.sample_rate*(self.xlim[1]))), len(self.iq))
 
             iq = self.iq[xmin : xmax]
             time = self.time[xmin : xmax]
@@ -171,7 +174,7 @@ class gr_plot_fft:
             
             self.plot_fft[0].set_data(freq, iq_fft)
             self.sp_fft.axis([freq.min(), freq.max(),
-                              iq_fft.min()-10, iq_fftmax()+10])
+                              iq_fft.min()-10, iq_fft.max()+10])
 
             draw()
 
-- 
cgit v1.2.3