API#

This part of the documentation lists the full API reference of all public classes and functions.

Type Hints Support#

signalyzer.Number#

alias of Union[bool, int, float]

signalyzer.Sample#

alias of Union[bool, int, float, str]

signalyzer.Samples#

alias of Union[MutableSequence[Union[bool, int, float, str]], Iterable[Union[bool, int, float, str]], Iterable[None]]

signalyzer.Operand#

alias of Union[Iterable[Union[bool, int, float]], bool, int, float]

signalyzer.DataFrame#

alias of Mapping[str, Iterable[Union[bool, int, float, str]]]

Signal Traces#

Trace#

class signalyzer.Trace(label: str = 'Trace', samples: Samples = <factory>)[source]#

Trace data class for time-discrete, equidistant signal samples.

label: str = 'Trace'#

Label of the trace displayed in its plot.

samples: Samples#

List of the time-discrete, equidistant signal samples of the trace.

classmethod from_dict(key: str, data: DataFrame, **kwargs: Any) Trace[source]#

Returns a new trace labeled with the key, and the signal samples from the value of the data dictionary item selected by the key.

Parameters:
  • key (str) – key name of the signal samples to select from the data dictionary

  • data (DataFrame) – dictionary with signal samples

  • label (str) – optional label to set instead of the key name

relabel(label: str) Trace[source]#

Returns the same trace relabeled with the new label.

Parameters:

label (str) – new label to set

property label_stem: str#

Returns the stem of the trace label.

repeat(times: int = 1) Iterator[Sample][source]#

Returns an iterator repeating each signal sample of the trace n-times.

Parameters:

times (int) – number of times to repeat a sample. Default is 1.

fields() tuple[dataclasses.Field, ...][source]#

Returns a tuple describing the fields of the data class.

as_dict() dict[str, Any][source]#

Returns the trace data class as a dictionary.

as_tuple() tuple[Any, ...][source]#

Returns the trace data class as a tuple.

bool(**kwargs: Any) Trace[source]#

Returns a new trace with the signal samples converted to booleans.

Parameters:

label (str) – optional trace label to set

