@@ -138,37 +138,10 @@ def demodulate(self, input_symbols, demod_type, noise_var=0):
138138
139139 def plot_constellation (self ):
140140 """ Plot the constellation """
141- # init some arrays
142- beta = self .num_bits_symbol
143- numbit = '0' + str (beta ) + 'b'
144- Bin = []
145- mot = []
146- const = []
147-
148- # creation of w array
149- reel = [pow (2 , i ) for i in range (beta // 2 - 1 , - 1 , - 1 )]
150- im = [1j * pow (2 , i ) for i in range (beta // 2 - 1 , - 1 , - 1 )]
151- w = concatenate ((reel , im ), axis = None )
152-
153- listBin = [format (i , numbit ) for i in range (2 ** beta )]
154- for e in listBin :
155- for i in range (beta ):
156- Bin .append (ord (e [i ]) - 48 )
157- if ord (e [i ]) - 48 == 0 :
158- mot .append (- 1 )
159- else :
160- mot .append (1 )
161- const .append (dot (w , mot ))
162- mot = []
163- symb = self .modulate (Bin )
164-
165- # plot the symbols
166- x = symb .real
167- y = symb .imag
141+ plt .scatter (self .constellation .real , self .constellation .imag )
168142
169- plt .plot (x , y , '+' , linewidth = 4 )
170- for i in range (len (x )):
171- plt .text (x [i ], y [i ], listBin [i ])
143+ for symb in self .constellation :
144+ plt .text (symb .real + .2 , symb .imag , self .demodulate (symb , 'hard' ))
172145
173146 plt .title ('Constellation' )
174147 plt .grid ()
@@ -193,7 +166,6 @@ def constellation(self, value):
193166 self .Es = signal_power (self .constellation )
194167 self .m = self ._constellation .size
195168 self .num_bits_symbol = int (num_bits_symbol )
196- self .constellation_mapping = arange (self .m )
197169
198170
199171class PSKModem (Modem ):
0 commit comments