summaryrefslogtreecommitdiff
path: root/gr-digital/examples/example_costas.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/examples/example_costas.py')
-rw-r--r--gr-digital/examples/example_costas.py42
1 files changed, 22 insertions, 20 deletions
diff --git a/gr-digital/examples/example_costas.py b/gr-digital/examples/example_costas.py
index 1db3287578..b7185ba974 100644
--- a/gr-digital/examples/example_costas.py
+++ b/gr-digital/examples/example_costas.py
@@ -24,6 +24,7 @@ except ImportError:
print("Error: could not import pyplot (http://matplotlib.sourceforge.net/)")
sys.exit(1)
+
class example_costas(gr.top_block):
def __init__(self, N, sps, rolloff, ntaps, bw, noise, foffset, toffset, poffset):
gr.top_block.__init__(self)
@@ -31,8 +32,8 @@ class example_costas(gr.top_block):
rrc_taps = filter.firdes.root_raised_cosine(
sps, sps, 1.0, rolloff, ntaps)
- data = 2.0*numpy.random.randint(0, 2, N) - 1.0
- data = numpy.exp(1j*poffset) * data
+ data = 2.0 * numpy.random.randint(0, 2, N) - 1.0
+ data = numpy.exp(1j * poffset) * data
self.src = blocks.vector_source_c(data.tolist(), False)
self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps)
@@ -45,28 +46,29 @@ class example_costas(gr.top_block):
self.connect(self.src, self.rrc, self.chn, self.cst, self.vsnk_cst)
self.connect(self.rrc, self.vsnk_src)
- self.connect((self.cst,1), self.vsnk_frq)
+ self.connect((self.cst, 1), self.vsnk_frq)
+
def main():
parser = ArgumentParser(conflict_handler="resolve")
parser.add_argument("-N", "--nsamples", type=int, default=2000,
- help="Set the number of samples to process [default=%(default)r]")
+ help="Set the number of samples to process [default=%(default)r]")
parser.add_argument("-S", "--sps", type=int, default=4,
- help="Set the samples per symbol [default=%(default)r]")
+ help="Set the samples per symbol [default=%(default)r]")
parser.add_argument("-r", "--rolloff", type=eng_float, default=0.35,
- help="Set the rolloff factor [default=%(default)r]")
- parser.add_argument("-W", "--bandwidth", type=eng_float, default=2*numpy.pi/100.0,
- help="Set the loop bandwidth [default=%(default)r]")
+ help="Set the rolloff factor [default=%(default)r]")
+ parser.add_argument("-W", "--bandwidth", type=eng_float, default=2 * numpy.pi / 100.0,
+ help="Set the loop bandwidth [default=%(default)r]")
parser.add_argument("-n", "--ntaps", type=int, default=45,
- help="Set the number of taps in the filters [default=%(default)r]")
+ help="Set the number of taps in the filters [default=%(default)r]")
parser.add_argument("--noise", type=eng_float, default=0.0,
- help="Set the simulation noise voltage [default=%(default)r]")
+ help="Set the simulation noise voltage [default=%(default)r]")
parser.add_argument("-f", "--foffset", type=eng_float, default=0.0,
- help="Set the simulation's normalized frequency offset (in Hz) [default=%(default)r]")
+ help="Set the simulation's normalized frequency offset (in Hz) [default=%(default)r]")
parser.add_argument("-t", "--toffset", type=eng_float, default=1.0,
- help="Set the simulation's timing offset [default=%(default)r]")
+ help="Set the simulation's timing offset [default=%(default)r]")
parser.add_argument("-p", "--poffset", type=eng_float, default=0.707,
- help="Set the simulation's phase offset [default=%(default)r]")
+ help="Set the simulation's phase offset [default=%(default)r]")
args = parser.parse_args()
# Adjust N for the interpolation by sps
@@ -81,21 +83,21 @@ def main():
data_src = numpy.array(put.vsnk_src.data())
# Convert the FLL's LO frequency from rads/sec to Hz
- data_frq = numpy.array(put.vsnk_frq.data()) / (2.0*numpy.pi)
+ data_frq = numpy.array(put.vsnk_frq.data()) / (2.0 * numpy.pi)
# adjust this to align with the data.
- data_cst = numpy.array(3*[0,]+list(put.vsnk_cst.data()))
+ data_cst = numpy.array(3 * [0, ] + list(put.vsnk_cst.data()))
# Plot the Costas loop's LO frequency
- f1 = pyplot.figure(1, figsize=(12,10), facecolor='w')
- s1 = f1.add_subplot(2,2,1)
+ f1 = pyplot.figure(1, figsize=(12, 10), facecolor='w')
+ s1 = f1.add_subplot(2, 2, 1)
s1.plot(data_frq)
s1.set_title("Costas LO")
s1.set_xlabel("Samples")
s1.set_ylabel("Frequency (normalized Hz)")
# Plot the IQ symbols
- s3 = f1.add_subplot(2,2,2)
+ s3 = f1.add_subplot(2, 2, 2)
s3.plot(data_src.real, data_src.imag, "o")
s3.plot(data_cst.real, data_cst.imag, "rx")
s3.set_title("IQ")
@@ -105,7 +107,7 @@ def main():
s3.set_ylim([-2, 2])
# Plot the symbols in time
- s4 = f1.add_subplot(2,2,3)
+ s4 = f1.add_subplot(2, 2, 3)
s4.set_position([0.125, 0.05, 0.775, 0.4])
s4.plot(data_src.real, "o-")
s4.plot(data_cst.real, "rx-")
@@ -115,9 +117,9 @@ def main():
pyplot.show()
+
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
-