diff options
Diffstat (limited to 'gr-utils/src/python')
-rw-r--r-- | gr-utils/src/python/.gitignore | 3 | ||||
-rw-r--r-- | gr-utils/src/python/CMakeLists.txt | 30 | ||||
-rw-r--r-- | gr-utils/src/python/Makefile.am | 52 | ||||
-rw-r--r-- | gr-utils/src/python/README.plot | 95 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_filter_design (renamed from gr-utils/src/python/gr_filter_design.py) | 60 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_char (renamed from gr-utils/src/python/gr_plot_char.py) | 14 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_const (renamed from gr-utils/src/python/gr_plot_const.py) | 38 | ||||
-rw-r--r-- | gr-utils/src/python/gr_plot_fft | 42 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_fft_c (renamed from gr-utils/src/python/gr_plot_fft_f.py) | 22 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_fft_f (renamed from gr-utils/src/python/gr_plot_fft_c.py) | 22 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_float (renamed from gr-utils/src/python/gr_plot_float.py) | 14 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_int (renamed from gr-utils/src/python/gr_plot_int.py) | 14 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_iq (renamed from gr-utils/src/python/gr_plot_iq.py) | 28 | ||||
-rw-r--r-- | gr-utils/src/python/gr_plot_psd | 42 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_psd_c (renamed from gr-utils/src/python/gr_plot_psd_c.py) | 20 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_psd_f (renamed from gr-utils/src/python/gr_plot_psd_f.py) | 18 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_qt (renamed from gr-utils/src/python/gr_plot_qt.py) | 44 | ||||
-rwxr-xr-x | gr-utils/src/python/gr_plot_short (renamed from gr-utils/src/python/gr_plot_short.py) | 14 | ||||
-rw-r--r-- | gr-utils/src/python/plot_data.py | 26 | ||||
-rwxr-xr-x | gr-utils/src/python/plot_fft_base.py (renamed from gr-utils/src/python/gr_plot_fft.py) | 71 | ||||
-rwxr-xr-x | gr-utils/src/python/plot_psd_base.py (renamed from gr-utils/src/python/gr_plot_psd.py) | 89 |
21 files changed, 426 insertions, 332 deletions
diff --git a/gr-utils/src/python/.gitignore b/gr-utils/src/python/.gitignore deleted file mode 100644 index b6950912c..000000000 --- a/gr-utils/src/python/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile -/Makefile.in -/*.pyc 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/Makefile.am b/gr-utils/src/python/Makefile.am deleted file mode 100644 index 11fb038f6..000000000 --- a/gr-utils/src/python/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright 2007,2009 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. -# - -include $(top_srcdir)/Makefile.common - -EXTRA_DIST += \ - $(bin_SCRIPTS) \ - README.plot \ - pyqt_plot.ui \ - pyqt_filter.ui - -ourpythondir = $(grpythondir) - -ourpython_PYTHON = \ - plot_data.py \ - pyqt_plot.py \ - pyqt_filter.py - -bin_SCRIPTS = \ - 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 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..cc21ea5e7 100755 --- a/gr-utils/src/python/gr_filter_design.py +++ b/gr-utils/src/python/gr_filter_design @@ -76,9 +76,9 @@ class gr_plot_filter(QtGui.QMainWindow): "High Pass", "Root Raised Cosine", "Gaussian") self.optFilters = ("Low Pass", "Band Pass", "Complex Band Pass", "Band Notch", "High Pass") - + self.set_windowed() - + # Initialize to LPF self.gui.filterTypeWidget.setCurrentWidget(self.gui.firlpfPage) @@ -211,19 +211,19 @@ class gr_plot_filter(QtGui.QMainWindow): self.gui.filterTypeWidget.setCurrentWidget(self.gui.gausPage) self.design() - + def changed_filter_design_type(self, design): if(design == "Equiripple"): self.set_equiripple() else: self.set_windowed() - + self.design() def set_equiripple(self): # Stop sending the signal for this function self.gui.filterTypeComboBox.blockSignals(True) - + self.equiripple = True self.gui.lpfPassBandRippleLabel.setVisible(True) self.gui.lpfPassBandRippleEdit.setVisible(True) @@ -252,11 +252,11 @@ class gr_plot_filter(QtGui.QMainWindow): # Tell gui its ok to start sending this signal again self.gui.filterTypeComboBox.blockSignals(False) - + def set_windowed(self): # Stop sending the signal for this function self.gui.filterTypeComboBox.blockSignals(True) - + self.equiripple = False self.gui.lpfPassBandRippleLabel.setVisible(False) self.gui.lpfPassBandRippleEdit.setVisible(False) @@ -332,7 +332,7 @@ class gr_plot_filter(QtGui.QMainWindow): if(ret): tb = sb - pb - + taps = gr.firdes.low_pass_2(gain, fs, pb, tb, atten, wintype) params = {"fs": fs, "gain": gain, "wintype": wintype, @@ -341,7 +341,7 @@ class gr_plot_filter(QtGui.QMainWindow): return (taps, params, ret) else: return ([], [], ret) - + def design_win_bpf(self, fs, gain, wintype): ret = True pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() @@ -417,7 +417,7 @@ class gr_plot_filter(QtGui.QMainWindow): if(r): tb = pb - sb taps = gr.firdes.high_pass_2(gain, fs, pb, tb, - atten, wintype) + atten, wintype) params = {"fs": fs, "gain": gain, "wintype": wintype, "filttype": "hpf", "sbend": sb, "pbstart": pb, "atten": atten, "ntaps": len(taps)} @@ -490,7 +490,7 @@ class gr_plot_filter(QtGui.QMainWindow): return (taps, params, ret) else: return ([], [], ret) - + def design_opt_bpf(self, fs, gain): ret = True pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() @@ -631,15 +631,15 @@ class gr_plot_filter(QtGui.QMainWindow): self.update_phase_curves() if(tab == 3): self.update_group_curves() - + def get_fft(self, fs, taps, Npts): Ts = 1.0/fs fftpts = fftpack.fft(taps, Npts) - self.freq = scipy.arange(0, fs, 1.0/(Npts*Ts)) + self.freq = scipy.arange(0, fs, 1.0/(Npts*Ts)) self.fftdB = 20.0*scipy.log10(abs(fftpts)) self.fftDeg = scipy.unwrap(scipy.angle(fftpts)) self.groupDelay = -scipy.diff(self.fftDeg) - + def update_time_curves(self): ntaps = len(self.taps) if(ntaps > 0): @@ -656,17 +656,17 @@ class gr_plot_filter(QtGui.QMainWindow): 0, ntaps) self.gui.timePlot.setAxisScale(self.gui.timePlot.yLeft, ymin, ymax) - + # Set the zoomer base to unzoom to the new axis self.timeZoomer.setZoomBase() - + self.gui.timePlot.replot() - + def update_freq_curves(self): npts = len(self.fftdB) if(npts > 0): self.freqcurve.setData(self.freq, self.fftdB) - + # Reset the x-axis to the new time scale ymax = 1.5 * max(self.fftdB[0:npts/2]) ymin = 1.1 * min(self.fftdB[0:npts/2]) @@ -676,10 +676,10 @@ class gr_plot_filter(QtGui.QMainWindow): xmin, xmax) self.gui.freqPlot.setAxisScale(self.gui.freqPlot.yLeft, ymin, ymax) - + # Set the zoomer base to unzoom to the new axis self.freqZoomer.setZoomBase() - + self.gui.freqPlot.replot() @@ -687,7 +687,7 @@ class gr_plot_filter(QtGui.QMainWindow): npts = len(self.fftDeg) if(npts > 0): self.phasecurve.setData(self.freq, self.fftDeg) - + # Reset the x-axis to the new time scale ymax = 1.5 * max(self.fftDeg[0:npts/2]) ymin = 1.1 * min(self.fftDeg[0:npts/2]) @@ -697,17 +697,17 @@ class gr_plot_filter(QtGui.QMainWindow): xmin, xmax) self.gui.phasePlot.setAxisScale(self.gui.phasePlot.yLeft, ymin, ymax) - + # Set the zoomer base to unzoom to the new axis self.phaseZoomer.setZoomBase() - + self.gui.phasePlot.replot() def update_group_curves(self): npts = len(self.groupDelay) if(npts > 0): self.groupcurve.setData(self.freq, self.groupDelay) - + # Reset the x-axis to the new time scale ymax = 1.5 * max(self.groupDelay[0:npts/2]) ymin = 1.1 * min(self.groupDelay[0:npts/2]) @@ -717,10 +717,10 @@ class gr_plot_filter(QtGui.QMainWindow): xmin, xmax) self.gui.groupPlot.setAxisScale(self.gui.groupPlot.yLeft, ymin, ymax) - + # Set the zoomer base to unzoom to the new axis self.groupZoomer.setZoomBase() - + self.gui.groupPlot.replot() def action_save_dialog(self): @@ -732,7 +732,7 @@ class gr_plot_filter(QtGui.QMainWindow): ("Could not save to file: %s" % filename), "&Ok") return - + csvhandle = csv.writer(handle, delimiter=",") for k in self.params.keys(): csvhandle.writerow([k, self.params[k]]) @@ -743,7 +743,7 @@ class gr_plot_filter(QtGui.QMainWindow): filename = QtGui.QFileDialog.getOpenFileName(self, "Open CSV Filter File", ".", "") if(len(filename) == 0): return - + try: handle = open(filename, "rb") except IOError: @@ -849,9 +849,9 @@ class gr_plot_filter(QtGui.QMainWindow): self.update_freq_curves() self.update_phase_curves() self.update_group_curves() - + self.gui.nTapsEdit.setText(Qt.QString("%1").arg(self.taps.size)) - + def setup_options(): usage="%prog: [options] (input_filename)" diff --git a/gr-utils/src/python/gr_plot_char.py b/gr-utils/src/python/gr_plot_char index 87a323c9c..a2b93a63c 100755 --- a/gr-utils/src/python/gr_plot_char.py +++ b/gr-utils/src/python/gr_plot_char @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008 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. -# +# try: import scipy @@ -40,7 +40,7 @@ def main(): 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() @@ -55,4 +55,4 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_const.py b/gr-utils/src/python/gr_plot_const index 8873e5b7e..749ad035b 100755 --- a/gr-utils/src/python/gr_plot_const.py +++ b/gr-utils/src/python/gr_plot_const @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008,2011 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. -# +# try: import scipy @@ -53,11 +53,11 @@ class draw_constellation: self.fig = figure(1, figsize=(16, 9), facecolor='w') rcParams['xtick.labelsize'] = self.axis_font_size rcParams['ytick.labelsize'] = self.axis_font_size - + self.text_file = figtext(0.10, 0.95, ("File: %s" % filename), weight="heavy", size=16) self.text_file_pos = figtext(0.10, 0.90, "File Position: ", weight="heavy", size=16) self.text_block = figtext(0.40, 0.90, ("Block Size: %d" % self.block_length), - weight="heavy", size=16) + weight="heavy", size=16) self.text_sr = figtext(0.60, 0.90, ("Sample Rate: %.2f" % self.sample_rate), weight="heavy", size=16) self.make_plots() @@ -90,7 +90,7 @@ class draw_constellation: if(len(iq) > 0): self.reals = scipy.array([r.real for r in iq]) self.imags = scipy.array([i.imag for i in iq]) - + self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.reals))]) return True else: @@ -102,7 +102,7 @@ class draw_constellation: self.hfile.seek(self.sizeof_data*self.start, 1) r = self.get_data() - + # Subplot for real and imaginary parts of signal self.sp_iq = self.fig.add_subplot(2,1,1, position=[0.075, 0.2, 0.4, 0.6]) self.sp_iq.set_title(("I&Q"), fontsize=self.title_font_size, fontweight="bold") @@ -141,7 +141,7 @@ class draw_constellation: self.plot_const[0].set_data([self.reals, self.imags]) self.sp_const.axis([-2, 2, -2, 2]) draw() - + def zoom(self, event): newxlim = scipy.array(self.sp_iq.get_xlim()) curxlim = scipy.array(self.xlim) @@ -163,7 +163,7 @@ class draw_constellation: if(find(event.key, forward_valid_keys)): self.step_forward() - + elif(find(event.key, backward_valid_keys)): self.step_backward() @@ -195,16 +195,16 @@ class draw_constellation: r = self.get_data() if(r): self.update_plots() - - + + def mouse_button_callback(self, event): x, y = event.xdata, event.ydata - + if x is not None and y is not None: if(event.inaxes == self.sp_iq): self.indx = searchsorted(self.time, [x]) self.set_trace(self.indx) - + def set_trace(self, indx): self.plot_iq[2].set_data(self.time[indx], self.reals[indx]) @@ -212,13 +212,13 @@ class draw_constellation: self.plot_const[1].set_data(self.reals[indx], self.imags[indx]) draw() - + def find(item_in, list_search): try: return list_search.index(item_in) != None except ValueError: return False - + def main(): usage="%prog: [options] input_filename" @@ -231,7 +231,7 @@ def main(): 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() @@ -245,6 +245,6 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_fft b/gr-utils/src/python/gr_plot_fft new file mode 100644 index 000000000..434348164 --- /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..43e808d95 100755 --- a/gr-utils/src/python/gr_plot_fft_f.py +++ b/gr-utils/src/python/gr_plot_fft_c @@ -1,44 +1,46 @@ #!/usr/bin/env python # # Copyright 2007,2008 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 -import gr_plot_fft +# 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 () if len(args) != 1: parser.print_help() 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: main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_fft_c.py b/gr-utils/src/python/gr_plot_fft_f index de59b36c9..dee9b17de 100755 --- a/gr-utils/src/python/gr_plot_fft_c.py +++ b/gr-utils/src/python/gr_plot_fft_f @@ -1,44 +1,46 @@ #!/usr/bin/env python # # Copyright 2007,2008 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 -import gr_plot_fft +# 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 () if len(args) != 1: parser.print_help() 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: main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_float.py b/gr-utils/src/python/gr_plot_float index e5c22a315..22806e48a 100755 --- a/gr-utils/src/python/gr_plot_float.py +++ b/gr-utils/src/python/gr_plot_float @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008 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. -# +# try: import scipy @@ -40,7 +40,7 @@ def main(): 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() @@ -55,4 +55,4 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_int.py b/gr-utils/src/python/gr_plot_int index b44d4360a..355ddf018 100755 --- a/gr-utils/src/python/gr_plot_int.py +++ b/gr-utils/src/python/gr_plot_int @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008 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. -# +# try: import scipy @@ -40,7 +40,7 @@ def main(): 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() @@ -55,4 +55,4 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_iq.py b/gr-utils/src/python/gr_plot_iq index 316e60a75..bf8077b6b 100755 --- a/gr-utils/src/python/gr_plot_iq.py +++ b/gr-utils/src/python/gr_plot_iq @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008,2011 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. -# +# try: import scipy @@ -53,7 +53,7 @@ class draw_iq: self.fig = figure(1, figsize=(16, 9), facecolor='w') rcParams['xtick.labelsize'] = self.axis_font_size rcParams['ytick.labelsize'] = self.axis_font_size - + self.text_file = figtext(0.10, 0.94, ("File: %s" % filename), weight="heavy", size=self.text_size) self.text_file_pos = figtext(0.10, 0.88, "File Position: ", weight="heavy", size=self.text_size) self.text_block = figtext(0.40, 0.88, ("Block Size: %d" % self.block_length), @@ -86,13 +86,13 @@ class draw_iq: self.reals = scipy.array([r.real for r in self.iq]) self.imags = scipy.array([i.imag for i in self.iq]) self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.reals))]) - + def make_plots(self): # if specified on the command-line, set file pointer self.hfile.seek(self.sizeof_data*self.start, 1) self.get_data() - + # Subplot for real and imaginary parts of signal self.sp_iq = self.fig.add_subplot(2,1,1, position=[0.075, 0.14, 0.85, 0.67]) self.sp_iq.set_title(("I&Q"), fontsize=self.title_font_size, fontweight="bold") @@ -111,14 +111,14 @@ class draw_iq: 1.5*max([self.reals.max(), self.imags.max()])]) self.sp_iq.set_xlim(self.time.min(), self.time.max()) draw() - + def click(self, event): forward_valid_keys = [" ", "down", "right"] backward_valid_keys = ["up", "left"] if(find(event.key, forward_valid_keys)): self.step_forward() - + elif(find(event.key, backward_valid_keys)): self.step_backward() @@ -140,14 +140,14 @@ class draw_iq: self.hfile.seek(-self.hfile.tell(),1) self.get_data() self.update_plots() - + def find(item_in, list_search): try: return list_search.index(item_in) != None except ValueError: 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." @@ -159,7 +159,7 @@ def main(): 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() @@ -173,6 +173,6 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_psd b/gr-utils/src/python/gr_plot_psd new file mode 100644 index 000000000..059ca6b64 --- /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..fff2bff0f 100755 --- a/gr-utils/src/python/gr_plot_psd_c.py +++ b/gr-utils/src/python/gr_plot_psd_c @@ -1,32 +1,32 @@ #!/usr/bin/env python # # Copyright 2008 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 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,13 +35,13 @@ 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: main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_psd_f.py b/gr-utils/src/python/gr_plot_psd_f index bad6788c3..ec6799479 100755 --- a/gr-utils/src/python/gr_plot_psd_f.py +++ b/gr-utils/src/python/gr_plot_psd_f @@ -1,32 +1,32 @@ #!/usr/bin/env python # # Copyright 2008 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 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,13 +35,13 @@ 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: main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_qt.py b/gr-utils/src/python/gr_plot_qt index f3dc472f5..153359f0c 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 @@ -55,12 +55,12 @@ class SpectrogramData(Qwt.QwtRasterData): def rasterHint(self, rect): return Qt.QSize(self.sp.shape[0], self.sp.shape[1]) - + def copy(self): return self def range(self): - + return Qwt.QwtDoubleInterval(self.sp.min(), self.sp.max()) def value(self, x, y): @@ -77,7 +77,7 @@ class gr_plot_qt(QtGui.QMainWindow): QtGui.QWidget.__init__(self, parent) self.gui = Ui_MainWindow() self.gui.setupUi(self) - + self.filename = None self.block_length = options.block_length self.start = options.start @@ -127,8 +127,8 @@ class gr_plot_qt(QtGui.QMainWindow): self.connect(self.gui.colorComboBox, Qt.SIGNAL("activated (const QString&)"), self.colorComboBoxEdit) - - + + # Set up line style combo box self.line_styles = {"None" : Qwt.QwtSymbol.NoSymbol, "Circle" : Qwt.QwtSymbol.Ellipse, @@ -290,7 +290,7 @@ class gr_plot_qt(QtGui.QMainWindow): def reload_file(self): if(self.filename): self.initialize(self.filename) - + def initialize(self, filename): self.filename = filename self.hfile = open(filename, "r") @@ -308,7 +308,7 @@ class gr_plot_qt(QtGui.QMainWindow): self.init_data_input() self.get_data(self.cur_start, self.cur_stop) self.get_psd() - self.get_specgram() + self.get_specgram() self.gui.plotHBar.setSliderPosition(0) self.gui.plotHBar.setMaximum(self.signal_size-self.block_length) @@ -322,7 +322,7 @@ class gr_plot_qt(QtGui.QMainWindow): self.signal_size = self.hfile.tell()/self.sizeof_data #print "Sizeof File: ", self.signal_size self.hfile.seek(0, os.SEEK_SET) - + def get_data(self, start, end): if(end > start): self.hfile.seek(start*self.sizeof_data, os.SEEK_SET) @@ -365,7 +365,7 @@ class gr_plot_qt(QtGui.QMainWindow): noverlap=self.specfftsize/4.0, window=winpoints, scale_by_freq=False) - + self.iq_spec = 10.0*scipy.log10(abs(iq_spec)) self.spec_f = f self.spec_t = t @@ -379,7 +379,7 @@ class gr_plot_qt(QtGui.QMainWindow): self.specfftsize = fftSize.toInt()[0] self.get_specgram() self.update_specgram_curves() - + def colorComboBoxEdit(self, colorSelection): colorstr = str(colorSelection.toAscii()) color_func = self.color_modes[colorstr] @@ -443,7 +443,7 @@ class gr_plot_qt(QtGui.QMainWindow): tend = self.cur_stop / self.sample_rate self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart)) self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend)) - + self.get_data(self.cur_start, self.cur_stop) self.update_time_curves() @@ -456,7 +456,7 @@ class gr_plot_qt(QtGui.QMainWindow): self.set_file_pos_box(self.cur_start, self.cur_stop) except AttributeError: pass - + def file_time_changed(self): tstart = self.gui.fileTimeStartLineEdit.text().toDouble() @@ -548,16 +548,16 @@ class gr_plot_qt(QtGui.QMainWindow): # Set the zoomer base to unzoom to the new axis self.timeZoomer.setZoomBase() - + self.gui.timePlot.replot() - + def update_psd_curves(self): self.psdcurve.setData(self.freq, self.iq_psd) self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom, min(self.freq), max(self.freq)) - + # Set the zoomer base to unzoom to the new axis self.freqZoomer.setZoomBase() @@ -579,10 +579,10 @@ class gr_plot_qt(QtGui.QMainWindow): self.gui.specPlot.setAxisScale(self.gui.specPlot.yLeft, min(self.spec_t), max(self.spec_t)) - self.gui.specPlot.setAxisScale(self.gui.specPlot.yRight, + self.gui.specPlot.setAxisScale(self.gui.specPlot.yRight, self.iq_spec.min(), self.iq_spec.max()) - + # Set the zoomer base to unzoom to the new axis self.specZoomer.setZoomBase() @@ -604,7 +604,7 @@ class gr_plot_qt(QtGui.QMainWindow): self.rcurve.setSymbol(self.rsym) self.icurve.setSymbol(self.isym) self.gui.timePlot.replot() - + def color_black_on_white(self): blue = QtGui.qRgb(0x00, 0x00, 0xFF) red = QtGui.qRgb(0xFF, 0x00, 0x00) @@ -636,7 +636,7 @@ class gr_plot_qt(QtGui.QMainWindow): whiteBrush = Qt.QBrush(Qt.QColor("white")) whiteBrush = Qt.QBrush(Qt.QColor(white)) redBrush = Qt.QBrush(Qt.QColor(red)) - + self.gui.timePlot.setCanvasBackground(QtGui.QColor("black")) self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black")) self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width)) @@ -658,7 +658,7 @@ class gr_plot_qt(QtGui.QMainWindow): whiteBrush = Qt.QBrush(Qt.QColor("white")) greenBrush = Qt.QBrush(Qt.QColor(green)) redBrush = Qt.QBrush(Qt.QColor(red)) - + self.gui.timePlot.setCanvasBackground(QtGui.QColor("black")) self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black")) self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width)) @@ -679,7 +679,7 @@ class gr_plot_qt(QtGui.QMainWindow): whiteBrush = Qt.QBrush(Qt.QColor("white")) blueBrush = Qt.QBrush(Qt.QColor(blue)) redBrush = Qt.QBrush(Qt.QColor(red)) - + self.gui.timePlot.setCanvasBackground(QtGui.QColor("black")) self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black")) self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width)) diff --git a/gr-utils/src/python/gr_plot_short.py b/gr-utils/src/python/gr_plot_short index 3466e0b7d..702a2a94a 100755 --- a/gr-utils/src/python/gr_plot_short.py +++ b/gr-utils/src/python/gr_plot_short @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008 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. -# +# try: import scipy @@ -40,7 +40,7 @@ def main(): 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() @@ -55,4 +55,4 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/plot_data.py b/gr-utils/src/python/plot_data.py index 15012e589..242ca2a4b 100644 --- a/gr-utils/src/python/plot_data.py +++ b/gr-utils/src/python/plot_data.py @@ -1,23 +1,23 @@ # # Copyright 2007,2008,2011 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. -# +# try: import scipy @@ -57,7 +57,7 @@ class plot_data: self.fig = figure(1, figsize=(16, 9), facecolor='w') rcParams['xtick.labelsize'] = self.axis_font_size rcParams['ytick.labelsize'] = self.axis_font_size - + self.text_file_pos = figtext(0.10, 0.88, "File Position: ", weight="heavy", size=self.text_size) self.text_block = figtext(0.40, 0.88, ("Block Size: %d" % self.block_length), weight="heavy", size=self.text_size) @@ -78,7 +78,7 @@ class plot_data: self.manager = get_current_fig_manager() connect('key_press_event', self.click) show() - + def get_data(self, hfile): self.text_file_pos.set_text("File Position: %d" % (hfile.tell()//self.sizeof_data)) try: @@ -88,7 +88,7 @@ class plot_data: else: self.f = scipy.array(f) self.time = scipy.array([i*(1/self.sample_rate) for i in range(len(self.f))]) - + def make_plots(self): self.sp_f = self.fig.add_subplot(2,1,1, position=[0.075, 0.2, 0.875, 0.6]) self.sp_f.set_title(("Amplitude"), fontsize=self.title_font_size, fontweight="bold") @@ -104,7 +104,7 @@ class plot_data: hf.seek(self.sizeof_data*self.start, 1) self.get_data(hf) - + # Subplot for real and imaginary parts of signal self.plot_f += plot(self.time, self.f, 'o-') maxval = max(maxval, self.f.max()) @@ -126,16 +126,16 @@ class plot_data: minval = min(minval, self.f.min()) self.sp_f.set_ylim([1.5*minval, 1.5*maxval]) - + draw() - + def click(self, event): forward_valid_keys = [" ", "down", "right"] backward_valid_keys = ["up", "left"] if(find(event.key, forward_valid_keys)): self.step_forward() - + elif(find(event.key, backward_valid_keys)): self.step_backward() @@ -156,7 +156,7 @@ class plot_data: else: hf.seek(-hf.tell(),1) self.update_plots() - + def find(item_in, list_search): try: diff --git a/gr-utils/src/python/gr_plot_fft.py b/gr-utils/src/python/plot_fft_base.py index ba3901e03..4afdc3a36 100755 --- a/gr-utils/src/python/gr_plot_fft.py +++ b/gr-utils/src/python/plot_fft_base.py @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008,2011 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. -# +# try: import scipy @@ -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 @@ -54,7 +54,7 @@ class gr_plot_fft: self.fig = figure(1, figsize=(16, 12), facecolor='w') rcParams['xtick.labelsize'] = self.axis_font_size rcParams['ytick.labelsize'] = self.axis_font_size - + self.text_file = figtext(0.10, 0.94, ("File: %s" % filename), weight="heavy", size=self.text_size) self.text_file_pos = figtext(0.10, 0.88, "File Position: ", weight="heavy", size=self.text_size) self.text_block = figtext(0.35, 0.88, ("Block Size: %d" % self.block_length), @@ -77,7 +77,7 @@ class gr_plot_fft: connect('draw_event', self.zoom) connect('key_press_event', self.click) show() - + def get_data(self): self.position = self.hfile.tell()/self.sizeof_data self.text_file_pos.set_text("File Position: %d" % (self.position)) @@ -87,7 +87,7 @@ class gr_plot_fft: print "End of File" else: self.iq_fft = self.dofft(self.iq) - + tstep = 1.0 / self.sample_rate #self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))]) self.time = scipy.array([tstep*(i) for i in xrange(len(self.iq))]) @@ -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 @@ -107,7 +107,7 @@ class gr_plot_fft: Fn = 0.5 * sample_rate freq = scipy.array([-Fn + i*Fs for i in xrange(N)]) return freq - + def make_plots(self): # if specified on the command-line, set file pointer self.hfile.seek(self.sizeof_data*self.start, 1) @@ -125,7 +125,7 @@ class gr_plot_fft: self.sp_fft.set_ylabel("Power Spectrum (dBm)", fontsize=self.label_font_size, fontweight="bold") self.get_data() - + self.plot_iq = self.sp_iq.plot([], 'bo-') # make plot for reals self.plot_iq += self.sp_iq.plot([], 'ro-') # make plot for imags self.draw_time() # draw the plot @@ -155,7 +155,7 @@ class gr_plot_fft: self.xlim = self.sp_iq.get_xlim() draw() - + def zoom(self, event): newxlim = scipy.array(self.sp_iq.get_xlim()) curxlim = scipy.array(self.xlim) @@ -168,10 +168,10 @@ class gr_plot_fft: iq = self.iq[xmin : xmax] time = self.time[xmin : xmax] - + iq_fft = self.dofft(iq) freq = self.calc_freq(time, self.sample_rate) - + self.plot_fft[0].set_data(freq, iq_fft) self.sp_fft.axis([freq.min(), freq.max(), iq_fft.min()-10, iq_fft.max()+10]) @@ -184,7 +184,7 @@ class gr_plot_fft: if(find(event.key, forward_valid_keys)): self.step_forward() - + elif(find(event.key, backward_valid_keys)): self.step_backward() @@ -206,43 +206,44 @@ 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: main() except KeyboardInterrupt: pass - + diff --git a/gr-utils/src/python/gr_plot_psd.py b/gr-utils/src/python/plot_psd_base.py index 3dab0535a..fe3c9e12b 100755 --- a/gr-utils/src/python/gr_plot_psd.py +++ b/gr-utils/src/python/plot_psd_base.py @@ -1,24 +1,24 @@ #!/usr/bin/env python # # Copyright 2007,2008,2010,2011 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. -# +# try: import scipy @@ -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 @@ -60,7 +60,7 @@ class gr_plot_psd: self.fig = figure(1, figsize=(16, 12), facecolor='w') rcParams['xtick.labelsize'] = self.axis_font_size rcParams['ytick.labelsize'] = self.axis_font_size - + self.text_file = figtext(0.10, 0.95, ("File: %s" % filename), weight="heavy", size=self.text_size) self.text_file_pos = figtext(0.10, 0.92, "File Position: ", @@ -85,7 +85,7 @@ class gr_plot_psd: connect('draw_event', self.zoom) connect('key_press_event', self.click) show() - + def get_data(self): self.position = self.hfile.tell()/self.sizeof_data self.text_file_pos.set_text("File Position: %d" % self.position) @@ -101,13 +101,13 @@ class gr_plot_psd: tstep = 1.0 / self.sample_rate #self.time = scipy.array([tstep*(self.position + i) for i in xrange(len(self.iq))]) self.time = scipy.array([tstep*(i) for i in xrange(len(self.iq))]) - + self.iq_psd, self.freq = self.dopsd(self.iq) return True else: print "End of File" return False - + def dopsd(self, iq): ''' Need to do this here and plot later so we can do the fftshift ''' overlap = self.psdfftsize/4 @@ -125,7 +125,7 @@ class gr_plot_psd: iqdims = [[0.075, 0.2, 0.4, 0.6], [0.075, 0.55, 0.4, 0.3]] psddims = [[0.575, 0.2, 0.4, 0.6], [0.575, 0.55, 0.4, 0.3]] specdims = [0.2, 0.125, 0.6, 0.3] - + # Subplot for real and imaginary parts of signal self.sp_iq = self.fig.add_subplot(2,2,1, position=iqdims[self.dospec]) self.sp_iq.set_title(("I&Q"), fontsize=self.title_font_size, fontweight="bold") @@ -139,7 +139,7 @@ class gr_plot_psd: self.sp_psd.set_ylabel("Power Spectrum (dBm)", fontsize=self.label_font_size, fontweight="bold") r = self.get_data() - + self.plot_iq = self.sp_iq.plot([], 'bo-') # make plot for reals self.plot_iq += self.sp_iq.plot([], 'ro-') # make plot for imags self.draw_time(self.time, self.iq) # draw the plot @@ -156,7 +156,7 @@ class gr_plot_psd: self.sp_spec.set_ylabel("Frequency (Hz)", fontsize=self.label_font_size, fontweight="bold") self.draw_spec(self.time, self.iq) - + draw() def draw_time(self, t, iq): @@ -189,9 +189,9 @@ class gr_plot_psd: self.draw_spec(self.time, self.iq) self.xlim = scipy.array(self.sp_iq.get_xlim()) # so zoom doesn't get called - + draw() - + def zoom(self, event): newxlim = scipy.array(self.sp_iq.get_xlim()) curxlim = scipy.array(self.xlim) @@ -205,7 +205,7 @@ class gr_plot_psd: time = scipy.array(self.time[xmin : xmax]) iq_psd, freq = self.dopsd(iq) - + self.draw_psd(freq, iq_psd) self.xlim = scipy.array(self.sp_iq.get_xlim()) @@ -217,7 +217,7 @@ class gr_plot_psd: if(find(event.key, forward_valid_keys)): self.step_forward() - + elif(find(event.key, backward_valid_keys)): self.step_backward() @@ -241,51 +241,52 @@ class gr_plot_psd: r = self.get_data() 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: main() except KeyboardInterrupt: pass - + |