General Utilities

General utilities.

bitarray2dec(x_bitarray)

Converts an input NumPy array of bits (0 and 1) to a decimal integer.

Parameters:

x_bitarray (1D array of int) – Input NumPy array of bits.

Returns:

number – Integer representation(s) of the input bit array(s).

Return type:

int or array of int

dB2lin(x)

Convert dB (decibels) to a linear value.

Parameters:

x (float) – The value in dB to be converted to a linear value.

Returns:

The linear value.

Return type:

float

dBm2W(x)

Convert dBm to Watts.

Parameters:

x (float) – The power value in dBm to be converted to Watts.

Returns:

The power value in Watts.

Return type:

float

dec2bitarray(x, bit_width)

Converts a positive integer or an array-like of positive integers to a NumPy array of the specified size containing bits (0 and 1).

Parameters:
  • x (int or array-like of int) – Positive integer(s) to be converted to a bit array.

  • bit_width (int) – Size of the output bit array.

Returns:

bitarray – Array containing the binary representation of all the input decimal(s).

Return type:

2D NumPy array of int

decimal2bitarray(x, bit_width)

Converts a positive integer to a NumPy array of the specified size containing bits (0 and 1). This version is slightly quicker but only works for one integer.

Parameters:
  • x (int) – Positive integer to be converted to a bit array.

  • bit_width (int) – Size of the output bit array.

Returns:

bitarray – Array containing the binary representation of the input decimal.

Return type:

1D NumPy array of int

lin2dB(x)

Convert linear value to dB (decibels).

Parameters:

x (float) – The linear value to be converted to dB.

Returns:

The value converted to dB, i.e 10log10(x).

Return type:

float

class parameters

Basic class to be used as a struct of parameters

view()

Prints the attributes and their values in either standard or scientific notation.