int(base: int | None = None, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples converted to integers.

Parameters:
  • base (int | None) – radix base of the integer literal to convert

  • label (str) – optional trace label to set

float(**kwargs: Any) Trace[source]#

Returns a new trace with the signal samples converted to floating-points.

Parameters:

label (str) – optional trace label to set

bin(**kwargs: Any) Trace[source]#

Returns a new trace with the signal samples converted to binary literals.

Parameters:

label (str) – optional trace label to set

oct(**kwargs: Any) Trace[source]#

Returns a new trace with the signal samples converted to octal literals.

Parameters:

label (str) – optional trace label to set

hex(**kwargs: Any) Trace[source]#

Returns a new trace with the signal samples converted to hexadecimal literals.

Parameters:

label (str) – optional trace label to set

less(operand: Operand) Trace[source]#

Returns a new trace with the results as integers of the lesser comparison between the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number to compare with

Note

An iterable operand should have at least the same length as the trace samples, otherwise only a subset of the signal samples is returned!

less_equal(operand: Operand) Trace[source]#

Returns a new trace with the results as integers of the lesser or equal comparison between the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number to compare with

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

equal(operand: Operand) Trace[source]#

Returns a new trace with the results as integers of the equal comparison between the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number to compare with

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

not_equal(operand: Operand) Trace[source]#

Returns a new trace with the results as integers of the not equal comparison between the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number to compare with

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

greater_equal(operand: Operand) Trace[source]#

Returns a new trace with the results as integers of the greater or equal comparison between the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number to compare with

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

greater(operand: Operand) Trace[source]#

Returns a new trace with the results as integers of the greater comparison between the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number to compare with

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

add(summand: Operand) Trace[source]#

Returns a new trace with the sums of the signal samples and the summand.

Parameters:

summand (Operand) – iterable or number

Note

An iterable summand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

sub(subtrahend: Operand) Trace[source]#

Returns a new trace with the differences between the signal samples and the subtrahend.

Parameters:

subtrahend (Operand) – iterable or number

Note

An iterable subtrahend should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

mul(factor: Operand) Trace[source]#

Returns a new trace with the products between the signal samples and the factor.

Parameters:

factor (Operand) – iterable or number

Note

An iterable factor should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

div(divisor: Operand) Trace[source]#

Returns a new trace with the quotients between the signal samples and the divisor.

Parameters:

divisor (Operand) – iterable or number

Note

An iterable divisor should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

Note

Zero-divisions between samples are resolved by returning zero for the samples in the new trace where the divisor is zero!

floordiv(divisor: Operand) Trace[source]#

Returns a new trace with the integer quotients between the signal samples and the divisor.

Parameters:

divisor (Operand) – iterable or number

Note

An iterable divisor should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

Note

Zero-divisions between samples are resolved by returning zero for the samples in the new trace where the divisor is zero!

mod(divisor: Operand) Trace[source]#

Returns a new trace with the remainders between the signal samples and the divisor.

The sign of the remainders is determined by the divisor.

Parameters:

divisor (Operand) – iterable or number

Note

An iterable divisor should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

Note

Zero-divisions between samples are resolved by returning zero for the samples in the new trace where the divisor is zero!

fmod(divisor: Operand) Trace[source]#

Returns a new trace with the remainders between the signal samples and the divisor.

The sign of a remainder is determined by the signal sample.

Parameters:

divisor (Operand) – iterable or number

Note

An iterable divisor should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

Note

Zero-divisions between samples are resolved by returning zero for the samples in the new trace where the divisor is zero!

pow(exponent: Operand) Trace[source]#

Returns a new trace with the exponentiated values for the signal samples raised to the power of the exponent.

Parameters:

exponent (Operand) – iterable or number

Note

An iterable exponent should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

bitwise_and(operand: Operand) Trace[source]#

Returns a new trace with the bitwise ANDed values of the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

bitwise_or(operand: Operand) Trace[source]#

Returns a new trace with the bitwise ORed values of the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

bitwise_xor(operand: Operand) Trace[source]#

Returns a new trace with the bitwise XORed values of the signal samples and the operand.

Parameters:

operand (Operand) – iterable or number

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

left_shift(operand: Operand) Trace[source]#

Returns a new trace with the bitwise left-shifted signal samples by the operand.

Parameters:

operand (Operand) – iterable or number

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

right_shift(operand: Operand) Trace[source]#

Returns a new trace with the right shifted signal samples by the operand.

Parameters:

operand (Operand) – iterable or number

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

bits(index: int, number: int = 1, **kwargs: Any) Trace[source]#

Returns a new trace with the unpacked number of bits starting at the bit index from the signal samples of the trace.

Parameters:
  • index (int) – start index of the bits to unpack [0..31]

  • number (int) – number of bits to unpack [1..32-index]. Default is 1.

  • label (str) – optional trace label to set

neg(**kwargs: Any) Trace[source]#

Returns a new trace with the negated values of the signal samples.

Parameters:

label (str) – optional trace label to set

abs() Trace[source]#

Returns a new trace with the absolute values of the signal samples.

invert(**kwargs: Any) Trace[source]#

Returns a new trace with the bitwise inverted values of the signal samples.

Parameters:

label (str) – optional trace label to set

round(ndigits: int | None = None, **kwargs: Any) Trace[source]#

Returns a new trace with the rounded values of the signal samples.

Parameters:
  • ndigits (int | None) – optional number of digits rounded after the decimal point

  • label (str) – optional trace label to set

trunc(**kwargs: Any) Trace[source]#

Returns a new trace with the truncated values of the signal samples.

Parameters:

label (str) – optional trace label to set

floor(**kwargs: Any) Trace[source]#

Returns a new trace with the floor, rounded integers of the signal samples.

Parameters:

label (str) – optional trace label to set

ceil(**kwargs: Any) Trace[source]#

Returns a new trace with the ceil, rounded integers of the signal samples.

Parameters:

label (str) – optional trace label to set

sign(**kwargs: Any) Trace[source]#

Returns a new trace with the signum values of the signal samples of the trace.

Parameters:

label (str) – optional trace label to set

zero(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for testing the signal samples to be zero or not.

Parameters:

label (str) – optional trace label to set

positive(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for testing the signal samples to be positive or not.

Parameters:

label (str) – optional trace label to set

negative(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for testing the signal samples to be negative or not.

Parameters:

label (str) – optional trace label to set

delta(**kwargs: Any) Trace[source]#

Returns a new trace with the deltas between the consecutive signal samples.

Parameters:
  • label (str) – optional trace label to set

  • preset (float) – optional preset value to compute the delta. Default is the first value in the signal samples.

enter_positive(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for checking the signal samples starts to be positive.

Parameters:
  • label (str) – optional trace label to set

  • preset (float) – optional preset value to compute the delta. Default is the first value in the signal samples.

left_positive(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for checking the signal samples stops to be positive.

Parameters:
  • label (str) – optional trace label to set

  • preset (float) – optional preset value to compute the delta. Default is the first value in the signal samples.

enter_negative(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for checking the signal samples starts to be negative.

Parameters:
  • label (str) – optional trace label to set

  • preset (float) – optional preset value to compute the delta. Default is the first value in the signal samples.

left_negative(**kwargs: Any) Trace[source]#

Returns a new trace with the test results as integers for checking the signal samples stops to be negative.

Parameters:
  • label (str) – optional trace label to set

  • preset (float) – optional preset value to compute the delta. Default is the first value in the signal samples.

accumulate(func: ~typing.Callable[[Number, Number], Number] = <built-in function add>, **kwargs: ~typing.Any) Trace[source]#

Returns a new trace with the accumulated signal samples.

Parameters:
  • func (Callable[[Number, Number], Number]) – function to use for the accumulation of the samples. Default is the function operator.add().

  • label (str) – optional trace label to set

sums_positive(**kwargs: Any) Trace[source]#

Returns a new trace with the integrated signal samples limited to positive sums.

Parameters:

label (str) – optional trace label to set

sums_negative(**kwargs: Any) Trace[source]#

Returns a new trace with the integrated signal samples limited to negative sums.

Parameters:

label (str) – optional trace label to set

sin(**kwargs: Any) Trace[source]#

Returns a new trace with the sines of the signal samples in radians.

Parameters:

label (str) – optional trace label to set

cos(**kwargs: Any) Trace[source]#

Returns a new trace with the cosines of the signal samples in radians.

Parameters:

label (str) – optional trace label to set

tan(**kwargs: Any) Trace[source]#

Returns a new trace with the tangents of the signal samples in radians.

Parameters:

label (str) – optional trace label to set

asin(**kwargs: Any) Trace[source]#

Returns a new trace with the arc sines of the signal samples.

Parameters:

label (str) – optional trace label to set

acos(**kwargs: Any) Trace[source]#

Returns a new trace with the arc cosines of the signal samples.

Parameters:

label (str) – optional trace label to set

atan(**kwargs: Any) Trace[source]#

Returns a new trace with the arc tangents of the signal samples.

Parameters:

label (str) – optional trace label to set

sinh(**kwargs: Any) Trace[source]#

Returns a new trace with the hyperbolic sines of the signal samples.

Parameters:

label (str) – optional trace label to set

cosh(**kwargs: Any) Trace[source]#

Returns a new trace with the hyperbolic cosines of the signal samples.

Parameters:

label (str) – optional trace label to set

tanh(**kwargs: Any) Trace[source]#

Returns a new trace with the hyperbolic tangents of the signal samples.

Parameters:

label (str) – optional trace label to set

asinh(**kwargs: Any) Trace[source]#

Returns a new trace with the area hyperbolic sines of the signal samples.

Parameters:

label (str) – optional trace label to set

acosh(**kwargs: Any) Trace[source]#

Returns a new trace with the area hyperbolic cosines of the signal samples.

Parameters:

label (str) – optional trace label to set

atanh(**kwargs: Any) Trace[source]#

Returns a new trace with the area hyperbolic tangents of the signal samples.

Parameters:

label (str) – optional trace label to set

sort(**kwargs: Any) Trace[source]#

Returns a new trace with the sorted signal samples \(N\) in ascending order.

Parameters:
  • key – function of one argument that is used to extract a comparison key from each sample. Default is None.

  • reverse (bool) – if True the sorted signal samples are returned in descending order.

winsorize(limits: float | tuple[Optional[float], Optional[float]] | None = None, **kwargs: Any)[source]#

Returns a new trace with the winsorized signal samples \(N\).

The nth-lowest sample values are set to the limits[0]-th percentile sample value, and the nth-highest sample values are set to the (1.0 - limits[1])-th percentile sample value.

Parameters:
  • limits (float | tuple[Optional[float], Optional[float]] | None) –

    either a pair of the percentages as floats between 0.0 and 1.0 to cut on each side of the sorted signal samples in ascending order, or the percentage for both sides.

    The value of one limit can be set to None to indicate an open interval for this side.

  • label (str) – optional trace label to set

index_of(sample: Sample) int[source]#

Returns the index of the first occurrence of the sample \(x\) in the signal samples \(N\) or -1 if no sample could be found.

Parameters:

sample – sample value to look for

count(sample: Sample) int[source]#

Returns the number of occurrences of the sample \(x\) in the signal samples \(N\).

Parameters:

sample – sample value to count

sum(*operands: Operand, **kwargs: Any) Trace | float[source]#

Returns either a new trace with the sums of the signal samples and the provided operands, or the sum \(\sum\limits_{i=0}^{N}{x_i}\) of the signal samples \(N\) of the trace in case no operands are provided.

An operand can be either a fix number or an array-like iterable.

Parameters:
  • operands (tuple[Operand, ...]) – operands to sum up with each signal sample

  • label (str) – optional trace label to set

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

min(*operands: Operand, **kwargs: Any) Trace | Sample[source]#

Returns either a new trace with the minimums of the signal samples and the provided operands, or the minimum \(x_{min}\) in the signal samples \(N\) of the trace in case no operands are provided.

An operand can be either a fix number or an array-like iterable.

Parameters:
  • operands (tuple[Operand, ...]) – operands to compare with each signal sample

  • label (str) – optional trace label to set

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

max(*operands: Operand, **kwargs: Any) Trace | Sample[source]#

Returns either a new trace with the maximus of the signal samples and the provided operands, or the maximum \(x_{max}\) in the signal samples \(N\) of the trace in case no operands are provided.

An operand can be either a fix number or an array-like iterable.

Parameters:
  • operands (tuple[Operand, ...]) – operands to compare with each signal sample

  • label (str) – optional trace label to set

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

range() float | int[source]#

Returns the range \(x_{max} - x_{min}\) of the signal samples \(N\).

midrange() float | int[source]#

Returns the midrange \(\frac{x_{max} + x_{min}}{2}\) of the signal samples \(N\).

average(*operands: Operand, **kwargs: Any) Trace | float[source]#

Returns either a new trace with the averages of the signal samples and the provided operands, or the average \(\overline{x}\) of the signal samples \(N\) of the trace in case no operands are provided.

An operand can be either a fix number or an array-like iterable.

Parameters:
  • operands (tuple[Operand, ...]) – operands to compute with each signal sample

  • label (str) – optional trace label to set

Note

An iterable operand should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

mean() float | int[source]#

Returns the arithmetic mean \(\overline{x}\) of the signal samples \(N\).

weighted_mean() float | int[source]#

Returns the linear weighted arithmetic mean \(\overline{x}_{w}\) of the signal samples \(N\).

winsor_mean(limits: float | tuple[Optional[float], Optional[float]] | None = None) float | int[source]#

Returns the winsorized arithmetic mean \(\overline{x}_{w\alpha}\) of the signal samples \(N\).

Parameters:

limits (float | tuple[Optional[float], Optional[float]] | None) –

either a pair of the percentages as floats between 0.0 and 1.0 to cut on each side of the sorted signal samples in ascending order, or the percentage for both sides.

The value of one limit can be set to None to indicate an open interval for this side.

median() float | int[source]#

Returns the median \(\overline{x}_{med}\) of the signal samples \(N\).

mode() float | int[source]#

Returns the mode \(\overline{x}_{mod}\) of the signal samples \(N\).

rms() float[source]#

Returns the root-mean-square \(x_{rms}\) of the signal samples \(N\).

aad() float[source]#

Returns the average absolute deviation \(D_{mean}\) of the signal samples \(N\).

mad() float[source]#

Returns the median absolute deviation \(D_{median}\) of the signal samples \(N\).

variance(**kwargs: Any) float[source]#

Returns the biased sample variance \(\sigma^2\) of the signal samples \(N\).

Parameters:
  • center (float | int) – optional center value. Default is the arithmetic mean of the signal samples.

  • unbiased (bool) – optional if True computes the unbiased variance \(\sigma^2\). Default is False.

std(**kwargs: Any) float[source]#

Returns the biased sample standard deviation \(\sigma\) of the signal samples \(N\).

Parameters:
  • center (float | int) – optional center value. Default is the arithmetic mean of the signal samples.

  • unbiased (bool) – optional if True computes the unbiased standard deviation \(\sigma\). Default is False.

coefficient(**kwargs: Any) float[source]#

Returns the coefficient of variation \(c_v\) of the signal samples \(N\).

Parameters:
  • center (float | int) – optional center value. Default is the arithmetic mean of the signal samples.

  • std (float | int) – optional standard deviation. Default is the biased standard deviation std of the signal samples.

  • unbiased (bool) – optional if True uses the unbiased standard deviation \(\sigma\). Default is False.

skew(**kwargs: Any) float[source]#

Returns the biased sample skew of the signal samples \(N\).

Parameters:
  • center (float | int) – optional center value. Default is the arithmetic mean of the signal samples.

  • std (float | int) – optional standard deviation. Default is the biased standard deviation std of the signal samples.

  • unbiased (bool) – optional if True uses the unbiased standard deviation \(\sigma\). Default is False.

kurtosis(**kwargs: Any) float[source]#

Returns the biased sample kurtosis of the signal samples \(N\).

Parameters:
  • center (float | int) – optional center value. Default is the arithmetic mean of the signal samples.

  • std (float | int) – optional standard deviation. Default is the biased standard deviation std of the signal samples.

  • unbiased (bool) – optional if True uses the unbiased standard deviation \(\sigma\). Default is False.

zscore(**kwargs: Any) Trace[source]#

Returns a new trace with the biased z-scored signal samples \(N\).

Parameters:
  • center (float | int) – optional center value. Default is the arithmetic mean of the signal samples.

  • std (float | int) – optional biased standard deviation. Default is the biased standard deviation std of the signal samples.

  • label (str) – optional trace label to set

clip(lower: Operand | None = None, upper: Operand | None = None, **kwargs: Any) Trace[source]#

Returns either a new trace with the signal samples limited between the provided lower and upper bound, or the same trace in case no bounds are provided.

A bound can be either a fix number or an array-like iterable.

Parameters:
  • lower (Operand | None) – optional lower bound to clip at. Default is None, this means the bound is not considered.

  • upper (Operand | None) – optional upper bound to clip at. Default is None, this means the bound is not considered.

  • label (str) – optional trace label to set

Note

The upper bound is dominant over the lower bound.

Note

An iterable bound should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

clamp(bound: Operand | None = None, **kwargs: Any) Trace[source]#

Returns either a new trace with the signal samples symmetrically clamped at the provided bound, or the same trace in case no bound is provided.

A bound can be either a fix number or an array-like iterable.

Parameters:
  • bound (Operand | None) – optional bound to clamp at. Default is None, this means the bound is not considered.

  • label (str) – optional trace label to set

Note

An iterable bound should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

interpolate(x: Sequence[int | float], y: Sequence[int | float], **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples of the trace piecewise linear interpolated between the data points.

The data points are internally sorted by their x-coordinates to be in ascending order.

Parameters:
  • x (Sequence[int | float]) – x-coordinates of the data points.

  • y (Sequence[int | float]) – y-coordinates of the data points.

  • label (str) – optional trace label to set

delay(on: int = 0, off: int = 0, **kwargs: Any) Trace[source]#

Returns a new trace with the change-rate limited signal samples of the binary signal trace.

The change-rate of the binary signal samples is limited by the numbers of samples to delay the on-state (1), and by the numbers of samples to delay the off-state (0) of the binary signal trace.

Parameters:
  • on (int) – optional number of samples to delay the on-state. Default is 0.

  • off (int) – optional number of samples to delay the off-state. Default is 0.

  • label (str) – optional trace label to set

  • preset (int) – optional preset value (0|1) of the delay. Default is the first value in the signal samples.

ramp(limits: tuple[Optional[Operand], Optional[Operand]] | None = None, **kwargs: Any) Trace[source]#

Returns either a new trace with the signal samples limited by the maximal allowed positive and/or negative delta limits between consecutive samples, or the same trace in case no limits are provided.

The maximal allowed positive delta limit can be either a fix number or an array-like iterable.

The maximal allowed negative delta limit can be either a fix number or an array-like iterable.

Parameters:
  • limits (Optional[tuple[Optional[Operand], Optional[Operand]]]) –

    optional a pair with the maximal allowed positive and negative deltas between consecutive samples.

    The value of one limit can be set to None to indicate an unlimited ramp for this side.

  • preset (float) – optional preset value of the ramp. Default is the first value in the signal samples.

  • label (str) – optional trace label to set

Note

An iterable maximal allowed positive or negative step should have at least the same length as the signal samples, otherwise only a subset of the signal samples is returned!

slew(limits: tuple[Optional[Operand], Optional[Operand]], hold: Operand | None = None, **kwargs: Any) SlewRateLimiterTraces[source]#

Slew-rate limiter over the signal samples of the trace.

The maximal allowed positive delta limit can be either a fix number or an array-like iterable.

The maximal allowed negative delta limit can be either a fix number or an array-like iterable.

The number of samples to hold the previous sample value when the one of the configured slew-rates becomes violated can be either a fix number or an array-like iterable.

Parameters:
  • limits (tuple[Optional[Operand], Optional[Operand]]) –

    a pair with the maximal allowed positive and negative deltas between consecutive samples.

    The value of one limit can be set to None to indicate an unlimited ramp for this side.

  • hold (Operand | None) – optional number of samples to hold the previous sample value when one of the configured slew-rates becomes violated.

  • preset (float) – optional preset value of the limiter. Default is the first value in the signal samples.

  • label (str) – optional trace label to set

band_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples filtered with a second-order IIR band-pass filter.

Parameters:
  • dt (float) – sampling-time of the samples (filter) in seconds

  • f0 (float) – center frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

  • label (str) – optional trace label to set

low_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples filtered with a second-order IIR low-pass filter.

Parameters:
  • dt (float) – sampling-time of the samples (filter) in seconds

  • f0 (float) – cutoff frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

  • label (str) – optional trace label to set

high_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples filtered with a second-order IIR high-pass filter.

Parameters:
  • dt (float) – sampling-time of the samples (filter) in seconds

  • f0 (float) – cutoff frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

  • label (str) – optional trace label to set

notch(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples filtered with a second-order IIR notch filter.

Parameters:
  • dt (float) – sampling-time of the samples (filter) in seconds

  • f0 (float) – center frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

  • label (str) – optional trace label to set

all_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples filtered with a second-order IIR all-pass filter.

Parameters:
  • dt (float) – sampling-time of the samples (filter) in seconds

  • f0 (float) – center frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

  • label (str) – optional trace label to set

dt1(ratio: Operand, gain: Operand = 1, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples of the trace processed by the transfer function of a DT1-element.

Parameters:
  • ratio (Operand) – integer ratios between damping time and sampling time, or floating-point ratios between sampling time and damping time.

  • gain (Operand) – proportional gain of the DT1-element.

  • preset (float) – optional preset value of the DT1-element. Default is the first value in the signal samples.

  • label (str) – optional trace label to set

pt1(ratio: Operand, gain: Operand = 1, **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples of the trace processed by the transfer function of a PT1-element.

Parameters:
  • ratio (Operand) – integer ratio between smoothing time and sampling time, or floating-point ratio between sampling time and smoothing time.

  • gain (Operand) – proportional gain of the PT1-element.

  • preset (float) – optional preset value of the PT1-element. Default is the first value in the signal samples.

  • label (str) – optional trace label to set

alpha_beta_filter(dt: float, alpha: Operand, beta: Operand, **kwargs: Any) AlphaBetaFilterTraces[source]#

Alpha-beta filter over the signal samples of the trace.

Parameters:
  • dt (float) – sampling-time of the samples (filter) in seconds

  • alpha (Operand) – adaption factor for the level prediction [0.0: Ignore signal sample, ..., 1.0[.

  • beta (Operand) – adaption factor for the trend prediction [0.0: Ignore signal sample, ..., 2.0].

  • level (float) – optional initial level of the alpha-beta filter. Default is the first value in the signal samples.

  • trend (float) – optional initial trend of the alpha-beta filter. Default is 0.0.

  • label (str) – optional trace label to set

exponential(alpha: float, **kwargs: Any) ExponentialSmoothingTraces[source]#

Second-order exponential smoothing over the signal samples of the trace.

Parameters:
  • alpha (float) – smoothing factor [0.0:freeze..1.0:transparent]

  • level (float) – optional initial level of the exponential smoothing. Default is the first value in the signal samples.

  • trend (float) – optional initial trend of the exponential smoothing. Default is 0.0.

  • label (str) – optional trace label to set

window(size: int, **kwargs: Any) Iterator[tuple[Sample, ...]][source]#

Moving window generator over the signal samples of the trace.

Parameters:
  • size (int) – moving window size (number of samples)

  • preset (float) – optional preset value to fill the moving window. Default is the first value in the signal samples.

moving_events(size: int, value: Sample = 1, **kwargs: Any) Trace[source]#

Returns a new trace with the number of value occurrences (events) in the moving window over the signal samples of the trace.

Parameters:
  • size (int) – moving window size

  • value – value to check. Default is 1.

  • preset (int) – optional preset value to fill the moving window. Default is None.

  • label (str) – optional trace label to set

moving_average(size: int, **kwargs: Any) MovingAverageTraces[source]#

Moving average over the signal samples of the trace.

Parameters:
  • size (int) – moving window size (number of samples)

  • preset (float) – optional preset value to fill the moving window. Default is the first value in the signal samples.

moving_differential(size: int, **kwargs: Any) Trace[source]#

Moving differential over the signal samples of the trace.

Parameters:
  • size (int) – moving window size (number of samples)

  • preset (float) – optional preset value to fill the moving window. Default is the first value in the signal samples.

  • label (str) – optional trace label to set

moving_regression(size: int, **kwargs: Any) LinearRegressionTraces[source]#

Moving linear regression over the signal samples of the trace.

Parameters:
  • size (int) – moving window size (> 1)

  • preset (float) – optional preset value to fill the moving window. Default is the first value in the signal samples.

  • label (str) – optional trace label to set

move(number: int, **kwargs: Any) Trace[source]#

Returns a new trace with the moved signal samples by the number of samples either to the right or to the left.

A positive number moves the signal samples to the right. This means a number of the first value in signal samples is inserted at the beginning of the signal samples to move as the fill value, and the number of the last signal samples are removed from the signal samples to move.

A negative number moves the signal samples to the left. This means a number of the last value in the signal samples is appended at end of the signal samples to move as the fill value, and the number of the first signal samples are removed from the signal samples to move.

Parameters:
  • number (int) – number of samples to move to the right (> 0) or to the left (< 0).

  • fill (float) – optional fill value. Default is the first or last value in the signal samples.

  • label (str) – optional trace label to set

slice(*args: tuple[int, ...], **kwargs: Any) Trace[source]#

Returns a new trace with the signal samples sliced with the built-in function slice() in the range given by the arguments args.

Parameters:
  • args (tuple[int, ...]) – optional start, stop index and step for slicing the signal samples.

  • label (str) – optional trace label to set

iter_x() Iterator[int][source]#

Returns an iterator for the x-coordinates of the trace.

iter_point() Iterator[Point2D][source]#

Returns an iterator for the x,y-points of the trace.

property x_values: list[int]#

Returns a list with the x-coordinates of the trace.

property y_values: list[Sample]#

Returns a list with the y-coordinates of the trace.

property digital: Digital#

Returns a new digital trace with shared signal samples.

plot(index: int | None = None, n: int | None = None, **kwargs: Any) Scatter[source]#

Returns the scatter plot of the trace.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

figure(index: int | None = None, n: int | None = None, **kwargs: Any) Figure[source]#

Returns a figure with the scatter plot of the trace.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

vectorize#

signalyzer.vectorize(operand: Operand) Samples[source]#

Returns for an int, float, bool or number literal str operand an endless iterator, otherwise the operand is returned unchanged.

Parameters:

operand (Operand) – operand to vectorize

Logic Functions#

Logical AND#

signalyzer.logical_and(*operands: Trace | Iterable, **kwargs: Any) Trace[source]#

Returns a new trace with the logical ANDed values of the given iterable operands.

Parameters:
  • operands (Trace | Iterable]) – trace or iterable

  • label (str) – optional trace label to set. Default is 'And'.

Note

The operands should have the same length, otherwise only a subset of the signal samples is returned!

Logical OR#

signalyzer.logical_or(*operands: Trace | Iterable, **kwargs: Any) Trace[source]#

Returns a new trace with the logical ORed values of the given iterable operands.

Parameters:
  • operands (Trace | Iterable) – trace or iterable

  • label (str) – optional trace label to set. Default is 'Or'.

Note

The operands should have the same length, otherwise only a subset of the signal samples is returned!

Priority Encoder#

signalyzer.priority(*operands: Trace | Iterable, **kwargs: Any) Trace[source]#

Returns a new trace with the priority numbers defined by the order of the given operands, and determined from the Truth=1 values of the given operands.

The priority starts with 0 as the highest priority number for the Truth=1 values of the first given iterable operand to the lowest priority number determined by the number of the given operands.

The iterable operands must contain either boolean values or integer values 1 or 0.

Parameters:
  • operands (Trace | Iterable) – trace or iterable to prioritize

  • highest (int) – optional number for the highest priority. Default is 0.

  • label (str) – optional trace label to set. Default is 'Priority'.

Note

The operands should have the same length, otherwise only a subset of the signal samples is returned!

Traces#

class signalyzer.Traces[source]#

Base data class for a collection of traces with mutable mapping support.

labels() tuple[str, ...][source]#

Returns a tuple of the trace labels in the collection.

relabel(label: str) Traces[source]#

Relabels the all traces with in the collection by keeping the last part of the trace label unchanged and the rest replaced by the base label.

Parameters:

label (str) – base label to set for the traces in the collection

fields() tuple[dataclasses.Field, ...][source]#

Returns a tuple describing the fields of the data class.

as_dict() dict[str, Any][source]#

Returns the collection of traces as a dictionary.

as_tuple() tuple[Any, ...][source]#

Returns the collection of traces as a tuple.

VectorTraces#

class signalyzer.VectorTraces(x: Trace = <factory>, y: Trace = <factory>, r: Trace | None = None, phi: Trace | None = None, theta: Trace | None = None, delta_phi: Trace | None = None, distance: Trace | None = None, dot: Trace | None = None)[source]#

Collection of traces for two signal samples converted into a vector represented in polar coordinates.

x: Trace#

Trace with cartesian x-coordinates of the vector

y: Trace#

Trace with cartesian y-coordinates of the vector

r: Trace | None = None#

Trace with radii of the vector

phi: Trace | None = None#

Trace with angles of the vector in radians [-pi..pi]

theta: Trace | None = None#

Trace with angles of the vector in degree [0..360].

delta_phi: Trace | None = None#

Trace with delta angles of the consecutive x,y-points in radians [-pi..pi]

distance: Trace | None = None#

Trace with euclidean distances of the consecutive x,y-points.

dot: Trace | None = None#

Trace with dot products of the consecutive x,y-points.

plot(index: int | None = None, n: int | None = None, **kwargs: Any) Scatterpolar[source]#

Returns the scatter polar plot of the vector traces.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

polar#

signalyzer.polar(x: Trace, y: Trace, **kwargs: Any) dict[str, Trace][source]#

Returns a dictionary with the traces for the two x, y signal samples converted into a vector represented in polar coordinates.

Parameters:
  • x (Trace) – cartesian x-coordinate signal trace of the vector

  • y (Trace) – cartesian y-coordinate signal trace of the vector

  • label (str) – optional traces base label to set. Default is Vector.

StatisticsTraces#

class signalyzer.StatisticsTraces(mean: Trace = <factory>, weighted_mean: Trace = <factory>, median: Trace = <factory>, mode: Trace = <factory>, rms: Trace = <factory>, minimum: Trace = <factory>, maximum: Trace = <factory>, range: Trace = <factory>, midrange: Trace = <factory>, absolute_error: Trace = <factory>, variance: Trace = <factory>, deviation: Trace = <factory>, coefficient: Trace = <factory>, skew: Trace = <factory>, kurtosis: Trace = <factory>)[source]#

Collection of Statistics traces for a set of signal samples statistically analyzed.

mean: Trace#

Arithmetic mean of the set (1st common moment).

weighted_mean: Trace#

Linear weighted mean of the set.

median: Trace#

Median of the set.

mode: Trace#

Mode of the set.

rms: Trace#

Root mean square of the set

minimum: Trace#

Minimum in the set.

maximum: Trace#

Maximum in the set

range: Trace#

Range of the set.

midrange: Trace#

Mid-range of the set.

absolute_error: Trace#

Empirical absolute error of the set (1st central moment).

variance: Trace#

Empirical biased sample variance of the set (2nd central moment).

deviation: Trace#

Empirical biased sample standard deviation of the set.

coefficient: Trace#

Empirical biased sample coefficient of variation of the set.

skew: Trace#

Empirical biased sample skew of the set (3rd central moment).

kurtosis: Trace#

Empirical biased sample kurtosis of the set (4th central moment).

figure(index: int | None = None, n: int | None = None, original: Trace | None = None, subplots: dict[str, Any] | None = None) Figure[source]#

Returns a figure of subplots for the traces in the collection.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

  • original (Trace) – optional original trace to add to the plot

  • subplots (dict) – optional dictionary with the settings for the subplots

MovingAverageTraces#

class signalyzer.MovingAverageTraces(mean: Trace = <factory>, weighted_mean: Trace = <factory>, median: Trace = <factory>, mode: Trace = <factory>, rms: Trace = <factory>, minimum: Trace = <factory>, maximum: Trace = <factory>, range: Trace = <factory>, midrange: Trace = <factory>, absolute_error: Trace = <factory>, variance: Trace = <factory>, deviation: Trace = <factory>, coefficient: Trace = <factory>, skew: Trace = <factory>, kurtosis: Trace = <factory>)[source]#

Collection of Statistics traces for signal samples processed with a simple moving average.

SetTraces#

class signalyzer.SetTraces(mean: Trace = <factory>, weighted_mean: Trace = <factory>, median: Trace = <factory>, mode: Trace = <factory>, rms: Trace = <factory>, minimum: Trace = <factory>, maximum: Trace = <factory>, range: Trace = <factory>, midrange: Trace = <factory>, absolute_error: Trace = <factory>, variance: Trace = <factory>, deviation: Trace = <factory>, coefficient: Trace = <factory>, skew: Trace = <factory>, kurtosis: Trace = <factory>)[source]#

Collection of Statistics traces for the combined set of multiple signal samples.

classmethod from_traces(*operands: Operand, **kwargs: Any) SetTraces[source]#

Returns the collection of Statistics traces computed over the combined sets of the operands.

An operand can be either a number or an array-like iterable.

Parameters:
  • operands (tuple[Operand, ...]) – operands to compute the statistics with

  • label (str) – optional traces base label to set

Note

All iterable operands must have the same length, otherwise only a subset of the operand values is returned!

combine#

signalyzer.combine(*operands: Operand, **kwargs: Any) dict[str, Trace][source]#

Returns a dictionary with the traces for the statistics results computed over the combined sets of operands.

An operand can be either a number or an array-like iterable.

Parameters:
  • operands (tuple[Operand, ...]) – operands to compute the statistics with

  • label (str) – optional trace label stem to set

Note

All iterable operands must have the same length, otherwise only a subset of the operand values is returned!

SlewRateLimiterTraces#

class signalyzer.SlewRateLimiterTraces(level: Trace = <factory>, deviation: Trace = <factory>, active: Trace = <factory>)[source]#

Collection of SlewRateLimiter traces for signal samples processed with a slew-rate limiter.

level: Trace#

Slew-rate limited signal level value.

deviation: Trace#

Signal deviation.

active: Trace#

Slew-rate limiter active (0: signal unlimited, 1: signal limited).

figure(index: int | None = None, n: int | None = None, original: Trace | None = None, subplots: dict[str, Any] | None = None) Figure[source]#

Returns a figure of subplots for the traces.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

  • original (Trace) – optional original trace to add to the plot

  • subplots (dict) – optional dictionary with the settings for the subplots

ExponentialSmoothingTraces#

class signalyzer.ExponentialSmoothingTraces(forecast: Trace = <factory>, forecast_sign: Trace = <factory>, level: Trace = <factory>, level_sign: Trace = <factory>, prognosis1: Trace = <factory>, prognosis2: Trace = <factory>, prognosis: Trace = <factory>, smoothed1: Trace = <factory>, smoothed2: Trace = <factory>, trend: Trace = <factory>, trend_sign: Trace = <factory>, trend_inflection: Trace = <factory>, error: Trace = <factory>, correction: Trace = <factory>, absolute_error: Trace = <factory>, variance: Trace = <factory>, deviation: Trace = <factory>, skew: Trace = <factory>, kurtosis: Trace = <factory>)[source]#

Collection of ExponentialSmoothing traces for signal samples processed with a 2nd-order exponential smoothing.

forecast: Trace#

Signal forecast value.

forecast_sign: Trace#

Sign of the signal forecast (-1: negative, 0: zero, 1: positive).

level: Trace#

Signal level value.

level_sign: Trace#

Sign of the signal level (-1: negative, 0: zero, 1: positive).

prognosis1: Trace#

Signal prognosis value for the first-order exponential smoothing.

prognosis2: Trace#

Signal prognosis value for the second-order exponential smoothing.

prognosis: Trace#

Signal prognosis value of the exponential smoothing.

smoothed1: Trace#

First-order exponentially smoothed signal value.

smoothed2: Trace#

Second-order exponentially smoothed signal value.

trend: Trace#

Signal prognosis trend value.

trend_sign: Trace#

Sign of the signal trend (-1: negative, 0: zero, 1: positive).

trend_inflection: Trace#

Inflection of the signal prognosis trend (1: increase, -1: decrease).

error: Trace#

Signal prognosis error.

correction: Trace#

Signal prognosis correction.

absolute_error: Trace#

Empirical absolute error of the distribution (1st central moment).

variance: Trace#

Empirical variance of the distribution (2nd central moment).

deviation: Trace#

Empirical standard deviation of the distribution.

skew: Trace#

Empirical skew of the distribution (3rd central moment).

kurtosis: Trace#

Empirical kurtosis of the distribution (4th central moment).

figure(index: int | None = None, n: int | None = None, original: Trace | None = None, subplots: dict[str, Any] | None = None) Figure[source]#

Returns a figure of subplots for the traces.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

  • original (Trace) – optional original trace to add to the plot

  • subplots (dict) – optional dictionary with the settings for the subplots

LinearRegressionTraces#

class signalyzer.LinearRegressionTraces(level: Trace = <factory>, slope: Trace = <factory>, intercept: Trace = <factory>, mean: Trace = <factory>, median: Trace = <factory>, minimum: Trace = <factory>, maximum: Trace = <factory>, range: Trace = <factory>, error: Trace = <factory>, negative_error: Trace = <factory>, positive_error: Trace = <factory>, absolute_error: Trace = <factory>, variance: Trace = <factory>, deviation: Trace = <factory>, skew: Trace = <factory>, kurtosis: Trace = <factory>)[source]#

Collection of LinearRegression traces for signal samples processed with a moving linear regression.

level: Trace#

Current y-coordinate of the approximated line.

slope: Trace#

Slope of the approximated line.

intercept: Trace#

Y-intercept of the approximated line.

mean: Trace#

Arithmetic mean of the y-coordinate values of the approximated line.

median: Trace#

Median of the y-coordinate values of the approximated line.

minimum: Trace#

Minimum of the y-coordinate values of the approximated line.

maximum: Trace#

Maximum of the y-coordinate values of the approximated line.

range: Trace#

Range of the y-coordinate values of the approximated line.

error: Trace#

Current error from the approximated line.

negative_error: Trace#

Maximal negative y-coordinate error from the approximated line.

positive_error: Trace#

Maximal positive y-coordinate error from the approximated line.

absolute_error: Trace#

Empirical absolute error of the distribution (1st central moment).

variance: Trace#

Empirical variance of the distribution (2nd central moment).

deviation: Trace#

Empirical standard deviation of the distribution.

skew: Trace#

Empirical skew of the distribution (3rd central moment).

kurtosis: Trace#

Empirical kurtosis of the distribution (4th central moment).

figure(index: int | None = None, n: int | None = None, original: Trace | None = None, subplots: dict[str, Any] | None = None) Figure[source]#

Returns a figure of subplots for the traces in the collection.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

  • original (Trace) – optional original trace to add to the plot

  • subplots (dict) – optional dictionary with the settings for the subplots

AlphaBetaFilterTraces#

class signalyzer.AlphaBetaFilterTraces(forecast: Trace = <factory>, forecast_sign: Trace = <factory>, level: Trace = <factory>, level_sign: Trace = <factory>, trend: Trace = <factory>, trend_sign: Trace = <factory>, trend_inflection: Trace = <factory>, error: Trace = <factory>, variance_forecast: Trace = <factory>, variance_level: Trace = <factory>, variance_trend: Trace = <factory>)[source]#

Collection of AlphaBetaFilter traces for signal samples filtered with an alpha-beta filter.

forecast: Trace#

Signal forecast value.

forecast_sign: Trace#

Sign of the signal forecast (-1: negative, 0: zero, 1: positive).

level: Trace#

Signal level value.

level_sign: Trace#

Sign of the signal level (-1: negative, 0: zero, 1: positive).

trend: Trace#

Signal trend value.

trend_sign: Trace#

Sign of the signal trend (-1: negative, 0: zero, 1: positive).

trend_inflection: Trace#

Inflection of the signal prognosis trend (1: increase, -1: decrease).

error: Trace#

Signal prognosis error.

variance_forecast: Trace#

Signal forecast variance reduction factor.

variance_level: Trace#

Signal level variance reduction factor.

variance_trend: Trace#

Signal trend variance reduction factor.

figure(index: int | None = None, n: int | None = None, original: Trace | None = None, subplots: dict[str, Any] | None = None) Figure[source]#

Returns a figure of subplots for the traces.

Parameters:
  • index (int) – optional start index of the samples to plot

  • n (int) – optional number of samples to plot

  • original (Trace) – optional original trace to add to the plot

  • subplots (dict) – optional dictionary with the settings for the subplots

Representations#

2D-Point#

class signalyzer.Point2D(x: int = 0.0, y: float = 0.0)[source]#

2-dimensional point representation by cartesian coordinates.

x: int = 0.0#

X-coordinate of the 2-dimensional point.

y: float = 0.0#

Y-coordinate of the 2-dimensional point.

property r#

Radius of the 2-dimensional point.

property phi#

Angle of the 2-dimensional point in radians [-pi..+pi].

property theta#

Angle of the 2-dimensional point in degrees [0..360].

as_vector()[source]#

Returns a Vector for the 2-dimensional point.

as_dict() dict[str, Any][source]#

Returns the 2-dimensional point as a dictionary.

as_tuple() tuple[Any, ...][source]#

Returns the 2-dimensional point as a tuple.

3D-Point#

class signalyzer.Point3D(x: int = 0.0, y: float = 0.0, z: float = 0.0)[source]#

3-dimensional point representation by cartesian coordinates.

x: int = 0.0#

X-coordinate of the 3-dimensional point.

y: float = 0.0#

Y-coordinate of the 3-dimensional point.

z: float = 0.0#

Z-coordinate of the 3-dimensional point.

property r: float#

Radius of the 3-dimensional point.

as_dict() dict[str, Any][source]#

Returns the 3-dimensional point as a dictionary.

as_tuple() tuple[Any, ...][source]#

Returns the 3-dimensional point as a tuple.

Vector#

class signalyzer.Vector(r: float = 0.0, phi: float = 0.0, theta: float | None = None)[source]#

Vector representation by polar coordinates.

r: float = 0.0#

Radius of the vector.

phi: float = 0.0#

Angle of the vector in radians [-pi..+pi].

theta: float | None = None#

Angle of the vector in degrees [0..360].

2D-State#

class signalyzer.State2D(name: str, x: int, y: int, color: str = 'Black')[source]#

State represented by a 2-dimensional node.

name: str#

Name of the state

x: int#

X-coordinate of the node

y: int#

Y-coordinate of the node

color: str = 'Black'#

Color of the node

3D-State#

class signalyzer.State3D(name: str, x: int, y: int, z: int, color: str = 'Black')[source]#

State represented by a 3-dimensional node.

name: str#

Name of the state

x: int#

X-coordinate of the state node

y: int#

Y-coordinate of the state node

z: int#

Z-coordinate of the state node

color: str = 'Black'#

Color of the node

Signal Processing#

Statistics#

class signalyzer.Statistics(mean: float = 0.0, weighted_mean: float = 0.0, median: float = 0.0, mode: float = 0.0, rms: float = 0.0, minimum: float = 0.0, maximum: float = 0.0, range: float = 0.0, midrange: float = 0.0, absolute_error: float = 0.0, variance: float = 0.0, deviation: float = 0.0, coefficient: float = 0.0, skew: float = 0.0, kurtosis: float = 0.0)[source]#

Statistics results.

mean: float = 0.0#

Arithmetic mean of the set (1st common moment)

weighted_mean: float = 0.0#

Weighted mean of the set

median: float = 0.0#

Median of the set

mode: float = 0.0#

Mode of the set

rms: float = 0.0#

Root mean square of the set

minimum: float = 0.0#

Minimum in the set

maximum: float = 0.0#

Maximum in the set

range: float = 0.0#

Range of the set

midrange: float = 0.0#

Mid-range of the set

absolute_error: float = 0.0#

Empirical absolute error of the set (1st central moment).

variance: float = 0.0#

Empirical biased sample variance of the set (2nd central moment).

deviation: float = 0.0#

Empirical biased sample standard deviation of the set.

coefficient: float = 0.0#

Empirical biased sample coefficient of variation of the set.

skew: float = 0.0#

Empirical biased sample skew of the set (3rd central moment).

kurtosis: float = 0.0#

Empirical biased sample kurtosis of the set (4th central moment).

Slew-Rate Limiter#

class signalyzer.SlewRateLimiter(level: float = 0.0, deviation: float = 0.0, active: int = 0)[source]#

Slew-rate limiter results.

level: float = 0.0#

Slew-rate limited signal level value.

deviation: float = 0.0#

Signal deviation.

active: int = 0#

Slew-rate limiter active (0: signal unlimited, 1: signal limited).

Exponential Smoothing#

class signalyzer.ExponentialSmoothing(forecast: float = 0.0, forecast_sign: float = 0, level: float = 0.0, level_sign: float = 0.0, prognosis1: float = 0.0, prognosis2: float = 0.0, prognosis: float = 0.0, smoothed1: float = 0.0, smoothed2: float = 0.0, trend: float = 0.0, trend_sign: float = 0.0, trend_inflection: float = 0.0, error: float = 0.0, correction: float = 0.0, absolute_error: float = 0.0, variance: float = 0.0, deviation: float = 0.0, skew: float = 0.0, kurtosis: float = 0.0)[source]#

2nd-order exponential smoothing results.

forecast: float = 0.0#

Signal forecast value.

forecast_sign: float = 0#

Sign of the signal level (-1: negative, 0: zero, 1: positive).

level: float = 0.0#

Signal level value.

level_sign: float = 0.0#

Sign of the signal level (-1: negative, 0: zero, 1: positive).

prognosis1: float = 0.0#

Signal prognosis value for the first-order exponential smoothing.

prognosis2: float = 0.0#

Signal prognosis value for the second-order exponential smoothing.

prognosis: float = 0.0#

Signal prognosis value of the exponential smoothing.

smoothed1: float = 0.0#

First-order exponentially smoothed signal value.

smoothed2: float = 0.0#

Second-order exponentially smoothed signal value.

trend: float = 0.0#

Signal prognosis trend value.

trend_sign: float = 0.0#

Sign of the signal trend (-1: negative, 0: zero, 1: positive).

trend_inflection: float = 0.0#

Inflection of the signal prognosis trend (1: increase, -1: decrease).

error: float = 0.0#

Signal prognosis error.

correction: float = 0.0#

Signal prognosis correction.

absolute_error: float = 0.0#

Empirical absolute error of the distribution (1st central moment).

variance: float = 0.0#

Empirical variance of the distribution (2nd central moment).

deviation: float = 0.0#

Empirical standard deviation of the distribution.

skew: float = 0.0#

Empirical skew of the distribution (3rd central moment).

kurtosis: float = 0.0#

Empirical kurtosis of the distribution (4th central moment).

Linear Regression#

class signalyzer.LinearRegression(level: float = 0.0, slope: float = 0.0, intercept: float = 0.0, mean: float = 0.0, median: float = 0.0, minimum: float = 0.0, maximum: float = 0.0, range: float = 0.0, error: float = 0.0, negative_error: float = 0.0, positive_error: float = 0.0, absolute_error: float = 0.0, variance: float = 0.0, deviation: float = 0.0, skew: float = 0.0, kurtosis: float = 0.0)[source]#

Linear regression results.

level: float = 0.0#

Current y-coordinate of the approximated line.

slope: float = 0.0#

Slope of the approximated line.

intercept: float = 0.0#

Y-intercept of the approximated line.

mean: float = 0.0#

Arithmetic mean of the y-coordinate values of the approximated line.

median: float = 0.0#

Median of the y-coordinate values of the approximated line.

minimum: float = 0.0#

Minimum of the y-coordinate values of the approximated line.

maximum: float = 0.0#

Maximum of the y-coordinate values of the approximated line.

range: float = 0.0#

Range of the y-coordinate values of the approximated line.

error: float = 0.0#

Current error from the approximated line.

negative_error: float = 0.0#

Maximal negative y-coordinate error from the approximated line.

positive_error: float = 0.0#

Maximal positive y-coordinate error from the approximated line.

absolute_error: float = 0.0#

Empirical absolute error of the distribution (1st central moment).

variance: float = 0.0#

Empirical variance of the distribution (2nd central moment).

deviation: float = 0.0#

Empirical standard deviation of the distribution.

skew: float = 0.0#

Empirical skew of the distribution (3rd central moment).

kurtosis: float = 0.0#

Empirical kurtosis of the distribution (4th central moment).

Filtering#

class signalyzer.AlphaBetaFilter(forecast: float = 0.0, forecast_sign: float = 0, level: float = 0.0, level_sign: float = 0.0, trend: float = 0.0, trend_sign: float = 0.0, trend_inflection: float = 0.0, error: float = 0.0, variance_forecast: float = 0.0, variance_level: float = 0.0, variance_trend: float = 0.0)[source]#

Alpha-beta filter results.

forecast: float = 0.0#

Signal forecast value.

forecast_sign: float = 0#

Sign of the signal forecast (-1: negative, 0: zero, 1: positive).

level: float = 0.0#

Signal level value.

level_sign: float = 0.0#

Sign of the signal level (-1: negative, 0: zero, 1: positive).

trend: float = 0.0#

Signal trend value.

trend_sign: float = 0.0#

Sign of the signal trend (-1: negative, 0: zero, 1: positive).

trend_inflection: float = 0.0#

Inflection of the signal prognosis trend (1: increase, -1: decrease).

error: float = 0.0#

Signal prediction error value.

variance_forecast: float = 0.0#

Signal forecast variance reduction factor.

variance_level: float = 0.0#

Signal level variance reduction factor.

variance_trend: float = 0.0#

Signal trend variance reduction factor.

class signalyzer.IIRFilter(b0: float, b1: float, b2: float, a1: float, a2: float, s1: float = 0.0, s2: float = 0.0)[source]#

The IIRFilter class is a factory for a second-order recursive linear infinite impulse response filter, also known as SOS-IIR filter.

The transfer function \(H(z)\) with normalized filter coefficients of a second-order IIR filter is defined as follows:

\(H(z) = \frac{b_0 + b_1 \cdot z^{-1} + b_2 \cdot z^{-2}} {1 + a_1 \cdot z^{-1} + a_2 \cdot z^{-2}}\)

b0: float#

Normalized feedforward filter coefficient

b1: float#

Normalized feedforward filter coefficient (1st-order)

b2: float#

Normalized feedforward filter coefficient (2nd-order)

a1: float#

Normalized feedback filter coefficient (1st-order)

a2: float#

Normalized feedback filter coefficient (2nd-order)

s1: float = 0.0#

Sum of the 1st-feedback stage of the SOS-IIR filter

s2: float = 0.0#

Sum of the 2nd-feedback stage of the SOS-IIR filter

classmethod band_pass(dt: float, f0: float, q: float = 0.7071067811865475) IIRFilter[source]#

Creates a digital second-order IIR band-pass filter with normalized filter coefficients for the given sampling-time dt, center frequency f0 and quality factor q of the filter.

Parameters:
  • dt (float) – sampling-time of the filter in seconds

  • f0 (float) – center frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

classmethod low_pass(dt: float, f0: float, q: float = 0.7071067811865475) IIRFilter[source]#

Creates a digital second-order IIR low-pass filter with normalized filter coefficients for the given sampling-time dt, cutoff frequency f0 and quality factor q of the filter.

Parameters:
  • dt (float) – sampling-time of the filter in seconds

  • f0 (float) – cutoff frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

classmethod high_pass(dt: float, f0: float, q: float = 0.7071067811865475) IIRFilter[source]#

Creates a digital second-order IIR high-pass filter with normalized filter coefficients for the given sampling-time dt, cutoff frequency f0 and quality factor q of the filter.

Parameters:
  • dt (float) – sampling-time of the filter in seconds

  • f0 (float) – cutoff frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

classmethod notch(dt: float, f0: float, q: float = 0.7071067811865475) IIRFilter[source]#

Creates a digital second-order IIR notch filter with normalized filter coefficients for the given sampling-time dt, center frequency f0 and quality factor q of the filter.

Parameters:
  • dt (float) – sampling-time of the filter in seconds

  • f0 (float) – center frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

classmethod all_pass(dt: float, f0: float, q: float = 0.7071067811865475) IIRFilter[source]#

Creates a digital second-order IIR all-pass filter with normalized filter coefficients for the given sampling-time dt, center frequency f0 and quality factor q of the filter.

Parameters:
  • dt (float) – sampling-time of the filter in seconds

  • f0 (float) – center frequency of the filter in Hertz

  • q (float) – inverse of bandwidth factor of the filter

clear() None[source]#

Clears the sum value of the feedback stages of the SOS-IIR filter.

compute(x: float | int) float[source]#

Computes for the sample \(x\) the SOS-IIR filter equation in canonical form with the configured normalized filter coefficients.

Parameters:

x (float | int) – sample value to compute

State Machines#

Statemachine#

class signalyzer.Statemachine(states: dict[int, str | signalyzer.statemachine.State2D | signalyzer.statemachine.State3D], signal: Trace = <factory>, labels: list[str] = <factory>, matrix: list[list[int]] = <factory>)[source]#

Statemachine data class to evaluate the state transitions between states of a statemachine.

A state of the statemachine is defined by a tuple pair, consisting of a unique integer number of the state, and the label of the state.

The states of a statemachine must define a consecutive, ascending interval of integer numbers.

states: dict[int, str | signalyzer.statemachine.State2D | signalyzer.statemachine.State3D]#

States of the statemachine

signal: Trace#

Signal trace with the state numbers

labels: list[str]#

List with the state labels of the statemachine

matrix: list[list[int]]#

Matrix with the counted transitions between the states

classmethod create(states: int | Sequence[str | State2D | State3D], start: int = 0, **kwargs: Any) Statemachine[source]#

Creates either a statemachine with the number of states without labeling them, or a statemachine with states from a sequence containing the labels or representations of the states to create.

Parameters:
  • states (int | Sequence[str | State2D | State3D]) – number of states or a sequence with the labels or representations for the states to create

  • start (int) – start number for the states to create Default is 0.

property numbers: list[int]#

List with the state numbers of the statemachine.

fields() tuple[dataclasses.Field, ...][source]#

Returns a tuple describing the fields of the data class.

zeroed_matrix() list[list[int]][source]#

Returns the zeroed transition matrix of the statemachine.

zeroed_counters() dict[tuple[int, int], int][source]#

Returns the dictionary with the zeroed state transition counters of the statemachine.

evaluate(signal: Trace | None = None) Statemachine[source]#

Counts the state transitions between the states of the statemachine in the signal.

The samples of the signal must contain only integer numbers defined by the states of the state machine.

Parameters:

signal – optional a new signal to evaluate

flatten() Iterator[int][source]#

Returns an iterator to flatten the state transition matrix into a list.

data() list[list[str | int]][source]#

Returns the data table with the counted state transitions between the states of the statemachine.

table(**kwargs: Any) Figure[source]#

Returns a table figure for the state transition matrix of the statemachine.

plot(**kwargs: Any) Heatmap[source]#

Returns a heatmap plot for the state transition matrix of the statemachine.

heatmap(**kwargs: Any) Figure[source]#

Returns a heatmap figure for the state transition matrix of the statemachine.

flowchart(**kwargs: Any) Sankey[source]#

Returns a sankey flow-chart plot for the state transition matrix of the statemachine.

Converters#

as_traces#

signalyzer.as_traces(samples: Sequence[dict[str, Any]]) dict[str, list[Sample]][source]#

Converts the list of samples into the trace format.