summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2012-04-01 17:16:41 -0400
committerTom Rondeau2012-04-01 17:16:41 -0400
commit1ca78cb621cbd60f25c5ce4373fa727114a86cee (patch)
tree7eb83818efa7c17fe409483fedf78c3eff2dc1ef
parentbd7b4a566da02a3e68857c7f5a6963a132a2f2d2 (diff)
downloadgnuradio-1ca78cb621cbd60f25c5ce4373fa727114a86cee.tar.gz
gnuradio-1ca78cb621cbd60f25c5ce4373fa727114a86cee.tar.bz2
gnuradio-1ca78cb621cbd60f25c5ce4373fa727114a86cee.zip
build: removed .py extensions from installed Python plot programs.
The fft and psd bases have been moved into the Python packages directory and new wrappers for data-type independent programs have been created.
-rw-r--r--gr-utils/src/python/CMakeLists.txt30
-rw-r--r--gr-utils/src/python/README.plot95
-rwxr-xr-xgr-utils/src/python/gr_filter_design (renamed from gr-utils/src/python/gr_filter_design.py)0
-rwxr-xr-xgr-utils/src/python/gr_plot_char (renamed from gr-utils/src/python/gr_plot_char.py)0
-rwxr-xr-xgr-utils/src/python/gr_plot_const (renamed from gr-utils/src/python/gr_plot_const.py)0
-rw-r--r--gr-utils/src/python/gr_plot_fft42
-rwxr-xr-xgr-utils/src/python/gr_plot_fft_c (renamed from gr-utils/src/python/gr_plot_fft_f.py)8
-rwxr-xr-xgr-utils/src/python/gr_plot_fft_f (renamed from gr-utils/src/python/gr_plot_fft_c.py)8
-rwxr-xr-xgr-utils/src/python/gr_plot_float (renamed from gr-utils/src/python/gr_plot_float.py)0
-rwxr-xr-xgr-utils/src/python/gr_plot_int (renamed from gr-utils/src/python/gr_plot_int.py)0
-rwxr-xr-xgr-utils/src/python/gr_plot_iq (renamed from gr-utils/src/python/gr_plot_iq.py)0
-rw-r--r--gr-utils/src/python/gr_plot_psd42
-rwxr-xr-xgr-utils/src/python/gr_plot_psd_c (renamed from gr-utils/src/python/gr_plot_psd_c.py)8
-rwxr-xr-xgr-utils/src/python/gr_plot_psd_f (renamed from gr-utils/src/python/gr_plot_psd_f.py)6
-rwxr-xr-xgr-utils/src/python/gr_plot_qt (renamed from gr-utils/src/python/gr_plot_qt.py)2
-rwxr-xr-xgr-utils/src/python/gr_plot_short (renamed from gr-utils/src/python/gr_plot_short.py)0
-rwxr-xr-xgr-utils/src/python/plot_fft_base.py (renamed from gr-utils/src/python/gr_plot_fft.py)41
-rwxr-xr-xgr-utils/src/python/plot_psd_base.py (renamed from gr-utils/src/python/gr_plot_psd.py)53
18 files changed, 242 insertions, 93 deletions
diff --git a/gr-utils/src/python/CMakeLists.txt b/gr-utils/src/python/CMakeLists.txt
index fba0d57a5..90caeb234 100644
--- a/gr-utils/src/python/CMakeLists.txt
+++ b/gr-utils/src/python/CMakeLists.txt
@@ -25,6 +25,8 @@ include(GrPython)
GR_PYTHON_INSTALL(
FILES
plot_data.py
+ plot_fft_base.py
+ plot_psd_base.py
pyqt_plot.py
pyqt_filter.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio
@@ -34,20 +36,20 @@ GR_PYTHON_INSTALL(
GR_PYTHON_INSTALL(
PROGRAMS
create-gnuradio-out-of-tree-project
- gr_plot_char.py
- gr_plot_const.py
- gr_plot_fft.py
- gr_plot_fft_c.py
- gr_plot_fft_f.py
- gr_plot_psd.py
- gr_plot_psd_c.py
- gr_plot_psd_f.py
- gr_plot_float.py
- gr_plot_int.py
- gr_plot_iq.py
- gr_plot_short.py
- gr_plot_qt.py
- gr_filter_design.py
+ gr_plot_char
+ gr_plot_const
+ gr_plot_fft
+ gr_plot_fft_c
+ gr_plot_fft_f
+ gr_plot_psd
+ gr_plot_psd_c
+ gr_plot_psd_f
+ gr_plot_float
+ gr_plot_int
+ gr_plot_iq
+ gr_plot_short
+ gr_plot_qt
+ gr_filter_design
DESTINATION ${GR_RUNTIME_DIR}
COMPONENT "utils"
)
diff --git a/gr-utils/src/python/README.plot b/gr-utils/src/python/README.plot
index 0c4657ba9..60f14c669 100644
--- a/gr-utils/src/python/README.plot
+++ b/gr-utils/src/python/README.plot
@@ -1,40 +1,97 @@
-* gr_plot_*.py:
-These are a collection of Python scripts to enable viewing and analysis of files produced by GNU Radio flow graphs. Most of them work off complex data produced by digital waveforms.
+* gr_plot_*:
+These are a collection of Python scripts to enable viewing and
+analysis of files produced by GNU Radio flow graphs. Most of them work
+off complex data produced by digital waveforms.
-** gr_plot_float.py:
-Takes a GNU Radio floating point binary file and displays the samples versus time. You can set the block size to specify how many points to read in at a time and the start position in the file.
+** gr_plot_float:
+Takes a GNU Radio floating point binary file and displays the samples
+versus time. You can set the block size to specify how many points to
+read in at a time and the start position in the file.
-By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples.
+By default, the system assumes a sample rate of 1, so in time, each
+sample is plotted versus the sample number. To set a true time axis,
+set the sample rate (-R or --sample-rate) to the sample rate used when
+capturing the samples.
-** gr_plot_iq.py:
-Takes a GNU Radio complex binary file and displays the I&Q data versus time. You can set the block size to specify how many points to read in at a time and the start position in the file.
+** gr_plot_iq:
+Takes a GNU Radio complex binary file and displays the I&Q data versus
+time. You can set the block size to specify how many points to read in
+at a time and the start position in the file.
-By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples.
+By default, the system assumes a sample rate of 1, so in time, each
+sample is plotted versus the sample number. To set a true time axis,
+set the sample rate (-R or --sample-rate) to the sample rate used when
+capturing the samples.
-** gr_plot_const.py:
-Takes a GNU Radio complex binary file and displays the I&Q data versus time and the constellation plot (I vs. Q). You can set the block size to specify how many points to read in at a time and the start position in the file.
+** gr_plot_const:
+Takes a GNU Radio complex binary file and displays the I&Q data versus
+time and the constellation plot (I vs. Q). You can set the block size
+to specify how many points to read in at a time and the start position
+in the file.
-By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples.
+By default, the system assumes a sample rate of 1, so in time, each
+sample is plotted versus the sample number. To set a true time axis,
+set the sample rate (-R or --sample-rate) to the sample rate used when
+capturing the samples.
-** gr_plot_fft_c.py:
-Takes a GNU Radio complex binary file and displays the I&Q data versus time as well as the frequency domain (FFT) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally).
+** gr_plot_fft_c:
+Takes a GNU Radio complex binary file and displays the I&Q data versus
+time as well as the frequency domain (FFT) plot. The y-axis values are
+plotted assuming volts as the amplitude of the I&Q streams and
+converted into dBm in the frequency domain (the 1/N power adjustment
+out of the FFT is performed internally).
-The script plots a certain block of data at a time, specified on the command line as -B or --block. This value defaults to 1000. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file).
+The script plots a certain block of data at a time, specified on the
+command line as -B or --block. This value defaults to 1000. The start
+position in the file can be set by specifying -s or --start and
+defaults to 0 (the start of the file).
-By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples.
+By default, the system assumes a sample rate of 1, so in time, each
+sample is plotted versus the sample number. To set a true time and
+frequency axis, set the sample rate (-R or --sample-rate) to the
+sample rate used when capturing the samples.
-** gr_plot_fft_f.py:
-Takes a GNU Radio floating point binary file and displays the samples versus time as well as the frequency domain (FFT) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally).
+** gr_plot_fft_f:
+Takes a GNU Radio floating point binary file and displays the samples
+versus time as well as the frequency domain (FFT) plot. The y-axis
+values are plotted assuming volts as the amplitude of the I&Q streams
+and converted into dBm in the frequency domain (the 1/N power
+adjustment out of the FFT is performed internally).
-The script plots a certain block of data at a time, specified on the command line as -B or --block. This value defaults to 1000. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file).
+The script plots a certain block of data at a time, specified on the
+command line as -B or --block. This value defaults to 1000. The start
+position in the file can be set by specifying -s or --start and
+defaults to 0 (the start of the file).
-By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples.
+By default, the system assumes a sample rate of 1, so in time, each
+sample is plotted versus the sample number. To set a true time and
+frequency axis, set the sample rate (-R or --sample-rate) to the
+sample rate used when capturing the samples.
+
+
+** gr_plot_fft:
+Takes a GNU Radio binary file (the datatype is specified using the -d
+option and defaults to complex64) and displays the samples versus time
+as well as the frequency domain (FFT) plot. The y-axis values are
+plotted assuming volts as the amplitude of the I&Q streams and
+converted into dBm in the frequency domain (the 1/N power adjustment
+out of the FFT is performed internally).
+
+The script plots a certain block of data at a time, specified on the
+command line as -B or --block. This value defaults to 1000. The start
+position in the file can be set by specifying -s or --start and
+defaults to 0 (the start of the file).
+
+By default, the system assumes a sample rate of 1, so in time, each
+sample is plotted versus the sample number. To set a true time and
+frequency axis, set the sample rate (-R or --sample-rate) to the
+sample rate used when capturing the samples.
diff --git a/gr-utils/src/python/gr_filter_design.py b/gr-utils/src/python/gr_filter_design
index e8703db4f..e8703db4f 100755
--- a/gr-utils/src/python/gr_filter_design.py
+++ b/gr-utils/src/python/gr_filter_design
diff --git a/gr-utils/src/python/gr_plot_char.py b/gr-utils/src/python/gr_plot_char
index 87a323c9c..87a323c9c 100755
--- a/gr-utils/src/python/gr_plot_char.py
+++ b/gr-utils/src/python/gr_plot_char
diff --git a/gr-utils/src/python/gr_plot_const.py b/gr-utils/src/python/gr_plot_const
index 8873e5b7e..8873e5b7e 100755
--- a/gr-utils/src/python/gr_plot_const.py
+++ b/gr-utils/src/python/gr_plot_const
diff --git a/gr-utils/src/python/gr_plot_fft b/gr-utils/src/python/gr_plot_fft
new file mode 100644
index 000000000..6859ea471
--- /dev/null
+++ b/gr-utils/src/python/gr_plot_fft
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio.plot_fft_base import plot_fft_base
+
+# This is a wrapper program for plot_fft_base. It handles any data
+# type and defaults to complex64.
+
+def main():
+ parser = plot_fft_base.setup_options()
+ (options, args) = parser.parse_args ()
+ if len(args) != 1:
+ parser.print_help()
+ raise SystemExit, 1
+ filename = args[0]
+
+ dc = plot_fft_base(options.data_type, filename, options)
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
diff --git a/gr-utils/src/python/gr_plot_fft_f.py b/gr-utils/src/python/gr_plot_fft_c
index f50358f01..e4ee9c5a9 100755
--- a/gr-utils/src/python/gr_plot_fft_f.py
+++ b/gr-utils/src/python/gr_plot_fft_c
@@ -20,10 +20,12 @@
# Boston, MA 02110-1301, USA.
#
-import gr_plot_fft
+from gnuradio.plot_fft_base import plot_fft_base
+
+# This is a wrapper program for plot_fft_base specifically for complex data
def main():
- parser = gr_plot_fft.setup_options()
+ parser = plot_fft_base.setup_options()
parser.remove_option("--data-type")
(options, args) = parser.parse_args ()
@@ -32,7 +34,7 @@ def main():
raise SystemExit, 1
filename = args[0]
- dc = gr_plot_fft.gr_plot_fft("float32", filename, options)
+ dc = plot_fft_base("complex64", filename, options)
if __name__ == "__main__":
try:
diff --git a/gr-utils/src/python/gr_plot_fft_c.py b/gr-utils/src/python/gr_plot_fft_f
index de59b36c9..66c75a8ff 100755
--- a/gr-utils/src/python/gr_plot_fft_c.py
+++ b/gr-utils/src/python/gr_plot_fft_f
@@ -20,10 +20,12 @@
# Boston, MA 02110-1301, USA.
#
-import gr_plot_fft
+from gnuradio.plot_fft_base import plot_fft_base
+
+# This is a wrapper program for plot_fft_base specifically for float data
def main():
- parser = gr_plot_fft.setup_options()
+ parser = plot_fft_base.setup_options()
parser.remove_option("--data-type")
(options, args) = parser.parse_args ()
@@ -32,7 +34,7 @@ def main():
raise SystemExit, 1
filename = args[0]
- dc = gr_plot_fft.gr_plot_fft("complex64", filename, options)
+ dc = plot_fft_base("float32", filename, options)
if __name__ == "__main__":
try:
diff --git a/gr-utils/src/python/gr_plot_float.py b/gr-utils/src/python/gr_plot_float
index e5c22a315..e5c22a315 100755
--- a/gr-utils/src/python/gr_plot_float.py
+++ b/gr-utils/src/python/gr_plot_float
diff --git a/gr-utils/src/python/gr_plot_int.py b/gr-utils/src/python/gr_plot_int
index b44d4360a..b44d4360a 100755
--- a/gr-utils/src/python/gr_plot_int.py
+++ b/gr-utils/src/python/gr_plot_int
diff --git a/gr-utils/src/python/gr_plot_iq.py b/gr-utils/src/python/gr_plot_iq
index 316e60a75..316e60a75 100755
--- a/gr-utils/src/python/gr_plot_iq.py
+++ b/gr-utils/src/python/gr_plot_iq
diff --git a/gr-utils/src/python/gr_plot_psd b/gr-utils/src/python/gr_plot_psd
new file mode 100644
index 000000000..658e7b297
--- /dev/null
+++ b/gr-utils/src/python/gr_plot_psd
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio.plot_psd_base import plot_psd_base
+
+# This is a wrapper program for plot_psd_base. It handles any data
+# type and defaults to complex64.
+
+def main():
+ parser = plot_psd_base.setup_options()
+ (options, args) = parser.parse_args ()
+ if len(args) != 1:
+ parser.print_help()
+ raise SystemExit, 1
+ filename = args[0]
+
+ dc = plot_psd_base(options.data_type, filename, options)
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ pass
diff --git a/gr-utils/src/python/gr_plot_psd_c.py b/gr-utils/src/python/gr_plot_psd_c
index 1edc04c2b..192f263ec 100755
--- a/gr-utils/src/python/gr_plot_psd_c.py
+++ b/gr-utils/src/python/gr_plot_psd_c
@@ -21,12 +21,12 @@
#
from optparse import OptionParser
-import gr_plot_psd
+from gnuradio.plot_psd_base import plot_psd_base
-# This is a wrapper program for gr_plot_psd specifically for complex data
+# This is a wrapper program for plot_psd_base specifically for complex data
def main():
- parser = gr_plot_psd.setup_options()
+ parser = plot_psd_base.setup_options()
parser.remove_option("--data-type")
(options, args) = parser.parse_args ()
@@ -35,7 +35,7 @@ def main():
raise SystemExit, 1
filename = args[0]
- dc = gr_plot_psd.gr_plot_psd("complex64", filename, options)
+ dc = plot_psd_base("complex64", filename, options)
if __name__ == "__main__":
try:
diff --git a/gr-utils/src/python/gr_plot_psd_f.py b/gr-utils/src/python/gr_plot_psd_f
index bad6788c3..fab312645 100755
--- a/gr-utils/src/python/gr_plot_psd_f.py
+++ b/gr-utils/src/python/gr_plot_psd_f
@@ -21,12 +21,12 @@
#
from optparse import OptionParser
-import gr_plot_psd
+from gnuradio.plot_psd_base import plot_psd_base
# This is a wrapper program for gr_plot_psd specifically for floating point data
def main():
- parser = gr_plot_psd.setup_options()
+ parser = plot_psd_base.setup_options()
parser.remove_option("--data-type")
(options, args) = parser.parse_args ()
@@ -35,7 +35,7 @@ def main():
raise SystemExit, 1
filename = args[0]
- dc = gr_plot_psd.gr_plot_psd("float32", filename, options)
+ dc = plot_psd_base("float32", filename, options)
if __name__ == "__main__":
try:
diff --git a/gr-utils/src/python/gr_plot_qt.py b/gr-utils/src/python/gr_plot_qt
index f3dc472f5..937d0014b 100755
--- a/gr-utils/src/python/gr_plot_qt.py
+++ b/gr-utils/src/python/gr_plot_qt
@@ -28,7 +28,7 @@ except ImportError:
try:
# FIXME: reenable this before committing
#from gnuradio.pyqt_plot import Ui_MainWindow
- from pyqt_plot import Ui_MainWindow
+ from gnuradio.pyqt_plot import Ui_MainWindow
except ImportError:
print "Could not import from pyqt_plot. Please build with \"pyuic4 pyqt_plot.ui -o pyqt_plot.py\""
raise SystemExit, 1
diff --git a/gr-utils/src/python/gr_plot_short.py b/gr-utils/src/python/gr_plot_short
index 3466e0b7d..3466e0b7d 100755
--- a/gr-utils/src/python/gr_plot_short.py
+++ b/gr-utils/src/python/gr_plot_short
diff --git a/gr-utils/src/python/gr_plot_fft.py b/gr-utils/src/python/plot_fft_base.py
index ba3901e03..0b5df504b 100755
--- a/gr-utils/src/python/gr_plot_fft.py
+++ b/gr-utils/src/python/plot_fft_base.py
@@ -35,7 +35,7 @@ except ImportError:
from optparse import OptionParser
-class gr_plot_fft:
+class plot_fft_base:
def __init__(self, datatype, filename, options):
self.hfile = open(filename, "r")
self.block_length = options.block
@@ -96,7 +96,7 @@ class gr_plot_fft:
def dofft(self, iq):
N = len(iq)
- iq_fft = fftpack.fftshift(scipy.fft(iq)) # fft and shift axis
+ iq_fft = scipy.fftpack.fftshift(scipy.fft(iq)) # fft and shift axis
iq_fft = 20*scipy.log10(abs((iq_fft+1e-15)/N)) # convert to decibels, adjust power
# adding 1e-15 (-300 dB) to protect against value errors if an item in iq_fft is 0
return iq_fft
@@ -206,37 +206,38 @@ class gr_plot_fft:
self.hfile.seek(-self.hfile.tell(),1)
self.get_data()
self.update_plots()
-
+
+ @staticmethod
+ def setup_options():
+ usage="%prog: [options] input_filename"
+ description = "Takes a GNU Radio complex binary file and displays the I&Q data versus time as well as the frequency domain (FFT) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. This value defaults to 1000. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
+
+ parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
+ parser.add_option("-d", "--data-type", type="string", default="complex64",
+ help="Specify the data type (complex64, float32, (u)int32, (u)int16, (u)int8) [default=%default]")
+ parser.add_option("-B", "--block", type="int", default=1000,
+ help="Specify the block size [default=%default]")
+ parser.add_option("-s", "--start", type="int", default=0,
+ help="Specify where to start in the file [default=%default]")
+ parser.add_option("-R", "--sample-rate", type="float", default=1.0,
+ help="Set the sampler rate of the data [default=%default]")
+ return parser
+
def find(item_in, list_search):
try:
return list_search.index(item_in) != None
except ValueError:
return False
-def setup_options():
- usage="%prog: [options] input_filename"
- description = "Takes a GNU Radio complex binary file and displays the I&Q data versus time as well as the frequency domain (FFT) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. This value defaults to 1000. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples."
-
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- parser.add_option("-d", "--data-type", type="string", default="complex64",
- help="Specify the data type (complex64, float32, (u)int32, (u)int16, (u)int8) [default=%default]")
- parser.add_option("-B", "--block", type="int", default=1000,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
- return parser
-
def main():
- parser = setup_options()
+ parser = plot_fft_base.setup_options()
(options, args) = parser.parse_args ()
if len(args) != 1:
parser.print_help()
raise SystemExit, 1
filename = args[0]
- dc = gr_plot_fft(options.data_type, filename, options)
+ dc = plot_fft_base(options.data_type, filename, options)
if __name__ == "__main__":
try:
diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/plot_psd_base.py
index 3dab0535a..78eed5f71 100755
--- a/gr-utils/src/python/gr_plot_psd.py
+++ b/gr-utils/src/python/plot_psd_base.py
@@ -37,7 +37,7 @@ from optparse import OptionParser
from scipy import log10
from gnuradio.eng_option import eng_option
-class gr_plot_psd:
+class plot_psd_base:
def __init__(self, datatype, filename, options):
self.hfile = open(filename, "r")
self.block_length = options.block
@@ -242,44 +242,45 @@ class gr_plot_psd:
if(r):
self.update_plots()
+ @staticmethod
+ def setup_options():
+ usage="%prog: [options] input_filename"
+ description = "Takes a GNU Radio binary file (with specified data type using --data-type) and displays the I&Q data versus time as well as the power spectral density (PSD) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples. Finally, the size of the FFT to use for the PSD and spectrogram plots can be set independently with --psd-size and --spec-size, respectively. The spectrogram plot does not display by default and is turned on with -S or --enable-spec."
+
+ parser = OptionParser(option_class=eng_option, conflict_handler="resolve",
+ usage=usage, description=description)
+ parser.add_option("-d", "--data-type", type="string", default="complex64",
+ help="Specify the data type (complex64, float32, (u)int32, (u)int16, (u)int8) [default=%default]")
+ parser.add_option("-B", "--block", type="int", default=8192,
+ help="Specify the block size [default=%default]")
+ parser.add_option("-s", "--start", type="int", default=0,
+ help="Specify where to start in the file [default=%default]")
+ parser.add_option("-R", "--sample-rate", type="eng_float", default=1.0,
+ help="Set the sampler rate of the data [default=%default]")
+ parser.add_option("", "--psd-size", type="int", default=1024,
+ help="Set the size of the PSD FFT [default=%default]")
+ parser.add_option("", "--spec-size", type="int", default=256,
+ help="Set the size of the spectrogram FFT [default=%default]")
+ parser.add_option("-S", "--enable-spec", action="store_true", default=False,
+ help="Turn on plotting the spectrogram [default=%default]")
+
+ return parser
+
def find(item_in, list_search):
try:
return list_search.index(item_in) != None
except ValueError:
return False
-def setup_options():
- usage="%prog: [options] input_filename"
- description = "Takes a GNU Radio binary file (with specified data type using --data-type) and displays the I&Q data versus time as well as the power spectral density (PSD) plot. The y-axis values are plotted assuming volts as the amplitude of the I&Q streams and converted into dBm in the frequency domain (the 1/N power adjustment out of the FFT is performed internally). The script plots a certain block of data at a time, specified on the command line as -B or --block. The start position in the file can be set by specifying -s or --start and defaults to 0 (the start of the file). By default, the system assumes a sample rate of 1, so in time, each sample is plotted versus the sample number. To set a true time and frequency axis, set the sample rate (-R or --sample-rate) to the sample rate used when capturing the samples. Finally, the size of the FFT to use for the PSD and spectrogram plots can be set independently with --psd-size and --spec-size, respectively. The spectrogram plot does not display by default and is turned on with -S or --enable-spec."
-
- parser = OptionParser(option_class=eng_option, conflict_handler="resolve",
- usage=usage, description=description)
- parser.add_option("-d", "--data-type", type="string", default="complex64",
- help="Specify the data type (complex64, float32, (u)int32, (u)int16, (u)int8) [default=%default]")
- parser.add_option("-B", "--block", type="int", default=8192,
- help="Specify the block size [default=%default]")
- parser.add_option("-s", "--start", type="int", default=0,
- help="Specify where to start in the file [default=%default]")
- parser.add_option("-R", "--sample-rate", type="eng_float", default=1.0,
- help="Set the sampler rate of the data [default=%default]")
- parser.add_option("", "--psd-size", type="int", default=1024,
- help="Set the size of the PSD FFT [default=%default]")
- parser.add_option("", "--spec-size", type="int", default=256,
- help="Set the size of the spectrogram FFT [default=%default]")
- parser.add_option("-S", "--enable-spec", action="store_true", default=False,
- help="Turn on plotting the spectrogram [default=%default]")
-
- return parser
-
def main():
- parser = setup_options()
+ parser = plot_psd_base.setup_options()
(options, args) = parser.parse_args ()
if len(args) != 1:
parser.print_help()
raise SystemExit, 1
filename = args[0]
- dc = gr_plot_psd(options.data_type, filename, options)
+ dc = plot_psd_base(options.data_type, filename, options)
if __name__ == "__main__":
try: