From 52dd136b4b6944e85711f858b7a4da8e2742b46e Mon Sep 17 00:00:00 2001 From: darksidelemm Date: Mon, 14 Mar 2016 01:28:25 +0000 Subject: [PATCH] Big speedup on fskdemodgui by fixing axes on the eye plot. git-svn-id: https://svn.code.sf.net/p/freetel/code@2744 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/fskdemodgui.py | 79 ++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/codec2-dev/octave/fskdemodgui.py b/codec2-dev/octave/fskdemodgui.py index 0a640dc7..6012c2dc 100644 --- a/codec2-dev/octave/fskdemodgui.py +++ b/codec2-dev/octave/fskdemodgui.py @@ -41,17 +41,24 @@ fest_plot = win.addPlot(title="Tone Frequency Estimation") fest_plot.setLabel('left','Frequency (Hz)') fest_plot.setLabel('bottom','Time (seconds)') eye_plot = win.addPlot(title="Eye Diagram") +# Disable auto-ranging on eye plot and fix axes for a big speedup... +eye_plot.disableAutoRange() +eye_plot.setYRange(0,1) +eye_plot.setXRange(0,15) + # Data arrays... -ebno_data = np.zeros(history_size) -ppm_data = np.zeros(history_size) -fest_data = np.zeros((4,history_size)) +ebno_data = np.zeros(history_size)*np.nan +ppm_data = np.zeros(history_size)*np.nan +fest_data = np.zeros((4,history_size))*np.nan # Curve objects, so we can update them... ebno_curve = ebno_plot.plot(x=history_scale,y=ebno_data) ppm_curve = ppm_plot.plot(x=history_scale,y=ppm_data) -fest1_curve = fest_plot.plot(x=history_scale,y=fest_data[0,:],pen=(255,0,0)) # f1 = Red -fest2_curve = fest_plot.plot(x=history_scale,y=fest_data[1,:],pen=(0,255,0)) # f2 = Blue +fest1_curve = fest_plot.plot(x=history_scale,y=fest_data[0,:],pen='r') # f1 = Red +fest2_curve = fest_plot.plot(x=history_scale,y=fest_data[1,:],pen='g') # f2 = Blue +fest3_curve = fest_plot.plot(x=history_scale,y=fest_data[2,:],pen='b') # f3 = Greem +fest4_curve = fest_plot.plot(x=history_scale,y=fest_data[3,:],pen='m') # f4 = Magenta # Plot update function. Reads from queue, processes and updates plots. def update_plots(): @@ -67,6 +74,13 @@ def update_plots(): sys.stderr.write(str(e)) return + # Roll data arrays + ebno_data[:-1] = ebno_data[1:] + ppm_data[:-1] = ppm_data[1:] + fest_data = np.roll(fest_data,-1,axis=1) + + + # Try reading in the new data points from the dictionary. try: new_ebno = in_data['EbNodB'] new_ppm = in_data['ppm'] @@ -75,42 +89,49 @@ def update_plots(): except Exception as e: print("ERROR reading dict: %s" % e) + # Try reading in the other 2 tones. try: - # Roll data arrays - ebno_data[:-1] = ebno_data[1:] - ppm_data[:-1] = ppm_data[1:] - fest_data = np.roll(fest_data,-1,axis=1) - - # Add in new data points - ebno_data[-1] = new_ebno - ppm_data[-1] = new_ppm - fest_data[0,-1] = new_fest1 - fest_data[1,-1] = new_fest2 - - # Update plots - ebno_curve.setData(x=history_scale,y=ebno_data) - ppm_curve.setData(x=history_scale,y=ppm_data) - fest1_curve.setData(x=history_scale,y=fest_data[0,:],pen=(255,0,0)) # f1 = Red - fest2_curve.setData(x=history_scale,y=fest_data[1,:],pen=(0,255,0)) # f2 = Blue - - except Exception as e: - print(e.strerror) - - # Now try reading in the eye diagram and other tone estimates. + new_fest1 = in_data['f3_est'] + new_fest2 = in_data['f4_est'] + fest_data[2,-1] = new_fest3 + fest_data[3,-1] = new_fest4 + except: + # If we can't read these tones out of the dict, fill with NaN + fest_data[2,-1] = np.nan + fest_data[3,-1] = np.nan + + # Add in new data points + ebno_data[-1] = new_ebno + ppm_data[-1] = new_ppm + fest_data[0,-1] = new_fest1 + fest_data[1,-1] = new_fest2 + + # Update plots + ebno_curve.setData(x=history_scale,y=ebno_data) + ppm_curve.setData(x=history_scale,y=ppm_data) + fest1_curve.setData(x=history_scale,y=fest_data[0,:],pen='r') # f1 = Red + fest2_curve.setData(x=history_scale,y=fest_data[1,:],pen='g') # f2 = Blue + fest3_curve.setData(x=history_scale,y=fest_data[2,:],pen='b') # f3 = Green + fest4_curve.setData(x=history_scale,y=fest_data[3,:],pen='m') # f4 = Magenta + + #Now try reading in and plotting the eye diagram try: eye_data = np.array(in_data['eye_diagram']) + #eye_plot.disableAutoRange() eye_plot.clear() + col_index = 0 for line in eye_data: - eye_plot.plot(line) + eye_plot.plot(line,pen=(col_index,eye_data.shape[0])) + col_index += 1 + #eye_plot.autoRange() except Exception as e: pass - timer = pg.QtCore.QTimer() timer.timeout.connect(update_plots) -timer.start(30) +timer.start(80) # Thread to read from stdin and push into a queue to be processed. -- 2.25.1