summaryrefslogtreecommitdiff
path: root/gr-digital/python/digital/qamlike.py
blob: 2f8c8553399963d2c7b291addbfa1eb932f176dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright 2013 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.
# 

"""
This file contains constellations that are similar to QAM, but are not perfect squares.
"""

import digital_swig
from qam import large_ampls_to_corners_mapping

def qam32_holeinside_constellation(large_ampls_to_corners=False):
    # First make constellation for one quadrant.
    #      0   1   2 
    # 2 - 010 111 110
    # 1 - 011 101 100
    # 0 - 000 001

    # Have put hole in the side rather than corner.
    # Corner point is helpful for frequency locking.

    # It has an attempt at some gray-coding, but not
    # a very good one.

    # Indices are (horizontal, vertical).
    indices_and_numbers = (
        ((0, 0), 0b000),
        ((0, 1), 0b011),
        ((0, 2), 0b010),
        ((1, 0), 0b001),
        ((1, 1), 0b101),
        ((1, 2), 0b111),
        ((2, 1), 0b100),
        ((2, 2), 0b110),
        )
    points = [None]*32
    for indices, number in indices_and_numbers:
        p_in_quadrant = 0.5+indices[0] + 1j*(0.5+indices[1])
        for quadrant in range(4):
            index = number + 8 * quadrant
            rotation = pow(1j, quadrant)
            p = p_in_quadrant * rotation
            points[index] = p
    side = 6
    width = 1
    # Double number of boxes on side
    # This is so that points in the 'hole' get assigned correctly.
    side = 12
    width = 0.5
    pre_diff_code = []
    if not large_ampls_to_corners:
        constellation = digital_swig.constellation_rect(points, pre_diff_code, 4,
                                                        side, side, width, width)
    else:
        sector_values = large_ampls_to_corners_mapping(side, points, width)
        constellation = digital_swig.constellation_expl_rect(
            points, pre_diff_code, 4, side, side, width, width, sector_values)
    return constellation