ts_shape.events.engineering.time_to_threshold
Classes
| Name | Description |
|---|---|
TimeToThresholdEvents | Engineering: Time-to-Threshold Prediction |
TimeToThresholdEvents
TimeToThresholdEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "eng:time_to_threshold",
value_column: str = "value_double",
time_column: str = "systime"
) -> None
Bases: Base
Engineering: Time-to-Threshold Prediction
Answer the question "when will this signal hit X at the current rate?"
by extrapolating recent trends. Complements
:class:ThresholdMonitoringEvents (which detects when you crossed a
threshold) with predictive analysis.
Methods:
- time_to_threshold: Estimate time until the signal reaches a value.
- time_to_threshold_windows: Per-window time-to-threshold estimates.
- remaining_useful_range: Time until signal leaves an acceptable band.
- crossing_forecast: Forecast crossing times for multiple thresholds.
Functions
| Name | Description |
|---|---|
time_to_threshold | Estimate time until the signal reaches a threshold value. |
time_to_threshold_windows | Per-window time-to-threshold estimates. |
remaining_useful_range | Estimate time until the signal leaves an acceptable operating band. |
crossing_forecast | Forecast crossing times for multiple named thresholds. |
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
signal_uuid | str | UUID of the signal to analyze. | required |
event_uuid | str | UUID stamped on emitted events. | 'eng:time_to_threshold' |
value_column | str | Column holding the signal values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
time_to_threshold
time_to_threshold(
threshold: float, lookback: str = "1h", direction: str = "auto"
) -> pd.DataFrame
Estimate time until the signal reaches a threshold value.
Fits a linear trend to the most recent lookback window and
extrapolates to find when the threshold would be crossed.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
threshold | float | Target value to predict crossing time for. | required |
lookback | str | How far back to look for trend estimation. | '1h' |
direction | str | 'rising', 'falling', or 'auto' (infer from slope sign). | 'auto' |
Returns
| Type | Description |
|---|---|
DataFrame | Single-row DataFrame with columns: current_value, slope_per_second, |
DataFrame | threshold, estimated_seconds, estimated_time, confidence, |
DataFrame | direction. |
time_to_threshold_windows
time_to_threshold_windows(
threshold: float, window: str = "1h", lookback: str = "1h"
) -> pd.DataFrame
Per-window time-to-threshold estimates.
For each window, fits a trend to the preceding lookback
period and estimates when the threshold will be crossed.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
threshold | float | Target value. | required |
window | str | Analysis window frequency. | '1h' |
lookback | str | Lookback period for trend estimation. | '1h' |
Returns
| Type | Description |
|---|---|
DataFrame | Summary DataFrame with columns: start, end, duration_seconds |
DataFrame | (the window bounds), window_start (the resample label; a |
DataFrame | deprecated twin of start), current_value, |
DataFrame | slope_per_second, estimated_seconds, confidence, direction. |
remaining_useful_range
remaining_useful_range(
lower_limit: float, upper_limit: float, lookback: str = "1h"
) -> pd.DataFrame
Estimate time until the signal leaves an acceptable operating band.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
lower_limit | float | Lower acceptable limit. | required |
upper_limit | float | Upper acceptable limit. | required |
lookback | str | Lookback period for trend estimation. | '1h' |
Returns
| Type | Description |
|---|---|
DataFrame | Single-row DataFrame with columns: current_value, |
DataFrame | slope_per_second, nearest_bound, nearest_bound_value, |
DataFrame | estimated_seconds, estimated_time, confidence. |
crossing_forecast
crossing_forecast(
thresholds: dict[str, float], lookback: str = "1h"
) -> pd.DataFrame
Forecast crossing times for multiple named thresholds.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
thresholds | dict[str, float] | Dict mapping names to values, e.g. {'warning': 80, 'alarm': 90, 'critical': 95}. | required |
lookback | str | Lookback period for trend estimation. | '1h' |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: threshold_name, threshold_value, |
DataFrame | estimated_seconds, estimated_time, reachable. |