5 from scipy import fftpack
7 print "Please install SciPy to run this script (http://www.scipy.org/)"
11 from matplotlib import mlab
13 print "Please install Matplotlib to run this script (http://matplotlib.sourceforge.net)"
17 from PyQt4 import Qt, QtCore, QtGui
19 print "Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)"
23 import PyQt4.Qwt5 as Qwt
25 print "Please install PyQwt5 to run this script (http://pyqwt.sourceforge.net/)"
29 # FIXME: reenable this before committing
30 #from gnuradio.pyqt_plot import Ui_MainWindow
31 from pyqt_plot import Ui_MainWindow
33 print "Could not import from pyqt_plot. Please build with \"pyuic4 pyqt_plot.ui -o pyqt_plot.py\""
37 from optparse import OptionParser
38 from gnuradio import eng_notation
41 class SpectrogramData(Qwt.QwtRasterData):
43 def __init__(self, f, t):
44 Qwt.QwtArrayData.__init__(self, Qt.QRectF(0, 0, 0, 0))
45 self.sp = scipy.array([[0], [0]])
47 def set_data(self, xfreq, ytime, data):
51 boundingBox = Qt.QRectF(self.freq.min(), self.time.min(),
52 self.freq.max() - self.freq.min(),
53 self.time.max() - self.time.min())
54 self.setBoundingRect(boundingBox)
56 def rasterHint(self, rect):
57 return Qt.QSize(self.sp.shape[0], self.sp.shape[1])
64 return Qwt.QwtDoubleInterval(self.sp.min(), self.sp.max())
66 def value(self, x, y):
68 f = int(self.freq.searchsorted(x))
69 t = int(self.time.searchsorted(y))
70 return self.sp[f][t-1]
71 except AttributeError: # if no file loaded yet
75 class gr_plot_qt(QtGui.QMainWindow):
76 def __init__(self, qapp, filename, options, parent=None):
77 QtGui.QWidget.__init__(self, parent)
78 self.gui = Ui_MainWindow()
79 self.gui.setupUi(self)
82 self.block_length = options.block_length
83 self.start = options.start
84 self.sample_rate = options.sample_rate
85 self.psdfftsize = options.psd_size
86 self.specfftsize = options.spec_size
87 self.winfunc = scipy.blackman
89 self.datatype = scipy.complex64
94 # Set up basic plot attributes
95 self.gui.timePlot.setAxisTitle(self.gui.timePlot.xBottom, "Time (sec)")
96 self.gui.timePlot.setAxisTitle(self.gui.timePlot.yLeft, "Amplitude (V)")
97 self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.xBottom, "Frequency (Hz)")
98 self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.yLeft, "Magnitude (dB)")
99 self.gui.specPlot.setAxisTitle(self.gui.specPlot.xBottom, "Frequency (Hz)")
100 self.gui.specPlot.setAxisTitle(self.gui.specPlot.yLeft, "Time (sec)")
102 # Set up FFT size combo box
103 self.fftsizes = ["128", "256", "512", "1024", "2048",
104 "4096", "8192", "16384", "32768"]
105 self.gui.psdFFTComboBox.addItems(self.fftsizes)
106 self.gui.specFFTComboBox.addItems(self.fftsizes)
107 pos = self.gui.psdFFTComboBox.findText(Qt.QString("%1").arg(self.psdfftsize))
108 self.gui.psdFFTComboBox.setCurrentIndex(pos)
109 pos = self.gui.specFFTComboBox.findText(Qt.QString("%1").arg(self.specfftsize))
110 self.gui.specFFTComboBox.setCurrentIndex(pos)
112 self.connect(self.gui.psdFFTComboBox,
113 Qt.SIGNAL("activated (const QString&)"),
114 self.psdFFTComboBoxEdit)
115 self.connect(self.gui.specFFTComboBox,
116 Qt.SIGNAL("activated (const QString&)"),
117 self.specFFTComboBoxEdit)
119 # Set up color scheme box
120 self.color_modes = {"Black on White" : self.color_black_on_white,
121 "White on Black" : self.color_white_on_black,
122 "Blue on Black" : self.color_blue_on_black,
123 "Green on Black" : self.color_green_on_black}
124 self.gui.colorComboBox.addItems(self.color_modes.keys())
125 pos = self.gui.colorComboBox.findText("Blue on Black")
126 self.gui.colorComboBox.setCurrentIndex(pos)
127 self.connect(self.gui.colorComboBox,
128 Qt.SIGNAL("activated (const QString&)"),
129 self.colorComboBoxEdit)
132 # Set up line style combo box
133 self.line_styles = {"None" : Qwt.QwtSymbol.NoSymbol,
134 "Circle" : Qwt.QwtSymbol.Ellipse,
135 "Diamond" : Qwt.QwtSymbol.Rect,
136 "Triangle" : Qwt.QwtSymbol.Triangle}
137 self.gui.lineStyleComboBox.addItems(self.line_styles.keys())
138 pos = self.gui.lineStyleComboBox.findText("None")
139 self.gui.lineStyleComboBox.setCurrentIndex(pos)
140 self.connect(self.gui.lineStyleComboBox,
141 Qt.SIGNAL("activated (const QString&)"),
142 self.lineStyleComboBoxEdit)
144 # Create zoom functionality for the plots
145 self.timeZoomer = Qwt.QwtPlotZoomer(self.gui.timePlot.xBottom,
146 self.gui.timePlot.yLeft,
147 Qwt.QwtPicker.PointSelection,
148 Qwt.QwtPicker.AlwaysOn,
149 self.gui.timePlot.canvas())
151 self.freqZoomer = Qwt.QwtPlotZoomer(self.gui.freqPlot.xBottom,
152 self.gui.freqPlot.yLeft,
153 Qwt.QwtPicker.PointSelection,
154 Qwt.QwtPicker.AlwaysOn,
155 self.gui.freqPlot.canvas())
157 self.specZoomer = Qwt.QwtPlotZoomer(self.gui.specPlot.xBottom,
158 self.gui.specPlot.yLeft,
159 Qwt.QwtPicker.PointSelection,
160 Qwt.QwtPicker.AlwaysOn,
161 self.gui.specPlot.canvas())
163 # Set up action when tab is changed
164 self.connect(self.gui.tabGroup,
165 Qt.SIGNAL("currentChanged (int)"),
168 # Add a legend to the Time plot
169 legend_real = Qwt.QwtLegend()
170 self.gui.timePlot.insertLegend(legend_real)
173 self.gui.plotHBar.setSingleStep(1)
174 self.gui.plotHBar.setPageStep(self.block_length)
175 self.gui.plotHBar.setMinimum(0)
176 self.gui.plotHBar.setMaximum(self.block_length)
177 self.connect(self.gui.plotHBar,
178 Qt.SIGNAL("valueChanged(int)"),
181 # Connect Open action to Open Dialog box
182 self.connect(self.gui.action_open,
183 Qt.SIGNAL("activated()"),
186 # Connect Reload action to reload the file
187 self.connect(self.gui.action_reload,
188 Qt.SIGNAL("activated()"),
190 self.gui.action_reload.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+R",
191 None, QtGui.QApplication.UnicodeUTF8))
193 # Set up file position boxes to update current figure
194 self.connect(self.gui.filePosStartLineEdit,
195 Qt.SIGNAL("editingFinished()"),
196 self.file_position_changed)
197 self.connect(self.gui.filePosStopLineEdit,
198 Qt.SIGNAL("editingFinished()"),
199 self.file_position_changed)
200 self.connect(self.gui.filePosLengthLineEdit,
201 Qt.SIGNAL("editingFinished()"),
202 self.file_length_changed)
204 self.connect(self.gui.fileTimeStartLineEdit,
205 Qt.SIGNAL("editingFinished()"),
206 self.file_time_changed)
207 self.connect(self.gui.fileTimeStopLineEdit,
208 Qt.SIGNAL("editingFinished()"),
209 self.file_time_changed)
210 self.connect(self.gui.fileTimeLengthLineEdit,
211 Qt.SIGNAL("editingFinished()"),
212 self.file_time_length_changed)
214 stylestr = str(self.gui.lineStyleComboBox.currentText().toAscii())
215 style = self.line_styles[stylestr]
217 self.rcurve = Qwt.QwtPlotCurve("Real")
218 self.icurve = Qwt.QwtPlotCurve("Imaginary")
219 self.rsym = Qwt.QwtSymbol()
220 self.rsym.setStyle(style)
221 self.rsym.setSize(10)
222 self.isym = Qwt.QwtSymbol()
223 self.isym.setStyle(style)
224 self.isym.setSize(10)
225 self.rcurve.setSymbol(self.rsym)
226 self.icurve.setSymbol(self.isym)
229 self.icurve.attach(self.gui.timePlot)
230 self.rcurve.attach(self.gui.timePlot)
232 self.psdcurve = Qwt.QwtPlotCurve("PSD")
233 self.psdcurve.attach(self.gui.freqPlot)
235 # Set up specTab plot as a spectrogram
236 self.specdata = SpectrogramData(range(0, 10), range(0, 10))
238 colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red)
239 colorMap.addColorStop(0.1, Qt.Qt.cyan)
240 colorMap.addColorStop(0.6, Qt.Qt.green)
241 colorMap.addColorStop(0.95, Qt.Qt.yellow)
243 self.spec = Qwt.QwtPlotSpectrogram()
244 self.spec.setColorMap(colorMap)
245 self.spec.attach(self.gui.specPlot)
246 self.spec.setDisplayMode(Qwt.QwtPlotSpectrogram.ImageMode, True)
247 self.spec.setData(self.specdata)
249 self.rightAxis = self.gui.specPlot.axisWidget(Qwt.QwtPlot.yRight)
250 self.rightAxis.setTitle("Magnitude (dBm)")
251 self.rightAxis.setColorBarEnabled(True)
252 self.rightAxis.setColorMap(self.spec.data().range(),
253 self.spec.colorMap())
254 self.gui.specPlot.enableAxis(Qwt.QwtPlot.yRight)
256 # Set up initial color scheme
257 self.color_modes["Blue on Black"]()
259 # When line width spin box changes, update the pen size
260 self.connect(self.gui.lineWidthSpinBox,
261 Qt.SIGNAL("valueChanged(int)"),
262 self.change_pen_width)
263 self.gui.lineWidthSpinBox.setRange(1, 10)
265 # When style size spin box changes, update the pen size
266 self.connect(self.gui.styleSizeSpinBox,
267 Qt.SIGNAL("valueChanged(int)"),
268 self.change_style_size)
269 self.gui.styleSizeSpinBox.setRange(1, 20)
270 self.gui.styleSizeSpinBox.setValue(5)
273 # Connect a signal for when the sample rate changes
274 self.set_sample_rate(self.sample_rate)
275 self.connect(self.gui.sampleRateLineEdit,
276 Qt.SIGNAL("editingFinished()"),
277 self.sample_rate_changed)
279 if(filename is not None):
280 self.initialize(filename)
285 filename = Qt.QFileDialog.getOpenFileName(self, "Open", ".")
288 self.initialize(filename)
290 def reload_file(self):
292 self.initialize(self.filename)
294 def initialize(self, filename):
295 self.filename = filename
296 self.hfile = open(filename, "r")
298 self.setWindowTitle(("GNU Radio File Plot Utility: %s" % filename))
300 self.gui.filePosStartLineEdit.setText("0")
301 self.gui.filePosStopLineEdit.setText("0")
302 self.gui.fileTimeStartLineEdit.setText("0")
303 self.gui.fileTimeStopLineEdit.setText("0")
306 self.cur_stop = self.block_length
308 self.init_data_input()
309 self.get_data(self.cur_start, self.cur_stop)
312 self.gui.plotHBar.setSliderPosition(0)
313 self.gui.plotHBar.setMaximum(self.signal_size)
316 self.update_time_curves()
317 self.update_psd_curves()
318 self.update_specgram_curves()
320 def init_data_input(self):
321 self.hfile.seek(0, os.SEEK_END)
322 self.signal_size = self.hfile.tell()/self.sizeof_data
323 #print "Sizeof File: ", self.signal_size
324 self.hfile.seek(0, os.SEEK_SET)
326 def get_data(self, start, end):
328 self.hfile.seek(start*self.sizeof_data, os.SEEK_SET)
329 self.position = start
331 iq = scipy.fromfile(self.hfile, dtype=self.datatype,
334 if(len(iq) < (end-start)):
336 self.gui.filePosLengthLineEdit.setText(Qt.QString("%1").arg(end))
337 self.gui.plotHBar.setMaximum(end)
338 self.gui.plotHBar.setSingleStep(end)
339 self.file_length_changed()
341 tstep = 1.0 / self.sample_rate
343 self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))]
345 self.set_file_pos_box(start, end)
349 # Do we want to do anything about this?
353 winpoints = self.winfunc(self.psdfftsize)
354 iq_psd, freq = mlab.psd(self.iq, Fs=self.sample_rate,
355 NFFT=self.psdfftsize,
356 noverlap=self.psdfftsize/4.0,
360 self.iq_psd = 10.0*scipy.log10(abs(fftpack.fftshift(iq_psd)))
361 self.freq = freq - self.sample_rate/2.0
363 def get_specgram(self):
364 winpoints = self.winfunc(self.specfftsize)
365 iq_spec, f, t = mlab.specgram(self.iq, Fs=self.sample_rate,
366 NFFT=self.specfftsize,
367 noverlap=self.specfftsize/4.0,
371 self.iq_spec = 10.0*scipy.log10(abs(iq_spec))
375 def psdFFTComboBoxEdit(self, fftSize):
376 self.psdfftsize = fftSize.toInt()[0]
378 self.update_psd_curves()
380 def specFFTComboBoxEdit(self, fftSize):
381 self.specfftsize = fftSize.toInt()[0]
383 self.update_specgram_curves()
385 def colorComboBoxEdit(self, colorSelection):
386 colorstr = str(colorSelection.toAscii())
387 color_func = self.color_modes[colorstr]
390 def lineStyleComboBoxEdit(self, styleSelection):
391 stylestr = str(styleSelection.toAscii())
392 self.rsym.setStyle(self.line_styles[stylestr])
393 self.isym.setStyle(self.line_styles[stylestr])
394 self.rcurve.setSymbol(self.rsym)
395 self.icurve.setSymbol(self.isym)
396 self.gui.timePlot.replot()
398 def sliderMoved(self, value):
400 pos_end = value + self.gui.plotHBar.pageStep()
402 self.get_data(pos_start, pos_end)
405 self.update_time_curves()
406 self.update_psd_curves()
407 self.update_specgram_curves()
409 def set_sample_rate(self, sr):
410 self.sample_rate = sr
411 srstr = eng_notation.num_to_str(self.sample_rate)
412 self.gui.sampleRateLineEdit.setText(Qt.QString("%1").arg(srstr))
414 def sample_rate_changed(self):
415 srstr = self.gui.sampleRateLineEdit.text().toAscii()
416 self.sample_rate = eng_notation.str_to_num(srstr)
417 self.set_file_pos_box(self.cur_start, self.cur_stop)
418 self.get_data(self.cur_start, self.cur_stop)
421 self.update_time_curves()
422 self.update_psd_curves()
423 self.update_specgram_curves()
425 def set_file_pos_box(self, start, end):
426 tstart = start / self.sample_rate
427 tend = end / self.sample_rate
429 self.gui.filePosStartLineEdit.setText(Qt.QString("%1").arg(start))
430 self.gui.filePosStopLineEdit.setText(Qt.QString("%1").arg(end))
431 self.gui.filePosLengthLineEdit.setText(Qt.QString("%1").arg(end-start))
433 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
434 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
435 self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tend-tstart))
437 def file_position_changed(self):
438 start = self.gui.filePosStartLineEdit.text().toInt()
439 end = self.gui.filePosStopLineEdit.text().toInt()
440 if((start[1] == True) and (end[1] == True)):
441 self.cur_start = start[0]
442 self.cur_stop = end[0]
444 tstart = self.cur_start / self.sample_rate
445 tend = self.cur_stop / self.sample_rate
446 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
447 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
449 self.get_data(self.cur_start, self.cur_stop)
451 self.update_time_curves()
452 self.update_psd_curves()
453 self.update_specgram_curves()
455 # If there's a non-digit character, reset box
458 self.set_file_pos_box(self.cur_start, self.cur_stop)
459 except AttributeError:
463 def file_time_changed(self):
464 tstart = self.gui.fileTimeStartLineEdit.text().toDouble()
465 tstop = self.gui.fileTimeStopLineEdit.text().toDouble()
466 if((tstart[1] == True) and (tstop[1] == True)):
467 self.cur_start = int(tstart[0] * self.sample_rate)
468 self.cur_stop = int(tstop[0] * self.sample_rate)
469 self.get_data(self.cur_start, self.cur_stop)
471 self.gui.filePosStartLineEdit.setText(Qt.QString("%1").arg(self.cur_start))
472 self.gui.filePosStopLineEdit.setText(Qt.QString("%1").arg(self.cur_stop))
474 self.update_time_curves()
475 self.update_psd_curves()
476 self.update_specgram_curves()
477 # If there's a non-digit character, reset box
479 self.set_file_pos_box(self.cur_start, self.cur_stop)
481 def file_length_changed(self):
482 start = self.gui.filePosStartLineEdit.text().toInt()
483 length = self.gui.filePosLengthLineEdit.text().toInt()
485 if((start[1] == True) and (length[1] == True)):
486 self.cur_start = start[0]
487 self.block_length = length[0]
488 self.cur_stop = self.cur_start + self.block_length
490 tstart = self.cur_start / self.sample_rate
491 tend = self.cur_stop / self.sample_rate
492 tlen = self.block_length / self.sample_rate
493 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
494 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
495 self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tlen))
497 self.gui.plotHBar.setPageStep(self.block_length)
499 self.get_data(self.cur_start, self.cur_stop)
503 self.update_time_curves()
504 self.update_psd_curves()
505 self.update_specgram_curves()
506 # If there's a non-digit character, reset box
508 self.set_file_pos_box(self.cur_start, self.cur_stop)
510 def file_time_length_changed(self):
511 tstart = self.gui.fileTimeStartLineEdit.text().toDouble()
512 tlength = self.gui.fileTimeLengthLineEdit.text().toDouble()
513 if((tstart[1] == True) and (tlength[1] == True)):
514 self.cur_start = int(tstart[0] * self.sample_rate)
515 self.block_length = int(tlength[0] * self.sample_rate)
516 self.cur_stop = self.cur_start + self.block_length
518 tstart = self.cur_start / self.sample_rate
519 tend = self.cur_stop / self.sample_rate
520 tlen = self.block_length / self.sample_rate
521 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
522 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
523 self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tlen))
525 self.get_data(self.cur_start, self.cur_stop)
529 self.update_time_curves()
530 self.update_psd_curves()
531 self.update_specgram_curves()
532 # If there's a non-digit character, reset box
534 self.set_file_pos_box(self.cur_start, self.cur_stop)
537 def update_time_curves(self):
538 self.icurve.setData(self.time, self.iq.imag)
539 self.rcurve.setData(self.time, self.iq.real)
541 # Reset the x-axis to the new time scale
542 iqmax = 1.5 * max(max(self.iq.real), max(self.iq.imag))
543 iqmin = 1.5 * min(min(self.iq.real), min(self.iq.imag))
544 self.gui.timePlot.setAxisScale(self.gui.timePlot.xBottom,
547 self.gui.timePlot.setAxisScale(self.gui.timePlot.yLeft,
551 # Set the zoomer base to unzoom to the new axis
552 self.timeZoomer.setZoomBase()
554 self.gui.timePlot.replot()
556 def update_psd_curves(self):
557 self.psdcurve.setData(self.freq, self.iq_psd)
559 self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom,
563 # Set the zoomer base to unzoom to the new axis
564 self.freqZoomer.setZoomBase()
566 self.gui.freqPlot.replot()
568 def update_specgram_curves(self):
569 # We don't have to reset the data for the speccurve here
570 # since this is taken care of in the SpectrogramData class
571 self.specdata.set_data(self.spec_f, self.spec_t, self.iq_spec)
573 # Set the color map based on the new data
574 self.rightAxis.setColorMap(self.spec.data().range(),
575 self.spec.colorMap())
577 # Set the new axis base; include right axis for the intenisty color bar
578 self.gui.specPlot.setAxisScale(self.gui.specPlot.xBottom,
581 self.gui.specPlot.setAxisScale(self.gui.specPlot.yLeft,
584 self.gui.specPlot.setAxisScale(self.gui.specPlot.yRight,
588 # Set the zoomer base to unzoom to the new axis
589 self.specZoomer.setZoomBase()
591 self.gui.specPlot.replot()
593 def tabChanged(self, index):
594 self.gui.timePlot.replot()
595 self.gui.freqPlot.replot()
596 self.gui.specPlot.replot()
598 def change_pen_width(self, width):
599 self.pen_width = width
600 colormode = str(self.gui.colorComboBox.currentText().toAscii())
601 color_func = self.color_modes[colormode]()
603 def change_style_size(self, size):
604 self.rsym.setSize(size)
605 self.isym.setSize(size)
606 self.rcurve.setSymbol(self.rsym)
607 self.icurve.setSymbol(self.isym)
608 self.gui.timePlot.replot()
610 def color_black_on_white(self):
611 blue = QtGui.qRgb(0x00, 0x00, 0xFF)
612 red = QtGui.qRgb(0xFF, 0x00, 0x00)
614 blackPen = Qt.QPen(Qt.QBrush(Qt.QColor("black")), self.pen_width)
615 bluePen = Qt.QPen(Qt.QBrush(Qt.QColor(blue)), self.pen_width)
616 redPen = Qt.QPen(Qt.QBrush(Qt.QColor(red)), self.pen_width)
618 self.gui.timePlot.setCanvasBackground(Qt.QColor("white"))
619 self.gui.freqPlot.setCanvasBackground(Qt.QColor("white"))
620 self.timeZoomer.setTrackerPen(blackPen)
621 self.timeZoomer.setRubberBandPen(blackPen)
622 self.freqZoomer.setTrackerPen(blackPen)
623 self.freqZoomer.setRubberBandPen(blackPen)
624 self.psdcurve.setPen(bluePen)
625 self.rcurve.setPen(bluePen)
626 self.icurve.setPen(redPen)
628 self.rsym.setPen(bluePen)
629 self.isym.setPen(redPen)
631 self.gui.timePlot.replot()
632 self.gui.freqPlot.replot()
634 def color_white_on_black(self):
635 white = QtGui.qRgb(0xFF, 0xFF, 0xFF)
636 red = QtGui.qRgb(0xFF, 0x00, 0x00)
638 whiteBrush = Qt.QBrush(Qt.QColor("white"))
639 whiteBrush = Qt.QBrush(Qt.QColor(white))
640 redBrush = Qt.QBrush(Qt.QColor(red))
642 self.gui.timePlot.setCanvasBackground(QtGui.QColor("black"))
643 self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black"))
644 self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
645 self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
646 self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
647 self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
648 self.psdcurve.setPen(Qt.QPen(whiteBrush, self.pen_width))
649 self.rcurve.setPen(Qt.QPen(whiteBrush, self.pen_width))
650 self.icurve.setPen(Qt.QPen(redBrush, self.pen_width))
652 self.gui.timePlot.replot()
653 self.gui.freqPlot.replot()
656 def color_green_on_black(self):
657 green = QtGui.qRgb(0x00, 0xFF, 0x00)
658 red = QtGui.qRgb(0xFF, 0x00, 0x50)
660 whiteBrush = Qt.QBrush(Qt.QColor("white"))
661 greenBrush = Qt.QBrush(Qt.QColor(green))
662 redBrush = Qt.QBrush(Qt.QColor(red))
664 self.gui.timePlot.setCanvasBackground(QtGui.QColor("black"))
665 self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black"))
666 self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
667 self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
668 self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
669 self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
670 self.psdcurve.setPen(Qt.QPen(greenBrush, self.pen_width))
671 self.rcurve.setPen(Qt.QPen(greenBrush, self.pen_width))
672 self.icurve.setPen(Qt.QPen(redBrush, self.pen_width))
674 self.gui.timePlot.replot()
675 self.gui.freqPlot.replot()
677 def color_blue_on_black(self):
678 blue = QtGui.qRgb(0x00, 0x00, 0xFF)
679 red = QtGui.qRgb(0xFF, 0x00, 0x00)
681 whiteBrush = Qt.QBrush(Qt.QColor("white"))
682 blueBrush = Qt.QBrush(Qt.QColor(blue))
683 redBrush = Qt.QBrush(Qt.QColor(red))
685 self.gui.timePlot.setCanvasBackground(QtGui.QColor("black"))
686 self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black"))
687 self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
688 self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
689 self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
690 self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
691 self.psdcurve.setPen(Qt.QPen(blueBrush, self.pen_width))
692 self.rcurve.setPen(Qt.QPen(blueBrush, self.pen_width))
693 self.icurve.setPen(Qt.QPen(redBrush, self.pen_width))
695 self.gui.timePlot.replot()
696 self.gui.freqPlot.replot()
699 usage="%prog: [options] (input_filename)"
702 parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
703 parser.add_option("-B", "--block-length", type="int", default=8192,
704 help="Specify the block size [default=%default]")
705 parser.add_option("-s", "--start", type="int", default=0,
706 help="Specify where to start in the file [default=%default]")
707 parser.add_option("-R", "--sample-rate", type="float", default=1.0,
708 help="Set the sampler rate of the data [default=%default]")
709 parser.add_option("", "--psd-size", type="int", default=2048,
710 help="Set the size of the PSD FFT [default=%default]")
711 parser.add_option("", "--spec-size", type="int", default=2048,
712 help="Set the size of the spectrogram FFT [default=%default]")
717 parser = setup_options()
718 (options, args) = parser.parse_args ()
725 app = Qt.QApplication(args)
726 gplt = gr_plot_qt(app, filename, options)
729 if __name__ == '__main__':