# Path: commpy/modulation.py
# class PSKModem(Modem):
#     """ Creates a Phase Shift Keying (PSK) Modem object.
# 
#         Parameters
#         ----------
#         m : int
#             Size of the PSK constellation.
# 
#         Attributes
#         ----------
#         constellation : 1D-ndarray of complex
#                         Modem constellation. If changed, the length of the new constellation must be a power of 2.
# 
#         Es            : float
#                         Average energy per symbols.
# 
#         m             : integer
#                         Constellation length.
# 
#         num_bits_symb : integer
#                         Number of bits per symbol.
# 
#         Raises
#         ------
#         ValueError
#                         If the constellation is changed to an array-like with length that is not a power of 2.
#         """
# 
#     def __init__(self, m):
#         """ Creates a Phase Shift Keying (PSK) Modem object. """
# 
#         num_bits_symbol = log2(m)
#         if num_bits_symbol != int(num_bits_symbol):
#             raise ValueError('Constellation length must be a power of 2.')
# 
#         super().__init__(exp(1j * arange(0, 2 * pi, 2 * pi / m)))
# 
# class QAMModem(Modem):
#     """ Creates a Quadrature Amplitude Modulation (QAM) Modem object.
# 
#         Parameters
#         ----------
#         m : int
#             Size of the PSK constellation.
# 
#         Attributes
#         ----------
#         constellation : 1D-ndarray of complex
#                         Modem constellation. If changed, the length of the new constellation must be a power of 2.
# 
#         Es            : float
#                         Average energy per symbols.
# 
#         m             : integer
#                         Constellation length.
# 
#         num_bits_symb : integer
#                         Number of bits per symbol.
# 
#         Raises
#         ------
#         ValueError
#                         If the constellation is changed to an array-like with length that is not a power of 2.
#                         If the parameter m would lead to an non-square QAM during initialization.
#     """
# 
#     def __init__(self, m):
#         """ Creates a Quadrature Amplitude Modulation (QAM) Modem object.
# 
#         Parameters
#         ----------
#         m : int
#             Size of the QAM constellation. Must lead to a square QAM (ie sqrt(m) is an integer).
# 
#         Raises
#         ------
#         ValueError
#                         If m would lead to an non-square QAM.
#         """
# 
#         num_symb_pam = sqrt(m)
#         if num_symb_pam != int(num_symb_pam):
#             raise ValueError('m must lead to a square QAM.')
# 
#         pam = arange(-num_symb_pam + 1, num_symb_pam, 2)
#         constellation = tile(hstack((pam, pam[::-1])), int(num_symb_pam) // 2) * 1j + pam.repeat(num_symb_pam)
#         super().__init__(constellation)


from commpy.modulation import PSKModem, QAMModem
# Authors: CommPy contributors
# License: BSD 3-Clause


# =============================================================================
# Example constellation plot of Modem
# =============================================================================

# Constellation corresponding to PSKModem for 4 bits per symbols
psk = PSKModem(16)
psk.plot_constellation()

# Constellation corresponding to QAMModem for 2 bits per symbols
qam = QAMModem(4)

# Path: commpy/modulation.py
# class PSKModem(Modem):
#     """ Creates a Phase Shift Keying (PSK) Modem object.
# 
#         Parameters
#         ----------
#         m : int
#             Size of the PSK constellation.
# 
#         Attributes
#         ----------
#         constellation : 1D-ndarray of complex
#                         Modem constellation. If changed, the length of the new constellation must be a power of 2.
# 
#         Es            : float
#                         Average energy per symbols.
# 
#         m             : integer
#                         Constellation length.
# 
#         num_bits_symb : integer
#                         Number of bits per symbol.
# 
#         Raises
#         ------
#         ValueError
#                         If the constellation is changed to an array-like with length that is not a power of 2.
#         """
# 
#     def __init__(self, m):
#         """ Creates a Phase Shift Keying (PSK) Modem object. """
# 
#         num_bits_symbol = log2(m)
#         if num_bits_symbol != int(num_bits_symbol):
#             raise ValueError('Constellation length must be a power of 2.')
# 
#         super().__init__(exp(1j * arange(0, 2 * pi, 2 * pi / m)))
# 
# class QAMModem(Modem):
#     """ Creates a Quadrature Amplitude Modulation (QAM) Modem object.
# 
#         Parameters
#         ----------
#         m : int
#             Size of the PSK constellation.
# 
#         Attributes
#         ----------
#         constellation : 1D-ndarray of complex
#                         Modem constellation. If changed, the length of the new constellation must be a power of 2.
# 
#         Es            : float
#                         Average energy per symbols.
# 
#         m             : integer
#                         Constellation length.
# 
#         num_bits_symb : integer
#                         Number of bits per symbol.
# 
#         Raises
#         ------
#         ValueError
#                         If the constellation is changed to an array-like with length that is not a power of 2.
#                         If the parameter m would lead to an non-square QAM during initialization.
#     """
# 
#     def __init__(self, m):
#         """ Creates a Quadrature Amplitude Modulation (QAM) Modem object.
# 
#         Parameters
#         ----------
#         m : int
#             Size of the QAM constellation. Must lead to a square QAM (ie sqrt(m) is an integer).
# 
#         Raises
#         ------
#         ValueError
#                         If m would lead to an non-square QAM.
#         """
# 
#         num_symb_pam = sqrt(m)
#         if num_symb_pam != int(num_symb_pam):
#             raise ValueError('m must lead to a square QAM.')
# 
#         pam = arange(-num_symb_pam + 1, num_symb_pam, 2)
#         constellation = tile(hstack((pam, pam[::-1])), int(num_symb_pam) // 2) * 1j + pam.repeat(num_symb_pam)
#         super().__init__(constellation)


# Path: commpy/examples/plotConsModem.py
from commpy.modulation import PSKModem, QAMModem

# Authors: CommPy contributors
# License: BSD 3-Clause


# =============================================================================
# Example constellation plot of Modem
# =============================================================================

# Constellation corresponding to PSKModem for 4 bits per symbols
psk = PSKModem(16)
psk.plot_constellation()

# Constellation corresponding to QAMModem for 2 bits per symbols
qam = QAMModem(4)

qam.plot_constellation()