summaryrefslogtreecommitdiff
path: root/gr-qtgui/apps/gr_constellation_plot
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/apps/gr_constellation_plot')
-rwxr-xr-xgr-qtgui/apps/gr_constellation_plot176
1 files changed, 0 insertions, 176 deletions
diff --git a/gr-qtgui/apps/gr_constellation_plot b/gr-qtgui/apps/gr_constellation_plot
deleted file mode 100755
index 2785cac534..0000000000
--- a/gr-qtgui/apps/gr_constellation_plot
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/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 __future__ import print_function
-
-from gnuradio import gr
-from gnuradio import blocks
-from gnuradio.eng_arg import eng_float, intx
-from argparse import ArgumentParser
-import os, sys
-
-try:
- from gnuradio import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print("Error: Program requires PyQt4 and gr-qtgui.")
- sys.exit(1)
-
-try:
- from gnuradio.qtgui.plot_constellation_form import *
- from gnuradio.qtgui.plot_base import *
-except ImportError:
- from plot_constellation_form import *
- from plot_base import *
-
-class my_top_block(gr.top_block):
- def __init__(self, filelist, start, nsamples, max_nsamples):
- gr.top_block.__init__(self)
-
- self._filelist = filelist
- self._samp_rate = 0
- self._center_freq = 0
- self._start = start
- self._max_nsamps = max_nsamples
- self._nsigs = len(self._filelist)
- self._nsamps = nsamples
- self._auto_scale = True
-
- self._y_min = -20
- self._y_max = 20
- self._y_range = 4
- self._y_value = 2
- self.gui_y_axis = None
-
- self.qapp = QtGui.QApplication(sys.argv)
-
- self.skip = blocks.skiphead(gr.sizeof_gr_complex, self._start)
- self.gui_snk = qtgui.const_sink_c(self._nsamps, "", self._nsigs)
- n = 0
- self.srcs = list()
- self._data_min = sys.maxint
- self._data_max = -sys.maxint - 1
- for f in filelist:
- data,_min,_max = read_samples_c(f, self._start, self._nsamps)
- self.srcs.append(blocks.vector_source_c(data))
-
- if(_min < self._data_min):
- self._data_min = _min
- if(_max > self._data_max):
- self._data_max = _max
-
- # Set default labels based on file names
- fname = f.split("/")[-1]
- self.gui_snk.set_line_label(n, "{0}".format(fname))
- n += 1
-
- self.connect(self.srcs[0], self.skip)
- self.connect(self.skip, (self.gui_snk, 0))
-
- for i,s in enumerate(self.srcs[1:]):
- self.connect(s, (self.gui_snk, i+1))
-
- self.gui_snk.enable_menu(False)
-
- # Get Python Qt references
- pyQt = self.gui_snk.pyqwidget()
- self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
-
- def get_gui(self):
- return self.pyWin
-
- def reset(self, newstart, newnsamps):
- self.stop()
- self.wait()
-
- self._start = newstart
-
- for s,f in zip(self.srcs, self._filelist):
- data,_min,_max = read_samples_c(f, self._start, newnsamps)
- s.set_data(data)
- if(len(data) < newnsamps):
- newnsamps = len(data)
-
- self._nsamps = newnsamps
- self.gui_snk.set_nsamps(self._nsamps)
-
- self.start()
-
- def set_y_axis(self, y_min, y_max):
- y_min = -y_max
- self.gui_snk.set_y_axis(y_min, y_max)
- self.gui_snk.set_x_axis(y_min, y_max)
- return y_min, y_max
-
- def auto_scale(self, state):
- if(state > 0):
- self.set_y_axis(self._data_min, self._data_max)
- self._auto_scale = True
- self._y_value = self._data_max
- self._y_range = self._data_max - self._data_min
- self._y_min = 10*self._data_min
- self._y_max = 10*self._data_max
-
- if(self.gui_y_axis):
- self.gui_y_axis(self._data_min, self._data_max)
- else:
- self._auto_scale = False
-
-
-def main():
- description = "Plots the constellations of a list of files."
- parser = ArgumentParser(description=description,
- 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("files", nargs="+", metavar='FILE')
- args = parser.parse_args()
-
- 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)
- max_nsamples = min(filesizes)
-
- 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 range(tb._nsigs):
- main_box._style_edit[n].setCurrentIndex(0)
- main_box.show()
-
- tb.run()
- tb.qapp.exec_()
-
-if __name__ == "__main__":
- try:
- main()
- except KeyboardInterrupt:
- pass