summaryrefslogtreecommitdiff
path: root/gr-qtgui/apps/plot_base.py
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-01-19 10:57:16 -0500
committerTom Rondeau <trondeau@vt.edu>2013-01-19 10:57:16 -0500
commit92c3c6c4840cb40b6a2bd8fd5e253c8a206260ad (patch)
tree6ebc719a986a0387b590d7aefe766c6faf3b99e4 /gr-qtgui/apps/plot_base.py
parent6b9231765fbfaff8135a0820b91e890055228d10 (diff)
qtgui: improved PSD plotting tools to use more complete and complex base classes.
Some tweaks to time plotters for better GUI interactions.
Diffstat (limited to 'gr-qtgui/apps/plot_base.py')
-rw-r--r--gr-qtgui/apps/plot_base.py97
1 files changed, 31 insertions, 66 deletions
diff --git a/gr-qtgui/apps/plot_base.py b/gr-qtgui/apps/plot_base.py
index a991de48e3..936218969c 100644
--- a/gr-qtgui/apps/plot_base.py
+++ b/gr-qtgui/apps/plot_base.py
@@ -44,7 +44,7 @@ try:
except ImportError:
from plot_form import *
-def read_samples(filename, start, in_size, dtype, dtype_size):
+def read_samples(filename, start, in_size, min_size, dtype, dtype_size):
# Read in_size number of samples from file
fhandle = open(filename, 'r')
fhandle.seek(start*dtype_size, 0)
@@ -54,87 +54,52 @@ def read_samples(filename, start, in_size, dtype, dtype_size):
data = data.tolist()
fhandle.close()
- if(len(data) < in_size):
- print "Warning: read in {0} samples but asked for {1} samples.".format(
- len(data), in_size)
+ if(min_size > 0):
+ if(len(data) < in_size):
+ print "Warning: read in {0} samples but asked for {1} samples.".format(
+ len(data), in_size)
+ else:
+ # If we have to, append 0's to create min_size samples of data
+ if(len(data) < min_size):
+ data += (min_size - len(data)) * [dtype(0)]
- return data, data_min, data_max
-
-def read_samples_f(filename, start, in_size):
- return read_samples(filename, start, in_size, scipy.float32, gr.sizeof_float)
-
-def read_samples_i(filename, start, in_size):
- return read_samples(filename, start, in_size, scipy.int32, gr.sizeof_int)
-
-def read_samples_s(filename, start, in_size):
- return read_samples(filename, start, in_size, scipy.int16, gr.sizeof_short)
-
-def read_samples_b(filename, start, in_size):
- return read_samples(filename, start, in_size, scipy.uint8, gr.sizeof_char)
-
-def read_samples_c(filename, start, in_size):
- # Complex samples are handled differently
- fhandle = open(filename, 'r')
- fhandle.seek(start*gr.sizeof_gr_complex, 0)
- data = scipy.fromfile(fhandle, dtype=scipy.complex64, count=in_size)
- data_min = 1.1*float(min(data.real.min(), data.imag.min()))
- data_max = 1.1*float(max(data.real.max(), data.imag.max()))
- data = data.tolist()
- fhandle.close()
-
- if(len(data) < in_size):
- print "Warning: read in {0} samples but asked for {1} samples.".format(
- len(data), in_size)
-
- return data, data_min, data_max
-
-def read_samples_and_pad(filename, start, in_size, min_size,
- dtype, dtype_size):
- # Read in_size number of samples from file
- fhandle = open(filename, 'r')
- fhandle.seek(start*gr.sizeof_char, 0)
- data = scipy.fromfile(fhandle, dtype=scipy.uint8, count=in_size)
- data_min = 1.1*data.min()
- data_max = 1.1*data.max()
- data = data.tolist()
- fhandle.close()
-
- # If we have to, append 0's to create min_size samples of data
- if(len(data) < min_size):
- data += (min_size - len(data)) * [scipy.uint8(0)]
return data, data_min, data_max
-def read_samples_and_pad_b(filename, start, in_size, min_size):
- return read_samples_and_pad(filename, start, in_size, min_size,
- scipy.uint8, gr.sizeof_char)
+def read_samples_f(filename, start, in_size, min_size=0):
+ return read_samples(filename, start, in_size, min_size,
+ scipy.float32, gr.sizeof_float)
-def read_samples_and_pad_s(filename, start, in_size, min_size):
- return read_samples_and_pad(filename, start, in_size, min_size,
- scipy.uint16, gr.sizeof_short)
+def read_samples_i(filename, start, in_size, min_size=0):
+ return read_samples(filename, start, in_size, min_size,
+ scipy.int32, gr.sizeof_int)
-def read_samples_and_pad_i(filename, start, in_size, min_size):
- return read_samples_and_pad(filename, start, in_size, min_size,
- scipy.uint32, gr.sizeof_int)
+def read_samples_s(filename, start, in_size, min_size=0):
+ return read_samples(filename, start, in_size, min_size,
+ scipy.int16, gr.sizeof_short)
-def read_samples_and_pad_f(filename, start, in_size, min_size):
- return read_samples_and_pad(filename, start, in_size, min_size,
- scipy.float32, gr.sizeof_float)
+def read_samples_b(filename, start, in_size, min_size=0):
+ return read_samples(filename, start, in_size, min_size,
+ scipy.uint8, gr.sizeof_char)
-def read_samples_and_pad_c(filename, start, in_size, min_size):
- # Read in_size number of samples from file
+def read_samples_c(filename, start, in_size, min_size=0):
+ # Complex samples are handled differently
fhandle = open(filename, 'r')
fhandle.seek(start*gr.sizeof_gr_complex, 0)
-
data = scipy.fromfile(fhandle, dtype=scipy.complex64, count=in_size)
data_min = 1.1*float(min(data.real.min(), data.imag.min()))
data_max = 1.1*float(max(data.real.max(), data.imag.max()))
data = data.tolist()
fhandle.close()
- # If we have to, append 0's to create min_size samples of data
- if(len(data) < min_size):
- data += (min_size - len(data)) * [complex(0,0)]
+ if(min_size > 0):
+ if(len(data) < in_size):
+ print "Warning: read in {0} samples but asked for {1} samples.".format(
+ len(data), in_size)
+ else:
+ # If we have to, append 0's to create min_size samples of data
+ if(len(data) < min_size):
+ data += (min_size - len(data)) * [complex(0,0)]
return data, data_min, data_max