aboutsummaryrefslogtreecommitdiffstats
path: root/op25/gr-op25_repeater
diff options
context:
space:
mode:
authorMax <ikj1234i@yahoo.com>2017-10-17 22:32:04 -0400
committerMax <ikj1234i@yahoo.com>2017-10-17 22:32:04 -0400
commite31207cf8839982fc1a68e084d0d8fd2fb25e45f (patch)
tree30024d60f07f92525279bdf64cfce7ab8b189ea2 /op25/gr-op25_repeater
parent6ddc299edfe74fbba04e805a2e5e73c91ac8de12 (diff)
plot module enhancements thx Graham
Diffstat (limited to 'op25/gr-op25_repeater')
-rw-r--r--op25/gr-op25_repeater/apps/gr_gnuplot.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/op25/gr-op25_repeater/apps/gr_gnuplot.py b/op25/gr-op25_repeater/apps/gr_gnuplot.py
index 58ccc72..61ce66f 100644
--- a/op25/gr-op25_repeater/apps/gr_gnuplot.py
+++ b/op25/gr-op25_repeater/apps/gr_gnuplot.py
@@ -35,6 +35,7 @@ GNUPLOT = '/usr/bin/gnuplot'
FFT_AVG = 0.25
FFT_BINS = 512
+PEAK_WIDTH = 0.050
class wrap_gp(object):
def __init__(self, sps=_def_sps):
@@ -46,6 +47,8 @@ class wrap_gp(object):
self.freqs = ()
self.avg_pwr = np.zeros(FFT_BINS)
self.buf = []
+ self.peak_freq = None
+ self.peak_pwr = 0.0
self.attach_gp()
@@ -89,15 +92,20 @@ class wrap_gp(object):
self.buf = []
plots.append('"-" with dots')
elif mode == 'fft':
+ self.peak_pwr = 0.0
self.ffts = np.fft.fft(self.buf * np.blackman(BUFSZ)) / (0.42 * BUFSZ)
self.ffts = np.fft.fftshift(self.ffts)
self.freqs = np.fft.fftfreq(len(self.ffts))
self.freqs = np.fft.fftshift(self.freqs)
+ tune_freq = (self.center_freq - self.relative_freq) / 1e6
if self.center_freq and self.width:
self.freqs = ((self.freqs * self.width) + self.center_freq) / 1e6
for i in xrange(len(self.ffts)):
self.avg_pwr[i] = ((1.0 - FFT_AVG) * self.avg_pwr[i]) + (FFT_AVG * np.abs(self.ffts[i]))
s += '%f\t%f\n' % (self.freqs[i], 20 * np.log10(self.avg_pwr[i]))
+ if (self.freqs[i] >= (tune_freq - PEAK_WIDTH)) and (self.freqs[i] <= (tune_freq + PEAK_WIDTH)) and (self.avg_pwr[i] > self.peak_pwr):
+ self.peak_pwr = self.avg_pwr[i]
+ self.peak_freq = self.freqs[i]
s += 'e\n'
self.buf = []
plots.append('"-" with lines')
@@ -128,13 +136,14 @@ class wrap_gp(object):
if self.center_freq:
arrow_pos = (self.center_freq - self.relative_freq) / 1e6
h+= 'set arrow from %f, graph 0 to %f, graph 1 nohead\n' % (arrow_pos, arrow_pos)
- h+= 'set title "Tuned to %f Mhz"\n' % ((self.center_freq - self.relative_freq) / 1e6)
+ h+= 'set title "Tuned to %f Mhz, peak signal offset %f"\n' % (arrow_pos, (self.peak_freq - arrow_pos))
dat = '%splot %s\n%s' % (h, ','.join(plots), s)
self.gp.stdin.write(dat)
return consumed
def set_center_freq(self, f):
self.center_freq = f
+ self.peak_freq = f
def set_relative_freq(self, f):
self.relative_freq = f