From 364ccffeb3e4de9d0ecf8d766025b1b26e51cfd1 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Tue, 5 Apr 2016 18:19:14 +0200 Subject: [PATCH] add mapping function with hard mapping to Modem class --- commpy/modulation.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commpy/modulation.py b/commpy/modulation.py index d3873ed..b85ce98 100644 --- a/commpy/modulation.py +++ b/commpy/modulation.py @@ -93,6 +93,14 @@ def demodulate(self, input_symbols, demod_type, noise_var = 0): return demod_bits + def mapping(self, input_symbols, map_type, noise_var = 0): + if map_type == 'hard': + index_list = map(lambda i: self.constellation[argmin(abs(input_symbols[i] - self.constellation))], \ + xrange(0, len(input_symbols))) + else: + pass + return index_list + class PSKModem(Modem): """ Creates a Phase Shift Keying (PSK) Modem object. """