diff options
author | Brennan Ashton <bashton@brennanashton.com> | 2018-11-15 16:27:44 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-11-22 11:09:00 -0800 |
commit | 745b2b2d34cff22468ea9a4a785e82d3398dc4e6 (patch) | |
tree | ab34aaca154581a37c9d50c636a69cd10a6d7cf1 /gr-utils/python/utils/plot_data.py | |
parent | 2e8f3ad85e13045fcaf81368fb9372735c503e68 (diff) |
gr-utils: Condense gr_plot commands and fix datatype arg
This removes all the gr_plot_* applications save for:
- gr_plot (time-domain)
- gr_plot_fft (FFT domain)
- gr_plot_psd (Power Spectrum Density)
Diffstat (limited to 'gr-utils/python/utils/plot_data.py')
-rw-r--r-- | gr-utils/python/utils/plot_data.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/gr-utils/python/utils/plot_data.py b/gr-utils/python/utils/plot_data.py index dc9346c484..7eed7b5b6e 100644 --- a/gr-utils/python/utils/plot_data.py +++ b/gr-utils/python/utils/plot_data.py @@ -26,8 +26,28 @@ from __future__ import print_function from __future__ import division from __future__ import unicode_literals +from argparse import ArgumentParser + import numpy +try: + from pylab import Button, connect, draw, figure, figtext, get_current_fig_manager, show, plot, rcParams +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) + + +datatype_lookup = { + "complex64": numpy.complex64, + "float32": numpy.float32, + "uint32": numpy.uint32, + "int32": numpy.int32, + "uint16": numpy.uint16, + "int16": numpy.int16, + "uint8": numpy.uint8, + "int8": numpy.int8, +} + class plot_data(object): def __init__(self, datatype, filenames, options): self.hfile = list() @@ -41,7 +61,9 @@ class plot_data(object): self.sample_rate = options.sample_rate self.datatype = datatype - self.sizeof_data = datatype().nbytes # number of bytes per sample in file + if self.datatype is None: + self.datatype = datatype_lookup[options.data_type] + self.sizeof_data = self.datatype().nbytes # number of bytes per sample in file self.axis_font_size = 16 self.label_font_size = 18 @@ -152,6 +174,24 @@ class plot_data(object): hf.seek(-hf.tell(),1) self.update_plots() + @staticmethod + def setup_options(): + description = "Takes a GNU Radio 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 = 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("files", metavar="FILE", nargs='+', + help="Input file with samples") + return parser def find(item_in, list_search): try: |