summaryrefslogtreecommitdiff
path: root/gr-digital/examples/berawgn.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/examples/berawgn.py')
-rwxr-xr-xgr-digital/examples/berawgn.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/gr-digital/examples/berawgn.py b/gr-digital/examples/berawgn.py
index d58dfbaaeb..2d95a1345f 100755
--- a/gr-digital/examples/berawgn.py
+++ b/gr-digital/examples/berawgn.py
@@ -1,4 +1,25 @@
#!/usr/bin/env python
+#
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
"""
BER simulation for QPSK signals, compare to theoretical values.
Change the N_BITS value to simulate more bits per Eb/N0 value,
@@ -14,10 +35,20 @@ magnitude below what you chose for N_BITS.
import math
import numpy
-from scipy.special import erfc
-import pylab
from gnuradio import gr, digital
+try:
+ from scipy.special import erfc
+except ImportError:
+ print "Error: could not import scipy (http://www.scipy.org/)"
+ sys.exit(1)
+
+try:
+ import pylab
+except ImportError:
+ print "Error: could not import pylab (http://matplotlib.sourceforge.net/)"
+ sys.exit(1)
+
# Best to choose powers of 10
N_BITS = 1e7
RAND_SEED = 42
@@ -59,7 +90,7 @@ class BERAWGNSimu(gr.top_block):
# Source is N_BITS bits, non-repeated
data = map(int, numpy.random.randint(0, self.const.arity(), N_BITS/self.const.bits_per_symbol()))
src = gr.vector_source_b(data, False)
- mod = gr.chunks_to_symbols_bc((self.const.points()), 1)
+ mod = digital.chunks_to_symbols_bc((self.const.points()), 1)
add = gr.add_vcc()
noise = gr.noise_source_c(gr.GR_GAUSSIAN,
self.EbN0_to_noise_voltage(EbN0),