Skip to main content
Version: Next

ts_shape.events.engineering.operating_range

Classes
NameDescription
OperatingRangeEventsEngineering: Operating Range Analysis

OperatingRangeEvents​

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

Bases: Base

Engineering: Operating Range Analysis

Analyze the operating envelope of a signal — what ranges it operates in, how often, and when the operating point shifts.

Methods:

  • operating_envelope: Per-window min/max/mean/percentiles.
  • detect_regime_change: Detect significant shifts in the operating point.
  • time_in_range: Percentage of time within a defined range per window.
  • value_distribution: Histogram of signal values.
Functions
NameDescription
operating_envelopePer-window operating envelope statistics.
detect_regime_changeDetect significant shifts in the operating point between windows.
time_in_rangeShare of each window spent within, below and above a range.
value_distributionHistogram of signal values.
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:operating_range'
value_columnstrColumn holding the signal values.'value_double'
time_columnstrTimestamp column.'systime'

operating_envelope​

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

Per-window operating envelope statistics.

Parameters
NameTypeDescriptionDefault
windowstrResample window (pandas offset string, e.g. '1h').'1h'
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, min_value, p5, mean_value, p95, max_value,
DataFramerange_width. end is start + window.

detect_regime_change​

methodsource
detect_regime_change(
window: str = "1h", shift_threshold: float = 2.0
) -> pd.DataFrame

Detect significant shifts in the operating point between windows.

A regime change is flagged when the window mean differs from the previous window mean by more than shift_threshold * pooled std.

Parameters
NameTypeDescriptionDefault
windowstrResample window (pandas offset string). Windows with fewer than two samples are skipped.'1h'
shift_thresholdfloatMinimum shift between consecutive window means, in multiples of the two windows' average std, to flag a regime change.2.0
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, is_delta, prev_mean, new_mean, shift_magnitude.
DataFramestart is the previous window's start and end the new
DataFramewindow's start.

time_in_range​

methodsource
time_in_range(
lower_limit: float,
upper_limit: float,
window: str = "1h",
time_weighted: bool = True,
) -> pd.DataFrame

Share of each window spent within, below and above a range.

By default the *_pct columns are percentages of time: each value is held until the next sample (zero-order hold), so a window without samples that holds an earlier value is reported too. With time_weighted=False they are percentages of the samples in each window (equal to the share of time only for evenly spaced data).

Parameters
NameTypeDescriptionDefault
lower_limitfloatLower bound of the range (inclusive), in signal units.required
upper_limitfloatUpper bound of the range (inclusive), in signal units.required
windowstrResample window (pandas offset string).'1h'
time_weightedboolTrue (default) weights each value by how long it was held; False counts samples.True
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid,
DataFramesource_uuid, time_in_range_pct, time_below_pct, time_above_pct.
DataFrameend is start + window.

value_distribution​

methodsource
value_distribution(n_bins: int = 10) -> pd.DataFrame

Histogram of signal values.

Parameters
NameTypeDescriptionDefault
n_binsintNumber of equal-width histogram bins between the signal's minimum and maximum.10
Returns
TypeDescription
DataFrameDataFrame with columns: bin_lower, bin_upper, count,
DataFramesample_count (samples in the bin), pct, cumulative_pct.
DataFrameCanonical twin columns: sample_count (after count); it holds the same
DataFramevalues as the deprecated column right before it, which is removed
DataFramein the next major release.