API#
This part of the documentation lists the full API reference of all public classes and functions.
Type Hints Support#
Signal Traces#
Trace#
- class signalyzer.Trace(label: str = 'Trace', samples: Samples = <factory>)[source]#
Trace data class for time-discrete, equidistant signal samples.
- 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
samplesfrom the value of the data dictionary item selected by the key.
- relabel(label: str) Trace[source]#
Returns the same trace relabeled with the new label.
- Parameters:
label (str) – new label to set
- 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.
- bool(**kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesconverted 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
samplesconverted to integers.
- float(**kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesconverted to floating-points.- Parameters:
label (str) – optional trace label to set
- bin(**kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesconverted to binary literals.- Parameters:
label (str) – optional trace label to set
- oct(**kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesconverted to octal literals.- Parameters:
label (str) – optional trace label to set
- hex(**kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesconverted 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
samplesand the operand.- Parameters:
operand (Operand) – iterable or number to compare with
- less_equal(operand: Operand) Trace[source]#
Returns a new trace with the results as integers of the lesser or equal comparison between the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number to compare with
- equal(operand: Operand) Trace[source]#
Returns a new trace with the results as integers of the equal comparison between the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number to compare with
- not_equal(operand: Operand) Trace[source]#
Returns a new trace with the results as integers of the not equal comparison between the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number to compare with
- greater_equal(operand: Operand) Trace[source]#
Returns a new trace with the results as integers of the greater or equal comparison between the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number to compare with
- greater(operand: Operand) Trace[source]#
Returns a new trace with the results as integers of the greater comparison between the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number to compare with
- add(summand: Operand) Trace[source]#
Returns a new trace with the sums of the signal
samplesand the summand.- Parameters:
summand (Operand) – iterable or number
- sub(subtrahend: Operand) Trace[source]#
Returns a new trace with the differences between the signal
samplesand the subtrahend.- Parameters:
subtrahend (Operand) – iterable or number
- mul(factor: Operand) Trace[source]#
Returns a new trace with the products between the signal
samplesand the factor.- Parameters:
factor (Operand) – iterable or number
- div(divisor: Operand) Trace[source]#
Returns a new trace with the quotients between the signal
samplesand 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 signalsamplesis 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
samplesand 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 signalsamplesis 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
samplesand 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 signalsamplesis 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
samplesand 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 signalsamplesis 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
samplesraised to the power of the exponent.- Parameters:
exponent (Operand) – iterable or number
- bitwise_and(operand: Operand) Trace[source]#
Returns a new trace with the bitwise ANDed values of the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number
- bitwise_or(operand: Operand) Trace[source]#
Returns a new trace with the bitwise ORed values of the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number
- bitwise_xor(operand: Operand) Trace[source]#
Returns a new trace with the bitwise XORed values of the signal
samplesand the operand.- Parameters:
operand (Operand) – iterable or number
- left_shift(operand: Operand) Trace[source]#
Returns a new trace with the bitwise left-shifted signal
samplesby the operand.- Parameters:
operand (Operand) – iterable or number
- right_shift(operand: Operand) Trace[source]#
Returns a new trace with the right shifted signal
samplesby the operand.- Parameters:
operand (Operand) – iterable or number
- 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
samplesof the trace.
- 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
- 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.
- 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
samplesof 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
samplesto 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
samplesto 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
samplesto 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.
- enter_positive(**kwargs: Any) Trace[source]#
Returns a new trace with the test results as integers for checking the signal
samplesstarts to be positive.
- left_positive(**kwargs: Any) Trace[source]#
Returns a new trace with the test results as integers for checking the signal
samplesstops to be positive.
- enter_negative(**kwargs: Any) Trace[source]#
Returns a new trace with the test results as integers for checking the signal
samplesstarts to be negative.
- left_negative(**kwargs: Any) Trace[source]#
Returns a new trace with the test results as integers for checking the signal
samplesstops to be negative.
- 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
sampleslimited 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
sampleslimited 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
samplesin radians.- Parameters:
label (str) – optional trace label to set
- cos(**kwargs: Any) Trace[source]#
Returns a new trace with the cosines of the signal
samplesin radians.- Parameters:
label (str) – optional trace label to set
- tan(**kwargs: Any) Trace[source]#
Returns a new trace with the tangents of the signal
samplesin 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.
- 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.0and1.0to 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
Noneto 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-1if 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
samplesand the provided operands, or the sum \(\sum\limits_{i=0}^{N}{x_i}\) of the signalsamples\(N\) of the trace in case no operands are provided.An operand can be either a fix number or an array-like iterable.
- min(*operands: Operand, **kwargs: Any) Trace | Sample[source]#
Returns either a new trace with the minimums of the signal
samplesand the provided operands, or the minimum \(x_{min}\) in the signalsamples\(N\) of the trace in case no operands are provided.An operand can be either a fix number or an array-like iterable.
- max(*operands: Operand, **kwargs: Any) Trace | Sample[source]#
Returns either a new trace with the maximus of the signal
samplesand the provided operands, or the maximum \(x_{max}\) in the signalsamples\(N\) of the trace in case no operands are provided.An operand can be either a fix number or an array-like iterable.
- 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
samplesand the provided operands, or the average \(\overline{x}\) of the signalsamples\(N\) of the trace in case no operands are provided.An operand can be either a fix number or an array-like iterable.
- 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.0and1.0to 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
Noneto indicate an open interval for this side.
- median() float | int[source]#
Returns the median \(\overline{x}_{med}\) 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\).
- std(**kwargs: Any) float[source]#
Returns the biased sample standard deviation \(\sigma\) of the signal
samples\(N\).
- 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
meanof the signalsamples.std (float | int) – optional standard deviation. Default is the biased standard deviation
stdof the signalsamples.unbiased (bool) – optional if
Trueuses the unbiased standard deviation \(\sigma\). Default isFalse.
- 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
meanof the signalsamples.std (float | int) – optional standard deviation. Default is the biased standard deviation
stdof the signalsamples.unbiased (bool) – optional if
Trueuses the unbiased standard deviation \(\sigma\). Default isFalse.
- 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
meanof the signalsamples.std (float | int) – optional standard deviation. Default is the biased standard deviation
stdof the signalsamples.unbiased (bool) – optional if
Trueuses the unbiased standard deviation \(\sigma\). Default isFalse.
- zscore(**kwargs: Any) Trace[source]#
Returns a new trace with the biased z-scored signal
samples\(N\).
- clip(lower: Operand | None = None, upper: Operand | None = None, **kwargs: Any) Trace[source]#
Returns either a new trace with the signal
sampleslimited 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.
- clamp(bound: Operand | None = None, **kwargs: Any) Trace[source]#
Returns either a new trace with the signal
samplessymmetrically 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
- interpolate(x: Sequence[int | float], y: Sequence[int | float], **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesof the trace piecewise linear interpolated between the data points.The data points are internally sorted by their x-coordinates to be in ascending order.
- delay(on: int = 0, off: int = 0, **kwargs: Any) Trace[source]#
Returns a new trace with the change-rate limited signal
samplesof the binary signal trace.The change-rate of the binary signal
samplesis 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
sampleslimited by the maximal allowed positive and/or negative delta limits between consecutivesamples, 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
Noneto 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
- slew(limits: tuple[Optional[Operand], Optional[Operand]], hold: Operand | None = None, **kwargs: Any) SlewRateLimiterTraces[source]#
Slew-rate limiter over the signal
samplesof 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
Noneto 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
samplesfiltered with a second-order IIR band-pass filter.
- low_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesfiltered with a second-order IIR low-pass filter.
- high_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesfiltered with a second-order IIR high-pass filter.
- notch(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesfiltered with a second-order IIR notch filter.
- all_pass(dt: float, f0: float, q: float = 0.7071067811865475, **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesfiltered with a second-order IIR all-pass filter.
- dt1(ratio: Operand, gain: Operand = 1, **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplesof 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
samplesof 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
samplesof the trace.- Parameters:
dt (float) – sampling-time of the
samples(filter) in secondsalpha (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
samplesof 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
samplesof the trace.
- 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
samplesof the trace.
- moving_average(size: int, **kwargs: Any) MovingAverageTraces[source]#
Moving average over the signal
samplesof the trace.
- moving_differential(size: int, **kwargs: Any) Trace[source]#
Moving differential over the signal
samplesof the trace.
- moving_regression(size: int, **kwargs: Any) LinearRegressionTraces[source]#
Moving linear regression over the signal
samplesof the trace.
- move(number: int, **kwargs: Any) Trace[source]#
Returns a new trace with the moved signal
samplesby the number of samples either to the right or to the left.A positive number moves the signal
samplesto the right. This means a number of the first value in signalsamplesis inserted at the beginning of the signalsamplesto move as the fill value, and the number of the last signalsamplesare removed from the signalsamplesto move.A negative number moves the signal
samplesto the left. This means a number of the last value in the signalsamplesis appended at end of the signalsamplesto move as the fill value, and the number of the first signalsamplesare removed from the signalsamplesto move.
- slice(*args: tuple[int, ...], **kwargs: Any) Trace[source]#
Returns a new trace with the signal
samplessliced with the built-in functionslice()in the range given by the arguments args.
vectorize#
Logic Functions#
Logical AND#
Logical OR#
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=1values of the given operands.The priority starts with
0as the highest priority number for theTruth=1values 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
1or0.- Parameters:
Note
The operands should have the same length, otherwise only a subset of the signal
samplesis returned!
Traces#
- class signalyzer.Traces[source]#
Base data class for a collection of traces with mutable mapping support.
- relabel(label: str) Traces[source]#
Relabels the all traces with in the collection by keeping the last part of the trace
labelunchanged 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.
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.
polar#
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
Statisticstraces for a set of signal samples statistically analyzed.
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
Statisticstraces 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
Statisticstraces for the combined set of multiple signal samples.- classmethod from_traces(*operands: Operand, **kwargs: Any) SetTraces[source]#
Returns the collection of
Statisticstraces computed over the combined sets of the operands.An operand can be either a number or an array-like iterable.
- Parameters:
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:
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
SlewRateLimitertraces for signal samples processed with a slew-rate limiter.
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
ExponentialSmoothingtraces for signal samples processed with a 2nd-order exponential smoothing.
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
LinearRegressiontraces for signal samples processed with a moving linear regression.
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
AlphaBetaFiltertraces for signal samples filtered with an alpha-beta filter.
Representations#
2D-Point#
- class signalyzer.Point2D(x: int = 0.0, y: float = 0.0)[source]#
2-dimensional point representation by cartesian coordinates.
- 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].
3D-Point#
Vector#
2D-State#
3D-State#
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.
Slew-Rate Limiter#
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.
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.
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.
- class signalyzer.IIRFilter(b0: float, b1: float, b2: float, a1: float, a2: float, s1: float = 0.0, s2: float = 0.0)[source]#
The
IIRFilterclass 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}}\)
- 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.
- 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.
- 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.
- 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.
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
evaluatethe state transitions betweenstatesof 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
statesof a statemachine must define a consecutive, ascending interval of integernumbers.- states: dict[int, str | signalyzer.statemachine.State2D | signalyzer.statemachine.State3D]#
States of the statemachine
- 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.
- fields() tuple[dataclasses.Field, ...][source]#
Returns a tuple describing the fields of the data class.
- 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
statesof the statemachine in thesignal.The
samplesof thesignalmust contain only integernumbersdefined by thestatesof the state machine.- Parameters:
signal – optional a new
signalto evaluate
- flatten() Iterator[int][source]#
Returns an iterator to flatten the state transition
matrixinto a list.
- data() list[list[str | int]][source]#
Returns the data table with the counted state transitions between the
statesof the statemachine.
- table(**kwargs: Any) Figure[source]#
Returns a table figure for the state transition
matrixof the statemachine.
- plot(**kwargs: Any) Heatmap[source]#
Returns a heatmap plot for the state transition
matrixof the statemachine.