Module rpps.base.data

Classes

class Analog (data=None)
Expand source code
class Analog(_Data):
    pass

Ancestors

  • rpps.base.data._Data
class Bit (data=None)
Expand source code
class Bit(Digital):
    dtype = bool

    def __str__(self):
        return f"{super().__str__()}:{self.bin}"

    @property
    def bin(self):
        return self._data.astype(int)

    def to_bytes(self):
        if isinstance(self._data, np.ndarray):
            return np.packbits(self.data)

    @classmethod
    def from_bytes(cls, data):
        if data is None:
            return cls()
        elif instance(data, Byte):
            return cls(data.to_bits())
        elif isinstance(data, bytes):
            return cls(np.unpackbits(np.array(data)))
        elif isinstance(data, np.ndarray):
            if data.dtype == np.uint8:
                return cls(np.unpackbits(data))
            elif data.dtype == np.bool:
                return cls(data)
            raise NotImplementedError(f"Cannot convert {type(data)} {data.shape} {data.dtype} to {cls.__name__}")
        raise NotImplementedError(f"Cannot convert {type(data)} to {cls.__name__}")

Ancestors

Class variables

var dtype

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

Static methods

def from_bytes(data)

Instance variables

prop bin
Expand source code
@property
def bin(self):
    return self._data.astype(int)

Methods

def to_bytes(self)
Expand source code
def to_bytes(self):
    if isinstance(self._data, np.ndarray):
        return np.packbits(self.data)
class Byte (data=None)
Expand source code
class Byte(Digital):
    dtype = np.uint8

    def __str__(self):
        return f"{super().__str__()}:{self.hex}"

    @property
    def hex(self):
        return self._data.tobytes().hex()

    def to_bits(self):
        if isinstance(self._data, np.ndarray):
            return np.unpackbits(self.data)

    @classmethod
    def from_bits(cls, data):
        if data is None:
            return cls()
        elif instance(data, Bits):
            return cls(data.to_bytes())
        elif isinstance(data, bytes):
            return cls(np.frombuffer(data, dtype=self.dtype))
        elif isinstance(data, np.ndarray):
            if data.dtype == np.uint8:
                return cls(data)
            elif data.dtype == np.bool:
                return cls(np.packbits(data))
            raise NotImplementedError(f"Cannot convert {type(data)} {data.shape} {data.dtype} to {cls.__name__}")
        raise NotImplementedError(f"Cannot convert {type(data)} to {cls.__name__}")

Ancestors

Class variables

var dtype

Unsigned integer type, compatible with C unsigned char.

:Character code: 'B' :Canonical name: numpy.ubyte :Alias on this platform (Linux x86_64): numpy.uint8: 8-bit unsigned integer (0 to 255).

Static methods

def from_bits(data)

Instance variables

prop hex
Expand source code
@property
def hex(self):
    return self._data.tobytes().hex()

Methods

def to_bits(self)
Expand source code
def to_bits(self):
    if isinstance(self._data, np.ndarray):
        return np.unpackbits(self.data)
class Digital (data=None)
Expand source code
class Digital(_Data):
    pass

Ancestors

  • rpps.base.data._Data

Subclasses

class Process (*args, **kwds)
Expand source code
class Process(Enum):
    NONE = -1
    RAW = auto() # Unprocessed data
    SCRAM = auto() # scrambled data
    CODING = auto() # coding data
    MOD = auto() # modulated data
    DEMOD = auto() # demodulated data
    HARD = auto() # hard data
    SOFT = auto() # soft data

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

Color.RED

  • value lookup:

Color(1)

  • name lookup:

Color['RED']

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Ancestors

  • enum.Enum

Class variables

var CODING
var DEMOD
var HARD
var MOD
var NONE
var RAW
var SCRAM
var SOFT