summaryrefslogtreecommitdiff
path: root/gr-utils/python/utils/gr_plot_const
diff options
context:
space:
mode:
Diffstat (limited to 'gr-utils/python/utils/gr_plot_const')
-rwxr-xr-xgr-utils/python/utils/gr_plot_const49
1 files changed, 22 insertions, 27 deletions
diff --git a/gr-utils/python/utils/gr_plot_const b/gr-utils/python/utils/gr_plot_const
index e2580dd58f..2ec54c3585 100755
--- a/gr-utils/python/utils/gr_plot_const
+++ b/gr-utils/python/utils/gr_plot_const
@@ -20,20 +20,22 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
import scipy
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from pylab import *
from matplotlib.font_manager import fontManager, FontProperties
except ImportError:
- print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)")
+ raise SystemExit(1)
-from optparse import OptionParser
+from argparse import ArgumentParser
class draw_constellation:
def __init__(self, filename, options):
@@ -83,7 +85,7 @@ class draw_constellation:
try:
iq = scipy.fromfile(self.hfile, dtype=self.datatype, count=self.block_length)
except MemoryError:
- print "End of File"
+ print("End of File")
else:
# retesting length here as newer version of scipy does not throw a MemoryError, just
# returns a zero-length array
@@ -94,7 +96,7 @@ class draw_constellation:
self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.reals))])
return True
else:
- print "End of File"
+ print("End of File")
return False
def make_plots(self):
@@ -215,36 +217,29 @@ class draw_constellation:
def find(item_in, list_search):
try:
- return list_search.index(item_in) != None
+ return list_search.index(item_in) != None
except ValueError:
- return False
+ return False
def main():
- usage="%prog: [options] input_filename"
description = "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."
- parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
- 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]")
-
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-B", "--block", type=int, default=1000,
+ help="Specify the block size [default=%(default)r]")
+ parser.add_argument("-s", "--start", type=int, default=0,
+ help="Specify where to start in the file [default=%(default)r]")
+ parser.add_argument("-R", "--sample-rate", type=float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE",
+ help="Input file with complex samples")
+ args = parser.parse_args()
- dc = draw_constellation(filename, options)
+ dc = draw_constellation(args.file, args)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
-
-
-