Logarithmics

Inheritance diagram of hermespy.core.logarithmic.Logarithmic, hermespy.core.logarithmic.LogarithmicSequence

Logarithmic numbers represent Decibel (dB) parameters within Hermes’ API. However, they will always act as their linear value when being interacted with, in order to preserve compatibility with any internal equation, since equations internally assume all parameters to be linear.

Note that therefore,

a = Logarithmic(10)
b = Logarithmic(20)

c = a + b
print(c)
>>> 20dB

will return in the output \(20.41392685158225\) instead of \(30\), since internally the linear representations will be summed. Instead, use the multiplication operator to sum Logarithmics, i.e.

a = Logarithmic(10)
b = Logarithmic(20)

c = a * b
print(c)
>>> 30dB
class Logarithmic(value, value_type=ValueType.DB, conversion=DbConversionType.POWER)[source]

Bases: float

Representation of a logarithmic number.

Parameters:
  • value (float | int) – Value of the logarithmic number.

  • value_type (ValueType) – Assumed type of value. Decibels by default.

  • conversion (DbConversionType) – Conversion of logarithmic scale. Power by default.

classmethod From_Tuple(linear, logarithmic, conversion=DbConversionType.POWER)[source]

Reconstruct a Logarithmic from its linear and logarithmic values.

Parameters:
  • linear (float) – Linear value of the logarithmic number.

  • logarithmic (float) – Logarithmic value of the logarithmic number.

  • conversion (DbConversionType) – Conversion of logarithmic scale.

Return type:

Logarithmic

property conversion: DbConversionType[source]

Logarithmic conversion type.

Returns: Conversion type.

property value_db: float[source]

Logarithmic value of represented number.

Returns: Logarithmic value.

class LogarithmicSequence(values: Sequence[float | int] | None = None, value_type: ValueType = ValueType.DB, conversion: DbConversionType = DbConversionType.POWER)[source]

Bases: ndarray[tuple[int], dtype[float64]]

A sequence of logarithmic numbers.

Parameters:
  • values – Initial content of the represented sequence. If not provided, the sequence will be initialized as empty.

  • value_type – Assumed type of value. Decibels by default.

  • conversion – Conversion of logarithmic scale. Power by default.

tolist()[source]

Convert to list representation.

Returns: list of logarithmics.

Return type:

list[Logarithmic]

property conversion: DbConversionType[source]

Logarithmic conversion type.

Returns: Conversion type.

class dB(*values, conversion=DbConversionType.POWER)[source]

Bases:

Represent scalar value as logarithmic number.

Parameters:
Return type:

Logarithmic | LogarithmicSequence

Returns: The logarithmic representation of *values.

class ValueType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

DB = 1[source]

Logarithmic number.

LIN = 0[source]

Linear number.