Skip to main content
Version: 0.0.98

ts_shape.events.engineering.rate_of_change

Classes
NameDescription
RateOfChangeEventsEngineering: Rate of Change Events

RateOfChangeEvents​

classsource
RateOfChangeEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "eng:rate_of_change",
value_column: str = "value_double",
time_column: str = "systime"
) -> None

Bases: Base

Engineering: Rate of Change Events

Detect rapid changes and step jumps in a numeric signal.

Methods:

  • detect_rapid_change: Flag intervals where rate of change exceeds threshold.
  • rate_statistics: Per-window rate of change statistics.
  • detect_step_changes: Sudden value jumps within a short duration.
Functions
NameDescription
detect_rapid_changeFlag intervals where rate of change exceeds threshold.
rate_statisticsPer-window statistics of the absolute rate of change.
detect_step_changesDetect sudden value jumps within a short duration.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
signal_uuidstrUUID of the signal to analyze.required
event_uuidstrUUID stamped on emitted events.'eng:rate_of_change'
value_columnstrColumn holding the signal values.'value_double'
time_columnstrTimestamp column.'systime'

detect_rapid_change​

methodsource
detect_rapid_change(
threshold: float, window: str | None = None
) -> pd.DataFrame

Flag intervals where rate of change exceeds threshold.

Each run of consecutive samples whose absolute rate is at or above threshold becomes one interval. The rate at a sample describes the step from the previous sample to it, so an interval starts at the sample before the first fast step and ends at the last sample of the run: a single fast step from t[i-1] to t[i] lasts t[i] - t[i-1], not zero.

Parameters
NameTypeDescriptionDefault
thresholdfloatMinimum absolute rate (units/second) to flag.required
windowstr | NoneDeprecated and not used: the rate is always computed between consecutive samples. Passing any value emits a DeprecationWarning. Filter the result on duration_seconds to drop short intervals.None
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, max_rate, direction.

rate_statistics​

methodsource
rate_statistics(window: str = '1h') -> pd.DataFrame

Per-window statistics of the absolute rate of change.

The statistics are over |rate| (signal units per second between consecutive samples), so a falling signal gives positive values.

Parameters
NameTypeDescriptionDefault
windowstrResample window.'1h'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, mean_rate,
DataFramemean_abs_rate, std_rate, std_abs_rate, max_rate, max_abs_rate,
DataFramemin_rate, min_abs_rate. end is start + window.
DataFrameCanonical twin columns: mean_abs_rate, std_abs_rate,
DataFramemax_abs_rate and min_abs_rate, each right after the
DataFramecolumn of the same values. The *_rate columns hold absolute
DataFramevalues today; in the next major release they become statistics
DataFrameof the signed rate, so read the *_abs_rate columns for the
DataFrameabsolute rate.

detect_step_changes​

methodsource
detect_step_changes(min_delta: float, max_duration: str = '5s') -> pd.DataFrame

Detect sudden value jumps within a short duration.

Parameters
NameTypeDescriptionDefault
min_deltafloatMinimum absolute value change to qualify.required
max_durationstrMaximum time window for the step to occur.'5s'
Returns
TypeDescription
DataFrameDataFrame with columns: systime, uuid, source_uuid, time, start,
DataFrameend, value_before, value_after, delta, duration,
DataFrameduration_seconds. systime and end equal time (the
DataFrameinstant after the jump; time is a deprecated twin), start
DataFrameis the sample before the jump, and duration_seconds is the
DataFramefloat-seconds twin of the Timedelta duration.