Skip to main content
Version: 0.0.98

RateOfChangeEvents

Intervals where a signal changes faster than a rate limit, rate statistics per window, and sudden step jumps.

ts_shape.events.engineering.rate_of_change · Engineering guide · API reference

Example​

import ts_shape
from ts_shape.events.engineering.rate_of_change import RateOfChangeEvents

df = ts_shape.make_timeseries(["flow_rate"], n_points=3600, freq="1s", baseline=50.0, noise=0.1)
df.loc[1800:, "value_double"] += 20.0 # step

roc = RateOfChangeEvents(df, "flow_rate")
rapid = roc.detect_rapid_change(threshold=0.5)
stats = roc.rate_statistics(window="15min")
result = roc.detect_step_changes(min_delta=10.0, max_duration="5s")
print(result[["systime", "value_before", "value_after", "delta"]])

Methods​

MethodReturns
detect_rapid_change(threshold)intervals with |rate| ≥ threshold: start, end, max_rate, direction
rate_statistics(window='1h')per window, of the absolute rate: mean_abs_rate, std_abs_rate, max_abs_rate, min_abs_rate
detect_step_changes(min_delta, max_duration='5s')jumps of at least min_delta within max_duration: time (after the jump), value_before, value_after, delta, duration

Notes​

  • Rates are in signal units per second, computed between consecutive samples. Each run of consecutive samples at or above threshold is one interval. The rate at a sample describes the step from the previous sample, so an interval starts at the sample before the first fast step (a single fast step lasts one sample interval, not zero); filter on duration_seconds to drop short ones.
  • rate_statistics describes |rate|. Its mean_rate, std_rate, max_rate and min_rate columns hold the same absolute values as the *_abs_rate twins today and become statistics of the signed rate in the next major release; read *_abs_rate for the absolute rate.
  • detect_rapid_change(window=...) is deprecated and ignored.