summaryrefslogtreecommitdiff
path: root/gr-utils/src/python/gr_plot_fft.py
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2011-01-15 17:48:02 -0500
committerTom Rondeau <trondeau@vt.edu>2011-01-15 17:48:02 -0500
commit4f4268311488f88c2f20f31ba9d4615b522b946a (patch)
tree5c345c87e8566b745e692c3c12894b2adc812a30 /gr-utils/src/python/gr_plot_fft.py
parent7b5095514204a524afbf6fd97bb70511519e5b35 (diff)
Fixing up other plotting tools for data read errors.
Diffstat (limited to 'gr-utils/src/python/gr_plot_fft.py')
-rwxr-xr-xgr-utils/src/python/gr_plot_fft.py28
1 files changed, 14 insertions, 14 deletions
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()