| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import math
- import numpy as np
- import tensorflow as tf
- class Signal:
- @property
- def rect_x(self) -> np.ndarray:
- return self.rect[:, 0]
- @property
- def rect_y(self) -> np.ndarray:
- return self.rect[:, 1]
- @property
- def rect(self) -> np.ndarray:
- raise NotImplemented("Not implemented")
- def set_rect_xy(self, x_mat: np.ndarray, y_mat: np.ndarray):
- raise NotImplemented("Not implemented")
- def set_rect(self, mat: np.ndarray):
- raise NotImplemented("Not implemented")
- @property
- def apf(self):
- raise NotImplemented("Not implemented")
- class COMComponent:
- def __init__(self, epoch_size=100):
- self._epoch = epoch_size
- class Channel(COMComponent):
- """
- Communication base module containing all model structure.
- This model is just empty therefore just bypasses any input to output
- """
- def forward(self, values: Signal) -> Signal:
- raise NotImplemented("Need to define forward function")
- def forward_tensor(self, tensor: tf.Tensor) -> tf.Tensor:
- """
- Forward operation optimised for tensorflow tensors
- """
- raise NotImplemented("Need to define forward_tensor function")
- class ModComponent(COMComponent):
- def __init__(self, alphabet_size, **kwargs):
- super().__init__(**kwargs)
- self.N = math.ceil(math.log2(alphabet_size))
- self.alphabet_size = alphabet_size
- class Modulator(ModComponent):
- def forward(self, binary: np.ndarray) -> Signal:
- """
- :param binary: raw bytes as input (most be dtype=bool)
- :return: amplitude, phase, frequency
- """
- raise NotImplemented("Need to define forward function")
- class Demodulator(ModComponent):
- def forward(self, values: Signal) -> np.ndarray:
- """
- :param values: value generator, each iteration returns tuple of (amplitude, phase, frequency)
- :return: binary resulting values (dtype=bool)
- """
- raise NotImplemented("Need to define forward function")
|