summaryrefslogtreecommitdiff
path: root/gr-digital/python/digital/psk.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python/digital/psk.py')
-rw-r--r--gr-digital/python/digital/psk.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/gr-digital/python/digital/psk.py b/gr-digital/python/digital/psk.py
index 0e0c65ea2b..5518ba55f3 100644
--- a/gr-digital/python/digital/psk.py
+++ b/gr-digital/python/digital/psk.py
@@ -1,36 +1,40 @@
#
# Copyright 2005,2006,2011 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.
-#
+#
"""
PSK modulation and demodulation.
"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import unicode_literals
+
from math import pi, log
from cmath import exp
-import digital_swig
-import modulation_utils
-from utils import mod_codes, gray_code
-from generic_mod_demod import generic_mod, generic_demod
-from generic_mod_demod import shared_mod_args, shared_demod_args
+from . import digital_swig
+from . import modulation_utils
+from .utils import mod_codes, gray_code
+from .generic_mod_demod import generic_mod, generic_demod
+from .generic_mod_demod import shared_mod_args, shared_demod_args
# Default number of points in constellation.
_def_constellation_points = 4
@@ -56,7 +60,7 @@ def create_encodings(mod_code, arity, differential):
else:
raise ValueError('That modulation code is not implemented for this constellation.')
return (pre_diff_code, post_diff_code)
-
+
# /////////////////////////////////////////////////////////////////////////////
# PSK constellation
# /////////////////////////////////////////////////////////////////////////////
@@ -68,7 +72,7 @@ def psk_constellation(m=_def_constellation_points, mod_code=_def_mod_code,
"""
k = log(m) / log(2.0)
if (k != int(k)):
- raise StandardError('Number of constellation points must be a power of two.')
+ raise Exception('Number of constellation points must be a power of two.')
points = [exp(2*pi*(0+1j)*i/m) for i in range(0,m)]
pre_diff_code, post_diff_code = create_encodings(mod_code, m, differential)
if post_diff_code is not None:
@@ -84,7 +88,7 @@ def psk_constellation(m=_def_constellation_points, mod_code=_def_mod_code,
class psk_mod(generic_mod):
"""
Hierarchical block for RRC-filtered PSK modulation.
-
+
The input is a byte stream (unsigned char), treated as a series of packed
symbols. Symbols are grouped from MSB to LSB.
@@ -118,7 +122,7 @@ class psk_demod(generic_demod):
"""
Hierarchical block for RRC-filtered PSK modulation.
-
+
The input is a complex modulated signal at baseband.
The output is a stream of bytes, each representing a recovered bit.