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-self.block_length)
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)):
335 end = start + len(iq)
336 self.gui.filePosLengthLineEdit.setText(Qt.QString("%1").arg(len(iq)))
337 self.file_length_changed()
339 tstep = 1.0 / self.sample_rate
341 self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))]
343 self.set_file_pos_box(start, end)
347 # Do we want to do anything about this?
351 winpoints = self.winfunc(self.psdfftsize)
352 iq_psd, freq = mlab.psd(self.iq, Fs=self.sample_rate,
353 NFFT=self.psdfftsize,
354 noverlap=self.psdfftsize/4.0,
358 self.iq_psd = 10.0*scipy.log10(abs(fftpack.fftshift(iq_psd)))
359 self.freq = freq - self.sample_rate/2.0
361 def get_specgram(self):
362 winpoints = self.winfunc(self.specfftsize)
363 iq_spec, f, t = mlab.specgram(self.iq, Fs=self.sample_rate,
364 NFFT=self.specfftsize,
365 noverlap=self.specfftsize/4.0,
369 self.iq_spec = 10.0*scipy.log10(abs(iq_spec))
373 def psdFFTComboBoxEdit(self, fftSize):
374 self.psdfftsize = fftSize.toInt()[0]
376 self.update_psd_curves()
378 def specFFTComboBoxEdit(self, fftSize):
379 self.specfftsize = fftSize.toInt()[0]
381 self.update_specgram_curves()
383 def colorComboBoxEdit(self, colorSelection):
384 colorstr = str(colorSelection.toAscii())
385 color_func = self.color_modes[colorstr]
388 def lineStyleComboBoxEdit(self, styleSelection):
389 stylestr = str(styleSelection.toAscii())
390 self.rsym.setStyle(self.line_styles[stylestr])
391 self.isym.setStyle(self.line_styles[stylestr])
392 self.rcurve.setSymbol(self.rsym)
393 self.icurve.setSymbol(self.isym)
394 self.gui.timePlot.replot()
396 def sliderMoved(self, value):
398 pos_end = value + self.gui.plotHBar.pageStep()
400 self.get_data(pos_start, pos_end)
403 self.update_time_curves()
404 self.update_psd_curves()
405 self.update_specgram_curves()
407 def set_sample_rate(self, sr):
408 self.sample_rate = sr
409 srstr = eng_notation.num_to_str(self.sample_rate)
410 self.gui.sampleRateLineEdit.setText(Qt.QString("%1").arg(srstr))
412 def sample_rate_changed(self):
413 srstr = self.gui.sampleRateLineEdit.text().toAscii()
414 self.sample_rate = eng_notation.str_to_num(srstr)
415 self.set_file_pos_box(self.cur_start, self.cur_stop)
416 self.get_data(self.cur_start, self.cur_stop)
419 self.update_time_curves()
420 self.update_psd_curves()
421 self.update_specgram_curves()
423 def set_file_pos_box(self, start, end):
424 tstart = start / self.sample_rate
425 tend = end / self.sample_rate
427 self.gui.filePosStartLineEdit.setText(Qt.QString("%1").arg(start))
428 self.gui.filePosStopLineEdit.setText(Qt.QString("%1").arg(end))
429 self.gui.filePosLengthLineEdit.setText(Qt.QString("%1").arg(end-start))
431 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
432 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
433 self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tend-tstart))
435 def file_position_changed(self):
436 start = self.gui.filePosStartLineEdit.text().toInt()
437 end = self.gui.filePosStopLineEdit.text().toInt()
438 if((start[1] == True) and (end[1] == True)):
439 self.cur_start = start[0]
440 self.cur_stop = end[0]
442 tstart = self.cur_start / self.sample_rate
443 tend = self.cur_stop / self.sample_rate
444 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
445 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
447 self.get_data(self.cur_start, self.cur_stop)
449 self.update_time_curves()
450 self.update_psd_curves()
451 self.update_specgram_curves()
453 # If there's a non-digit character, reset box
456 self.set_file_pos_box(self.cur_start, self.cur_stop)
457 except AttributeError:
461 def file_time_changed(self):
462 tstart = self.gui.fileTimeStartLineEdit.text().toDouble()
463 tstop = self.gui.fileTimeStopLineEdit.text().toDouble()
464 if((tstart[1] == True) and (tstop[1] == True)):
465 self.cur_start = int(tstart[0] * self.sample_rate)
466 self.cur_stop = int(tstop[0] * self.sample_rate)
467 self.get_data(self.cur_start, self.cur_stop)
469 self.gui.filePosStartLineEdit.setText(Qt.QString("%1").arg(self.cur_start))
470 self.gui.filePosStopLineEdit.setText(Qt.QString("%1").arg(self.cur_stop))
472 self.update_time_curves()
473 self.update_psd_curves()
474 self.update_specgram_curves()
475 # If there's a non-digit character, reset box
477 self.set_file_pos_box(self.cur_start, self.cur_stop)
479 def file_length_changed(self):
480 start = self.gui.filePosStartLineEdit.text().toInt()
481 length = self.gui.filePosLengthLineEdit.text().toInt()
483 if((start[1] == True) and (length[1] == True)):
484 self.cur_start = start[0]
485 self.block_length = length[0]
486 self.cur_stop = self.cur_start + self.block_length
488 tstart = self.cur_start / self.sample_rate
489 tend = self.cur_stop / self.sample_rate
490 tlen = self.block_length / self.sample_rate
491 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
492 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
493 self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tlen))
495 self.gui.plotHBar.setPageStep(self.block_length)
497 self.get_data(self.cur_start, self.cur_stop)
501 self.update_time_curves()
502 self.update_psd_curves()
503 self.update_specgram_curves()
504 # If there's a non-digit character, reset box
506 self.set_file_pos_box(self.cur_start, self.cur_stop)
508 def file_time_length_changed(self):
509 tstart = self.gui.fileTimeStartLineEdit.text().toDouble()
510 tlength = self.gui.fileTimeLengthLineEdit.text().toDouble()
511 if((tstart[1] == True) and (tlength[1] == True)):
512 self.cur_start = int(tstart[0] * self.sample_rate)
513 self.block_length = int(tlength[0] * self.sample_rate)
514 self.cur_stop = self.cur_start + self.block_length
516 tstart = self.cur_start / self.sample_rate
517 tend = self.cur_stop / self.sample_rate
518 tlen = self.block_length / self.sample_rate
519 self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart))
520 self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend))
521 self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tlen))
523 self.get_data(self.cur_start, self.cur_stop)
527 self.update_time_curves()
528 self.update_psd_curves()
529 self.update_specgram_curves()
530 # If there's a non-digit character, reset box
532 self.set_file_pos_box(self.cur_start, self.cur_stop)
535 def update_time_curves(self):
536 self.icurve.setData(self.time, self.iq.imag)
537 self.rcurve.setData(self.time, self.iq.real)
539 # Reset the x-axis to the new time scale
540 iqmax = 1.5 * max(max(self.iq.real), max(self.iq.imag))
541 iqmin = 1.5 * min(min(self.iq.real), min(self.iq.imag))
542 self.gui.timePlot.setAxisScale(self.gui.timePlot.xBottom,
545 self.gui.timePlot.setAxisScale(self.gui.timePlot.yLeft,
549 # Set the zoomer base to unzoom to the new axis
550 self.timeZoomer.setZoomBase()
552 self.gui.timePlot.replot()
554 def update_psd_curves(self):
555 self.psdcurve.setData(self.freq, self.iq_psd)
557 self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom,
561 # Set the zoomer base to unzoom to the new axis
562 self.freqZoomer.setZoomBase()
564 self.gui.freqPlot.replot()
566 def update_specgram_curves(self):
567 # We don't have to reset the data for the speccurve here
568 # since this is taken care of in the SpectrogramData class
569 self.specdata.set_data(self.spec_f, self.spec_t, self.iq_spec)
571 # Set the color map based on the new data
572 self.rightAxis.setColorMap(self.spec.data().range(),
573 self.spec.colorMap())
575 # Set the new axis base; include right axis for the intenisty color bar
576 self.gui.specPlot.setAxisScale(self.gui.specPlot.xBottom,
579 self.gui.specPlot.setAxisScale(self.gui.specPlot.yLeft,
582 self.gui.specPlot.setAxisScale(self.gui.specPlot.yRight,
586 # Set the zoomer base to unzoom to the new axis
587 self.specZoomer.setZoomBase()
589 self.gui.specPlot.replot()
591 def tabChanged(self, index):
592 self.gui.timePlot.replot()
593 self.gui.freqPlot.replot()
594 self.gui.specPlot.replot()
596 def change_pen_width(self, width):
597 self.pen_width = width
598 colormode = str(self.gui.colorComboBox.currentText().toAscii())
599 color_func = self.color_modes[colormode]()
601 def change_style_size(self, size):
602 self.rsym.setSize(size)
603 self.isym.setSize(size)
604 self.rcurve.setSymbol(self.rsym)
605 self.icurve.setSymbol(self.isym)
606 self.gui.timePlot.replot()
608 def color_black_on_white(self):
609 blue = QtGui.qRgb(0x00, 0x00, 0xFF)
610 red = QtGui.qRgb(0xFF, 0x00, 0x00)
612 blackPen = Qt.QPen(Qt.QBrush(Qt.QColor("black")), self.pen_width)
613 bluePen = Qt.QPen(Qt.QBrush(Qt.QColor(blue)), self.pen_width)
614 redPen = Qt.QPen(Qt.QBrush(Qt.QColor(red)), self.pen_width)
616 self.gui.timePlot.setCanvasBackground(Qt.QColor("white"))
617 self.gui.freqPlot.setCanvasBackground(Qt.QColor("white"))
618 self.timeZoomer.setTrackerPen(blackPen)
619 self.timeZoomer.setRubberBandPen(blackPen)
620 self.freqZoomer.setTrackerPen(blackPen)
621 self.freqZoomer.setRubberBandPen(blackPen)
622 self.psdcurve.setPen(bluePen)
623 self.rcurve.setPen(bluePen)
624 self.icurve.setPen(redPen)
626 self.rsym.setPen(bluePen)
627 self.isym.setPen(redPen)
629 self.gui.timePlot.replot()
630 self.gui.freqPlot.replot()
632 def color_white_on_black(self):
633 white = QtGui.qRgb(0xFF, 0xFF, 0xFF)
634 red = QtGui.qRgb(0xFF, 0x00, 0x00)
636 whiteBrush = Qt.QBrush(Qt.QColor("white"))
637 whiteBrush = Qt.QBrush(Qt.QColor(white))
638 redBrush = Qt.QBrush(Qt.QColor(red))
640 self.gui.timePlot.setCanvasBackground(QtGui.QColor("black"))
641 self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black"))
642 self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
643 self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
644 self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
645 self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
646 self.psdcurve.setPen(Qt.QPen(whiteBrush, self.pen_width))
647 self.rcurve.setPen(Qt.QPen(whiteBrush, self.pen_width))
648 self.icurve.setPen(Qt.QPen(redBrush, self.pen_width))
650 self.gui.timePlot.replot()
651 self.gui.freqPlot.replot()
654 def color_green_on_black(self):
655 green = QtGui.qRgb(0x00, 0xFF, 0x00)
656 red = QtGui.qRgb(0xFF, 0x00, 0x50)
658 whiteBrush = Qt.QBrush(Qt.QColor("white"))
659 greenBrush = Qt.QBrush(Qt.QColor(green))
660 redBrush = Qt.QBrush(Qt.QColor(red))
662 self.gui.timePlot.setCanvasBackground(QtGui.QColor("black"))
663 self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black"))
664 self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
665 self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
666 self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
667 self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
668 self.psdcurve.setPen(Qt.QPen(greenBrush, self.pen_width))
669 self.rcurve.setPen(Qt.QPen(greenBrush, self.pen_width))
670 self.icurve.setPen(Qt.QPen(redBrush, self.pen_width))
672 self.gui.timePlot.replot()
673 self.gui.freqPlot.replot()
675 def color_blue_on_black(self):
676 blue = QtGui.qRgb(0x00, 0x00, 0xFF)
677 red = QtGui.qRgb(0xFF, 0x00, 0x00)
679 whiteBrush = Qt.QBrush(Qt.QColor("white"))
680 blueBrush = Qt.QBrush(Qt.QColor(blue))
681 redBrush = Qt.QBrush(Qt.QColor(red))
683 self.gui.timePlot.setCanvasBackground(QtGui.QColor("black"))
684 self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black"))
685 self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
686 self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
687 self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, self.pen_width))
688 self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, self.pen_width))
689 self.psdcurve.setPen(Qt.QPen(blueBrush, self.pen_width))
690 self.rcurve.setPen(Qt.QPen(blueBrush, self.pen_width))
691 self.icurve.setPen(Qt.QPen(redBrush, self.pen_width))
693 self.gui.timePlot.replot()
694 self.gui.freqPlot.replot()
697 usage="%prog: [options] (input_filename)"
700 parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
701 parser.add_option("-B", "--block-length", type="int", default=8192,
702 help="Specify the block size [default=%default]")
703 parser.add_option("-s", "--start", type="int", default=0,
704 help="Specify where to start in the file [default=%default]")
705 parser.add_option("-R", "--sample-rate", type="float", default=1.0,
706 help="Set the sampler rate of the data [default=%default]")
707 parser.add_option("", "--psd-size", type="int", default=2048,
708 help="Set the size of the PSD FFT [default=%default]")
709 parser.add_option("", "--spec-size", type="int", default=2048,
710 help="Set the size of the spectrogram FFT [default=%default]")
715 parser = setup_options()
716 (options, args) = parser.parse_args ()
723 app = Qt.QApplication(args)
724 gplt = gr_plot_qt(app, filename, options)
727 if __name__ == '__main__':