summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Pinkava <j-pi@seznam.cz>2016-06-26 13:04:39 +0200
committerJiří Pinkava <j-pi@seznam.cz>2016-08-06 21:51:37 +0200
commit4d2809c9a46ec5676f2a08457609f559d910785f (patch)
tree3e19981d3e89729a61cc415b3a269c9eb209fd7d
parent675afc063c9ca5ccec3ede43d87aac83c1928182 (diff)
filter: replace OptionParser by ArgumentParser for gr-utils and gr-qtgui
-rwxr-xr-xgr-filter/examples/benchmark_filters.py32
-rwxr-xr-xgr-qtgui/apps/gr_constellation_plot31
-rwxr-xr-xgr-qtgui/apps/gr_psd_plot_b15
-rwxr-xr-xgr-qtgui/apps/gr_psd_plot_c15
-rwxr-xr-xgr-qtgui/apps/gr_psd_plot_f15
-rwxr-xr-xgr-qtgui/apps/gr_psd_plot_i15
-rwxr-xr-xgr-qtgui/apps/gr_psd_plot_s15
-rwxr-xr-xgr-qtgui/apps/gr_spectrogram_plot57
-rwxr-xr-xgr-qtgui/apps/gr_spectrogram_plot_b15
-rwxr-xr-xgr-qtgui/apps/gr_spectrogram_plot_c15
-rwxr-xr-xgr-qtgui/apps/gr_spectrogram_plot_f15
-rwxr-xr-xgr-qtgui/apps/gr_spectrogram_plot_i15
-rwxr-xr-xgr-qtgui/apps/gr_spectrogram_plot_s15
-rwxr-xr-xgr-qtgui/apps/gr_time_plot_b11
-rwxr-xr-xgr-qtgui/apps/gr_time_plot_c11
-rwxr-xr-xgr-qtgui/apps/gr_time_plot_f11
-rwxr-xr-xgr-qtgui/apps/gr_time_plot_i11
-rwxr-xr-xgr-qtgui/apps/gr_time_plot_s11
-rwxr-xr-xgr-qtgui/apps/gr_time_raster_b13
-rwxr-xr-xgr-qtgui/apps/gr_time_raster_f13
-rw-r--r--gr-qtgui/apps/plot_psd_base.py40
-rw-r--r--gr-qtgui/apps/plot_spectrogram_base.py43
-rw-r--r--gr-qtgui/apps/plot_time_base.py33
-rw-r--r--gr-qtgui/apps/plot_time_raster_base.py41
-rw-r--r--gr-utils/python/utils/gr_plot_fft8
-rwxr-xr-xgr-utils/python/utils/gr_plot_fft_c11
-rwxr-xr-xgr-utils/python/utils/gr_plot_fft_f12
-rwxr-xr-xgr-utils/python/utils/gr_plot_float27
-rwxr-xr-xgr-utils/python/utils/gr_plot_int27
-rwxr-xr-xgr-utils/python/utils/gr_plot_iq31
-rw-r--r--gr-utils/python/utils/gr_plot_psd8
-rwxr-xr-xgr-utils/python/utils/gr_plot_psd_c13
-rwxr-xr-xgr-utils/python/utils/gr_plot_psd_f13
-rwxr-xr-xgr-utils/python/utils/gr_plot_short27
-rwxr-xr-xgr-utils/python/utils/plot_fft_base.py33
-rwxr-xr-xgr-utils/python/utils/plot_psd_base.py48
36 files changed, 346 insertions, 420 deletions
diff --git a/gr-filter/examples/benchmark_filters.py b/gr-filter/examples/benchmark_filters.py
index 18380a7a34..4da6b9f5ad 100755
--- a/gr-filter/examples/benchmark_filters.py
+++ b/gr-filter/examples/benchmark_filters.py
@@ -22,10 +22,10 @@
import time
import random
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio import gr
from gnuradio import blocks, filter
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_float, intx
def make_random_complex_tuple(L):
result = []
@@ -52,25 +52,17 @@ def benchmark(name, creator, dec, ntaps, total_test_size, block_size):
name, ntaps, total_test_size, delta, ntaps*total_test_size/delta)
def main():
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-n", "--ntaps", type="int", default=256)
- parser.add_option("-t", "--total-input-size", type="eng_float", default=40e6)
- parser.add_option("-b", "--block-size", type="intx", default=50000)
- parser.add_option("-d", "--decimation", type="int", default=1)
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
+ parser = ArgumentParser()
+ parser.add_argument("-n", "--ntaps", type=int, default=256)
+ parser.add_argument("-t", "--total-input-size", type=eng_float, default=40e6)
+ parser.add_argument("-b", "--block-size", type=intx, default=50000)
+ parser.add_argument("-d", "--decimation", type=int, default=1)
+ args = parser.parse_args()
- ntaps = options.ntaps
- total_input_size = options.total_input_size
- block_size = options.block_size
- dec = options.decimation
-
- benchmark("filter.fir_filter_ccc", filter.fir_filter_ccc,
- dec, ntaps, total_input_size, block_size)
- benchmark("filter.fft_filter_ccc", filter.fft_filter_ccc,
- dec, ntaps, total_input_size, block_size)
+ benchmark("filter.fir_filter_ccc", filter.fir_filter_ccc, args.decimation,
+ args.ntaps, args.total_input_size, args.block_size)
+ benchmark("filter.fft_filter_ccc", filter.fft_filter_ccc, args.decimation,
+ args.ntaps, args.total_input_size, args.block_size)
if __name__ == '__main__':
main()
diff --git a/gr-qtgui/apps/gr_constellation_plot b/gr-qtgui/apps/gr_constellation_plot
index 528bb97e5a..ff5db1a9a6 100755
--- a/gr-qtgui/apps/gr_constellation_plot
+++ b/gr-qtgui/apps/gr_constellation_plot
@@ -22,8 +22,8 @@
from gnuradio import gr
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import os, sys
try:
@@ -143,32 +143,27 @@ class my_top_block(gr.top_block):
def main():
description = "Plots the constellations of a list of files."
- parser = OptionParser(option_class=eng_option, description=description,
+ parser = ArgumentParser(description=description,
conflict_handler="resolve")
- parser.add_option("-N", "--nsamples", type="int", default=1000000,
- help="Set the number of samples to display [default=%default]")
- parser.add_option("-S", "--start", type="int", default=0,
- help="Starting sample number [default=%default]")
- (options, args) = parser.parse_args()
+ parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+ help="Set the number of samples to display [default=%(default)r]")
+ parser.add_argument("-S", "--start", type=int, default=0,
+ help="Starting sample number [default=%(default)r]")
+ parser.add_argument("files", nargs="+", metavar='FILE')
+ args = parser.parse_args()
- if(len(args) < 1):
- parser.print_help()
- sys.exit(0)
-
- filelist = list(args)
-
- nsamples = options.nsamples
+ filelist = args.files
+ nsamples = args.nsamples
# Find the smallest number of samples in all files and use that as
# a maximum value possible.
filesizes = []
for f in filelist:
if(os.path.exists(f)):
- filesizes.append(os.path.getsize(f) / gr.sizeof_gr_complex)
+ filesizes.append(os.path.getsize(f) // gr.sizeof_gr_complex)
max_nsamples = min(filesizes)
- tb = my_top_block(filelist,
- options.start, nsamples, max_nsamples);
+ tb = my_top_block(filelist, args.start, nsamples, max_nsamples);
main_box = plot_constellation_form(tb, 'GNU Radio Constellation Plot', 10000.0)
for n in xrange(tb._nsigs):
diff --git a/gr-qtgui/apps/gr_psd_plot_b b/gr-qtgui/apps/gr_psd_plot_b
index 606311af48..26263112ca 100755
--- a/gr-qtgui/apps/gr_psd_plot_b
+++ b/gr-qtgui/apps/gr_psd_plot_b
@@ -54,16 +54,15 @@ class psd_plot_b(plot_base.plot_base):
def main():
description = "Plots the PSDs of a list of files. Files are a binary list of bytes."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = psd_plot_b(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average)
+ tb = psd_plot_b(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average)
main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_c b/gr-qtgui/apps/gr_psd_plot_c
index 6df9fae190..1bd847b607 100755
--- a/gr-qtgui/apps/gr_psd_plot_c
+++ b/gr-qtgui/apps/gr_psd_plot_c
@@ -55,16 +55,15 @@ class psd_plot_c(plot_base.plot_base):
def main():
description = "Plots the PSDs of a list of files. Files are a binary list of complex floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = psd_plot_c(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average)
+ tb = psd_plot_c(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average)
main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_f b/gr-qtgui/apps/gr_psd_plot_f
index f07e3e8b50..04f1b03486 100755
--- a/gr-qtgui/apps/gr_psd_plot_f
+++ b/gr-qtgui/apps/gr_psd_plot_f
@@ -55,16 +55,15 @@ class psd_plot_f(plot_base.plot_base):
def main():
description = "Plots the PSDs of a list of files. Files are a binary list of floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = psd_plot_f(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average)
+ tb = psd_plot_f(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average)
main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_i b/gr-qtgui/apps/gr_psd_plot_i
index 1852345823..46bdd7bc84 100755
--- a/gr-qtgui/apps/gr_psd_plot_i
+++ b/gr-qtgui/apps/gr_psd_plot_i
@@ -54,16 +54,15 @@ class psd_plot_i(plot_base.plot_base):
def main():
description = "Plots the PSDs of a list of files. Files are a binary list of integers."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = psd_plot_i(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average)
+ tb = psd_plot_i(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average)
main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_psd_plot_s b/gr-qtgui/apps/gr_psd_plot_s
index c06076f1f9..8dc4a05d55 100755
--- a/gr-qtgui/apps/gr_psd_plot_s
+++ b/gr-qtgui/apps/gr_psd_plot_s
@@ -54,16 +54,15 @@ class psd_plot_s(plot_base.plot_base):
def main():
description = "Plots the PSDs of a list of files. Files are a binary list of shorts."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = psd_plot_s(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average)
+ tb = psd_plot_s(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average)
main_box = plot_base.plot_psd_form(tb, 'GNU Radio PSD Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot b/gr-qtgui/apps/gr_spectrogram_plot
index db79f9dbad..8e8ba86757 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot
+++ b/gr-qtgui/apps/gr_spectrogram_plot
@@ -142,55 +142,54 @@ def read_header(filelist):
def main():
description = 'Plots the spectrogram (waterfall) of a file with detached header.'
description += ' Assumes header is <input_filename>.hdr'
- (options, args) = plot_base.setup_options(description)
- filelist = list(args)
+ args = plot_base.setup_options(description)
# Attempt to read the header information
- info = read_header(filelist)
+ info = read_header(args.files)
# If no header, quit
if not info:
sys.stderr.write('Header not found\n')
sys.exit(1)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
srate = info["rx_rate"]
# Dispatch the proper function
# Complex Types
if(info["cplx"] == True):
if( info["type"] == "float" ):
- tb = spectrogram_plot_c(filelist,
- options.center_frequency,srate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_c(args.files,
+ args.center_frequency,srate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
else:
sys.stderr.write("Complex File Type " + info["type"]+ " not supported.\n")
# Real Types
else:
if( info["type"] == "bytes" ):
- tb = spectrogram_plot_b(filelist,
- options.center_frequency,srate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_b(args.files,
+ args.center_frequency,srate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
elif( info["type"] == "int" ):
- tb = spectrogram_plot_i(filelist,
- options.center_frequency,srate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_i(args.files,
+ args.center_frequency,srate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
elif( info["type"] == "float" ):
- tb = spectrogram_plot_f(filelist,
- options.center_frequency,srate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_f(args.files,
+ args.center_frequency,srate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
elif( info["type"] == "short" ):
- tb = spectrogram_plot_s(filelist,
- options.center_frequency,srate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_s(args.files,
+ args.center_frequency,srate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
else:
sys.stderr.write("Real File Type " + info["type"] + " not supported\n")
main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Spectrogram Plot')
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_b b/gr-qtgui/apps/gr_spectrogram_plot_b
index 0d7a16ea6e..6045ebfadd 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_b
+++ b/gr-qtgui/apps/gr_spectrogram_plot_b
@@ -54,16 +54,15 @@ class spectrogram_plot_b(plot_base.plot_base):
def main():
description = "Plots the spectrogram (waterfall) of a list of files. Files are a binary list of chars."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = spectrogram_plot_b(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_b(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_c b/gr-qtgui/apps/gr_spectrogram_plot_c
index 52b0d4dff7..a2e63d0113 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_c
+++ b/gr-qtgui/apps/gr_spectrogram_plot_c
@@ -55,16 +55,15 @@ class spectrogram_plot_c(plot_base.plot_base):
def main():
description = "Plots the spectrogram (waterfall) of a list of files. Files are a binary list of complex floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = spectrogram_plot_c(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_c(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Spectrogram Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_f b/gr-qtgui/apps/gr_spectrogram_plot_f
index 6ea5afc4ef..d131747486 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_f
+++ b/gr-qtgui/apps/gr_spectrogram_plot_f
@@ -55,16 +55,15 @@ class spectrogram_plot_f(plot_base.plot_base):
def main():
description = "Plots the spectrogram (waterfall) of a list of files. Files are a binary list of floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = spectrogram_plot_f(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_f(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_i b/gr-qtgui/apps/gr_spectrogram_plot_i
index 893df2a234..723291d4b4 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_i
+++ b/gr-qtgui/apps/gr_spectrogram_plot_i
@@ -54,16 +54,15 @@ class spectrogram_plot_i(plot_base.plot_base):
def main():
description = "Plots the spectrogram (waterfall) of a list of files. Files are a binary list of ints."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = spectrogram_plot_i(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_i(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_spectrogram_plot_s b/gr-qtgui/apps/gr_spectrogram_plot_s
index 82a22f740d..606fbf95e4 100755
--- a/gr-qtgui/apps/gr_spectrogram_plot_s
+++ b/gr-qtgui/apps/gr_spectrogram_plot_s
@@ -54,16 +54,15 @@ class spectrogram_plot_s(plot_base.plot_base):
def main():
description = "Plots the spectrogram (waterfall) of a list of files. Files are a binary list of shorts."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = spectrogram_plot_s(filelist,
- options.center_frequency, options.sample_rate,
- options.psd_size,
- options.start, options.nsamples, max_nsamples,
- options.average);
+ tb = spectrogram_plot_s(args.files,
+ args.center_frequency, args.sample_rate,
+ args.psd_size,
+ args.start, args.nsamples, max_nsamples,
+ args.average);
main_box = plot_base.plot_spectrogram_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_b b/gr-qtgui/apps/gr_time_plot_b
index d822557f1b..a2f63cc4bf 100755
--- a/gr-qtgui/apps/gr_time_plot_b
+++ b/gr-qtgui/apps/gr_time_plot_b
@@ -52,14 +52,13 @@ class plot_time_b(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of chars."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_b(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- not options.no_auto_scale)
+ tb = plot_time_b(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_c b/gr-qtgui/apps/gr_time_plot_c
index 202e0f88f4..3dfccad804 100755
--- a/gr-qtgui/apps/gr_time_plot_c
+++ b/gr-qtgui/apps/gr_time_plot_c
@@ -54,14 +54,13 @@ class plot_time_c(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of complex floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_c(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- not options.no_auto_scale)
+ tb = plot_time_c(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot', 10000.0)
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_f b/gr-qtgui/apps/gr_time_plot_f
index 8f5ad9f60d..59b340de9e 100755
--- a/gr-qtgui/apps/gr_time_plot_f
+++ b/gr-qtgui/apps/gr_time_plot_f
@@ -53,14 +53,13 @@ class plot_time_f(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_f(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- not options.no_auto_scale)
+ tb = plot_time_f(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot', 10000.0)
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_i b/gr-qtgui/apps/gr_time_plot_i
index 8a7888b451..66c0a7f9cf 100755
--- a/gr-qtgui/apps/gr_time_plot_i
+++ b/gr-qtgui/apps/gr_time_plot_i
@@ -52,14 +52,13 @@ class plot_time_i(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of integers."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_i(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- not options.no_auto_scale)
+ tb = plot_time_i(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_plot_s b/gr-qtgui/apps/gr_time_plot_s
index 7cee262379..b2e42320db 100755
--- a/gr-qtgui/apps/gr_time_plot_s
+++ b/gr-qtgui/apps/gr_time_plot_s
@@ -52,14 +52,13 @@ class plot_time_s(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of shorts."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_s(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- not options.no_auto_scale)
+ tb = plot_time_s(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_raster_b b/gr-qtgui/apps/gr_time_raster_b
index ad8691489c..6cd93b0965 100755
--- a/gr-qtgui/apps/gr_time_raster_b
+++ b/gr-qtgui/apps/gr_time_raster_b
@@ -56,15 +56,14 @@ class plot_time_raster_b(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of chars."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_raster_b(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- options.nrows, options.ncols,
- not options.no_auto_scale)
+ tb = plot_time_raster_b(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ args.nrows, args.ncols,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_raster_form(tb, 'GNU Radio Time Plot')
main_box.show()
diff --git a/gr-qtgui/apps/gr_time_raster_f b/gr-qtgui/apps/gr_time_raster_f
index 5d6a8389cf..944d739978 100755
--- a/gr-qtgui/apps/gr_time_raster_f
+++ b/gr-qtgui/apps/gr_time_raster_f
@@ -56,15 +56,14 @@ class plot_time_raster_f(plot_base.plot_base):
def main():
description = "Plots a list of files on a scope plot. Files are a binary list of floats."
- (options, args) = plot_base.setup_options(description)
+ args = plot_base.setup_options(description)
- filelist = list(args)
- max_nsamples = plot_base.find_max_nsamples(filelist)
+ max_nsamples = plot_base.find_max_nsamples(args.files)
- tb = plot_time_raster_f(filelist, options.sample_rate,
- options.start, options.nsamples, max_nsamples,
- options.nrows, options.ncols,
- not options.no_auto_scale)
+ tb = plot_time_raster_f(args.files, args.sample_rate,
+ args.start, args.nsamples, max_nsamples,
+ args.nrows, args.ncols,
+ not args.no_auto_scale)
main_box = plot_base.plot_time_raster_form(tb, 'GNU Radio Time Plot', 10000.0)
main_box.show()
diff --git a/gr-qtgui/apps/plot_psd_base.py b/gr-qtgui/apps/plot_psd_base.py
index 46f903e1b5..c3c03ec977 100644
--- a/gr-qtgui/apps/plot_psd_base.py
+++ b/gr-qtgui/apps/plot_psd_base.py
@@ -21,8 +21,8 @@
#
from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import os, sys
try:
@@ -141,23 +141,21 @@ class plot_base(gr.top_block):
self.start()
def setup_options(desc):
- parser = OptionParser(option_class=eng_option, description=desc,
- conflict_handler="resolve")
- parser.add_option("-N", "--nsamples", type="int", default=1000000,
+ parser = ArgumentParser(description=desc, conflict_handler="resolve")
+ parser.add_argument("-N", "--nsamples", type=int, default=1000000,
help="Set the number of samples to display [default=prints entire file]")
- parser.add_option("-S", "--start", type="int", default=0,
- help="Starting sample number [default=%default]")
- parser.add_option("-L", "--psd-size", type="int", default=2048,
- help="Set the FFT size of the PSD [default=%default]")
- parser.add_option("-f", "--center-frequency", type="eng_float", default=0.0,
- help="Set the center frequency of the signal [default=%default]")
- parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
- help="Set the sample rate of the signal [default=%default]")
- parser.add_option("-a", "--average", type="float", default=1.0,
- help="Set amount of averaging (smaller=more averaging) [default=%default]")
- (options, args) = parser.parse_args()
-
- if(len(args) < 1):
- parser.print_help()
- sys.exit(0)
- return (options,args)
+ parser.add_argument("-S", "--start", type=int, default=0,
+ help="Starting sample number [default=%(default)r]")
+ parser.add_argument("-L", "--psd-size", type=int, default=2048,
+ help="Set the FFT size of the PSD [default=%(default)r]")
+ parser.add_argument("-f", "--center-frequency", type=eng_float, default=0.0,
+ help="Set the center frequency of the signal [default=%(default)r]")
+ parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+ help="Set the sample rate of the signal [default=%(default)r]")
+ parser.add_argument("-a", "--average", type=float, default=1.0,
+ help="Set amount of averaging (smaller=more averaging) [default=%(default)r]")
+ parser.add_argument("files", nargs='+', metavar='FILE',
+ help="Complex samples")
+ args = parser.parse_args()
+
+ return args
diff --git a/gr-qtgui/apps/plot_spectrogram_base.py b/gr-qtgui/apps/plot_spectrogram_base.py
index b252bb8863..f568100719 100644
--- a/gr-qtgui/apps/plot_spectrogram_base.py
+++ b/gr-qtgui/apps/plot_spectrogram_base.py
@@ -21,8 +21,8 @@
#
from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import os, sys
try:
@@ -146,25 +146,22 @@ class plot_base(gr.top_block):
self.start()
def setup_options(desc):
- parser = OptionParser(option_class=eng_option, description=desc,
- conflict_handler="resolve")
- parser.add_option("-N", "--nsamples", type="int", default=1000000,
- help="Set the number of samples to display [default=%default]")
- parser.add_option("-S", "--start", type="int", default=0,
- help="Starting sample number [default=%default]")
- parser.add_option("-L", "--psd-size", type="int", default=2048,
- help="Set the FFT size of the PSD [default=%default]")
- parser.add_option("-f", "--center-frequency", type="eng_float", default=0.0,
- help="Set the center frequency of the signal [default=%default]")
- parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
- help="Set the sample rate of the signal [default=%default]")
- parser.add_option("-a", "--average", type="float", default=1.0,
- help="Set amount of averaging (smaller=more averaging) [default=%default]")
- (options, args) = parser.parse_args()
-
- if(len(args) < 1):
- parser.print_help()
- sys.exit(0)
-
- return (options, args)
+ parser = ArgumentParser(description=desc, conflict_handler="resolve")
+ parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+ help="Set the number of samples to display [default=%(default)r]")
+ parser.add_argument("-S", "--start", type=int, default=0,
+ help="Starting sample number [default=%(default)r]")
+ parser.add_argument("-L", "--psd-size", type=int, default=2048,
+ help="Set the FFT size of the PSD [default=%(default)r]")
+ parser.add_argument("-f", "--center-frequency", type=eng_float, default=0.0,
+ help="Set the center frequency of the signal [default=%(default)r]")
+ parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+ help="Set the sample rate of the signal [default=%(default)r]")
+ parser.add_argument("-a", "--average", type=float, default=1.0,
+ help="Set amount of averaging (smaller=more averaging) [default=%(default)r]")
+ parser.add_argument('files', nargs='+', metavar='FILE',
+ help="File with complex samples")
+ args = parser.parse_args()
+
+ return args
diff --git a/gr-qtgui/apps/plot_time_base.py b/gr-qtgui/apps/plot_time_base.py
index 007c94d044..cfbe5dc6cb 100644
--- a/gr-qtgui/apps/plot_time_base.py
+++ b/gr-qtgui/apps/plot_time_base.py
@@ -21,8 +21,8 @@
#
from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import os, sys
try:
@@ -166,19 +166,18 @@ class plot_base(gr.top_block):
self._auto_scale = False
def setup_options(desc):
- parser = OptionParser(option_class=eng_option, description=desc,
- conflict_handler="resolve")
- parser.add_option("-N", "--nsamples", type="int", default=1000000,
- help="Set the number of samples to display [default=%default]")
- parser.add_option("-S", "--start", type="int", default=0,
- help="Starting sample number [default=%default]")
- parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
- help="Set the sample rate of the signal [default=%default]")
- parser.add_option("", "--no-auto-scale", action="store_true", default=False,
- help="Do not auto-scale the plot [default=%default]")
- (options,args) = parser.parse_args()
- if(len(args) < 1):
- parser.print_help()
- sys.exit(0)
- return (options,args)
+ parser = ArgumentParser(description=desc, conflict_handler="resolve")
+ parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+ help="Set the number of samples to display [default=%(default)r]")
+ parser.add_argument("-S", "--start", type=int, default=0,
+ help="Starting sample number [default=%(default)r]")
+ parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+ help="Set the sample rate of the signal [default=%(default)r]")
+ parser.add_argument("--no-auto-scale", action="store_true",
+ help="Do not auto-scale the plot [default=%(default)r]")
+ parser.add_argument("files", nargs='+', metavar="FILE",
+ help="File with complex samples")
+ args = parser.parse_args()
+
+ return args
diff --git a/gr-qtgui/apps/plot_time_raster_base.py b/gr-qtgui/apps/plot_time_raster_base.py
index 856c8c8945..e84b84c295 100644
--- a/gr-qtgui/apps/plot_time_raster_base.py
+++ b/gr-qtgui/apps/plot_time_raster_base.py
@@ -21,8 +21,8 @@
#
from gnuradio import gr, blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import os, sys
try:
@@ -161,23 +161,22 @@ class plot_base(gr.top_block):
self._auto_scale = False
def setup_options(desc):
- parser = OptionParser(option_class=eng_option, description=desc,
- conflict_handler="resolve")
- parser.add_option("-N", "--nsamples", type="int", default=1000000,
- help="Set the number of samples to display [default=%default]")
- parser.add_option("-S", "--start", type="int", default=0,
- help="Starting sample number [default=%default]")
- parser.add_option("-C", "--ncols", type="int", default=100,
- help="Number of columns [default=%default]")
- parser.add_option("-R", "--nrows", type="int", default=100,
- help="Number of rows [default=%default]")
- parser.add_option("-r", "--sample-rate", type="eng_float", default=1.0,
- help="Set the sample rate of the signal [default=%default]")
- parser.add_option("", "--no-auto-scale", action="store_true", default=False,
- help="Do not auto-scale the plot [default=%default]")
- (options,args) = parser.parse_args()
- if(len(args) < 1):
- parser.print_help()
- sys.exit(0)
- return (options,args)
+ parser = ArgumentParser(description=desc, conflict_handler="resolve")
+ parser.add_argument("-N", "--nsamples", type=int, default=1000000,
+ help="Set the number of samples to display [default=%(default)r]")
+ parser.add_argument("-S", "--start", type=int, default=0,
+ help="Starting sample number [default=%(default)r]")
+ parser.add_argument("-C", "--ncols", type=int, default=100,
+ help="Number of columns [default=%(default)r]")
+ parser.add_argument("-R", "--nrows", type=int, default=100,
+ help="Number of rows [default=%(default)r]")
+ parser.add_argument("-r", "--sample-rate", type=eng_float, default=1.0,
+ help="Set the sample rate of the signal [default=%(default)r]")
+ parser.add_argument("--no-auto-scale", action="store_true",
+ help="Do not auto-scale the plot [default=%(default)r]")
+ parser.add_argument("files", nargs="+", metavar="FILE",
+ help="Input files with complex samples")
+ args = parser.parse_args()
+
+ return args
diff --git a/gr-utils/python/utils/gr_plot_fft b/gr-utils/python/utils/gr_plot_fft
index 4343481645..59fc88b994 100644
--- a/gr-utils/python/utils/gr_plot_fft
+++ b/gr-utils/python/utils/gr_plot_fft
@@ -27,13 +27,9 @@ from gnuradio.plot_fft_base import plot_fft_base
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]
+ args = parser.parse_args()
- dc = plot_fft_base(options.data_type, filename, options)
+ dc = plot_fft_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_fft_c b/gr-utils/python/utils/gr_plot_fft_c
index 43e808d95a..48d3218586 100755
--- a/gr-utils/python/utils/gr_plot_fft_c
+++ b/gr-utils/python/utils/gr_plot_fft_c
@@ -26,15 +26,12 @@ from gnuradio.plot_fft_base import plot_fft_base
def main():
parser = plot_fft_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", ))
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_fft_base("complex64", filename, options)
+ dc = plot_fft_base("complex64", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_fft_f b/gr-utils/python/utils/gr_plot_fft_f
index dee9b17dea..d1791419bb 100755
--- a/gr-utils/python/utils/gr_plot_fft_f
+++ b/gr-utils/python/utils/gr_plot_fft_f
@@ -26,15 +26,11 @@ from gnuradio.plot_fft_base import plot_fft_base
def main():
parser = plot_fft_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="float32",
+ choices=("float32", ))
+ args = parser.parse_args()
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
-
- dc = plot_fft_base("float32", filename, options)
+ dc = plot_fft_base("float32", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_float b/gr-utils/python/utils/gr_plot_float
index 22806e48ae..faf8106d70 100755
--- a/gr-utils/python/utils/gr_plot_float
+++ b/gr-utils/python/utils/gr_plot_float
@@ -26,29 +26,26 @@ except ImportError:
print "Please install SciPy to run this script (http://www.scipy.org/)"
raise SystemExit, 1
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "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."
- 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]")
+ 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", nargs='+',
+ help="Input file with samples")
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
+ args = parser.parse_args()
datatype=scipy.float32
- dc = plot_data(datatype, filenames, options)
+ dc = plot_data(datatype, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_int b/gr-utils/python/utils/gr_plot_int
index 355ddf0189..c687f13b17 100755
--- a/gr-utils/python/utils/gr_plot_int
+++ b/gr-utils/python/utils/gr_plot_int
@@ -26,29 +26,26 @@ except ImportError:
print "Please install SciPy to run this script (http://www.scipy.org/)"
raise SystemExit, 1
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "Takes a GNU Radio integer 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."
- 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]")
+ 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", nargs='+',
+ help="Input file");
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
+ args = parser.parse_args()
datatype=scipy.int32
- dc = plot_data(datatype, filenames, options)
+ dc = plot_data(datatype, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_iq b/gr-utils/python/utils/gr_plot_iq
index bf8077b6b4..7409b73909 100755
--- a/gr-utils/python/utils/gr_plot_iq
+++ b/gr-utils/python/utils/gr_plot_iq
@@ -32,7 +32,7 @@ except ImportError:
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_iq:
def __init__(self, filename, options):
@@ -149,24 +149,21 @@ def find(item_in, list_search):
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. 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]
-
- dc = draw_iq(filename, options)
+ 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_iq(args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_psd b/gr-utils/python/utils/gr_plot_psd
index 059ca6b645..b052cbfdd7 100644
--- a/gr-utils/python/utils/gr_plot_psd
+++ b/gr-utils/python/utils/gr_plot_psd
@@ -27,13 +27,9 @@ from gnuradio.plot_psd_base import plot_psd_base
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]
+ args = parser.parse_args()
- dc = plot_psd_base(options.data_type, filename, options)
+ dc = plot_psd_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_psd_c b/gr-utils/python/utils/gr_plot_psd_c
index fff2bff0f2..352a838138 100755
--- a/gr-utils/python/utils/gr_plot_psd_c
+++ b/gr-utils/python/utils/gr_plot_psd_c
@@ -20,22 +20,19 @@
# Boston, MA 02110-1301, USA.
#
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_psd_base import plot_psd_base
# This is a wrapper program for plot_psd_base specifically for complex data
def main():
parser = plot_psd_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", ))
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_psd_base("complex64", filename, options)
+ dc = plot_psd_base("complex64", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_psd_f b/gr-utils/python/utils/gr_plot_psd_f
index ec67994797..ab860e3fb8 100755
--- a/gr-utils/python/utils/gr_plot_psd_f
+++ b/gr-utils/python/utils/gr_plot_psd_f
@@ -20,22 +20,19 @@
# Boston, MA 02110-1301, USA.
#
-from optparse import OptionParser
+from argparse import ArgumentParser
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 = plot_psd_base.setup_options()
- parser.remove_option("--data-type")
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("float32", ))
- (options, args) = parser.parse_args ()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
- filename = args[0]
+ args = parser.parse_args()
- dc = plot_psd_base("float32", filename, options)
+ dc = plot_psd_base("float32", args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/gr_plot_short b/gr-utils/python/utils/gr_plot_short
index 702a2a94a6..f900af1bac 100755
--- a/gr-utils/python/utils/gr_plot_short
+++ b/gr-utils/python/utils/gr_plot_short
@@ -26,29 +26,26 @@ except ImportError:
print "Please install SciPy to run this script (http://www.scipy.org/)"
raise SystemExit, 1
-from optparse import OptionParser
+from argparse import ArgumentParser
from gnuradio.plot_data import plot_data
def main():
- usage="%prog: [options] input_filenames"
description = "Takes a GNU Radio short integer 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."
- 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]")
+ 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("files", metavar="FILE", nargs="+",
+ help="Input file with data (int16_t)")
- (options, args) = parser.parse_args ()
- if len(args) < 1:
- parser.print_help()
- raise SystemExit, 1
- filenames = args
+ args = parser.parse_args()
datatype=scipy.int16
- dc = plot_data(datatype, filenames, options)
+ dc = plot_data(datatype, args.files, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/plot_fft_base.py b/gr-utils/python/utils/plot_fft_base.py
index c4bc484d97..c99462147d 100755
--- a/gr-utils/python/utils/plot_fft_base.py
+++ b/gr-utils/python/utils/plot_fft_base.py
@@ -33,7 +33,7 @@ except ImportError:
print "Please install Python Matplotlib (http://matplotlib.sourceforge.net/) and Python TkInter https://wiki.python.org/moin/TkInter to run this script"
raise SystemExit, 1
-from optparse import OptionParser
+from argparse import ArgumentParser
class plot_fft_base:
def __init__(self, datatype, filename, options):
@@ -209,18 +209,21 @@ class plot_fft_base:
@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]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", "float32", "uint32", "int32", "uint16",
+ "int16", "uint8", "int8"),
+ help="Specify the data type [default=%(default)r]")
+ 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 samples")
return parser
def find(item_in, list_search):
@@ -231,13 +234,9 @@ def find(item_in, list_search):
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]
+ args = parser.parse_args()
- dc = plot_fft_base(options.data_type, filename, options)
+ dc = plot_fft_base(args.data_type, args.file, args)
if __name__ == "__main__":
try:
diff --git a/gr-utils/python/utils/plot_psd_base.py b/gr-utils/python/utils/plot_psd_base.py
index fe3c9e12b7..2611ed4be2 100755
--- a/gr-utils/python/utils/plot_psd_base.py
+++ b/gr-utils/python/utils/plot_psd_base.py
@@ -33,9 +33,9 @@ except ImportError:
print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)"
raise SystemExit, 1
-from optparse import OptionParser
+from argparse import ArgumentParser
from scipy import log10
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_float, intx
class plot_psd_base:
def __init__(self, datatype, filename, options):
@@ -244,25 +244,27 @@ class plot_psd_base:
@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]")
+ parser = ArgumentParser(conflict_handler="resolve", description=description)
+ parser.add_argument("-d", "--data-type", default="complex64",
+ choices=("complex64", "float32", "int32", "uint32", "int16",
+ "uint16", "int8", "uint8" ),
+ help="Specify the data type [default=%(default)r]")
+ parser.add_argument("-B", "--block", type=int, default=8192,
+ 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=eng_float, default=1.0,
+ help="Set the sampler rate of the data [default=%(default)r]")
+ parser.add_argument("--psd-size", type=int, default=1024,
+ help="Set the size of the PSD FFT [default=%(default)r]")
+ parser.add_argument("--spec-size", type=int, default=256,
+ help="Set the size of the spectrogram FFT [default=%(default)r]")
+ parser.add_argument("-S", "--enable-spec", action="store_true",
+ help="Turn on plotting the spectrogram [default=%(default)r]")
+ parser.add_argument("file", metavar="FILE",
+ help="Input file with samples")
return parser
@@ -274,13 +276,9 @@ def find(item_in, list_search):
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]
+ args = parser.parse_args()
- dc = plot_psd_base(options.data_type, filename, options)
+ dc = plot_psd_base(args.data_type, args.file, args)
if __name__ == "__main__":
try: