ts_shape.events.engineering.control_loop_health
| Name | Description |
|---|---|
ControlLoopHealthEvents | Engineering: Control Loop Health |
ControlLoopHealthEvents
ControlLoopHealthEvents(
dataframe: pd.DataFrame,
setpoint_uuid: str,
actual_uuid: str,
*,
output_uuid: str | None = None,
event_uuid: str = "eng:control_loop_health",
value_column: str = "value_double",
time_column: str = "systime"
) -> None
Bases: Base
Engineering: Control Loop Health
Continuously assess PID/control loop health from setpoint + actual pairs, independent of setpoint changes. Computes error integrals, detects oscillation in the error signal, and checks for valve saturation.
Methods:
- error_integrals: Per-window IAE, ISE, ITAE, bias.
- detect_oscillation: Sustained oscillation in the error signal.
- output_saturation: Valve pegged at limits.
- loop_health_summary: Shift-level report card.
| Name | Description |
|---|---|
error_integrals | Per-window error integrals for control loop performance. |
detect_oscillation | Detect sustained oscillation in the error signal. |
output_saturation | Detect when controller output is pegged at limits. |
loop_health_summary | Shift-level report card combining all loop health metrics. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
setpoint_uuid | str | UUID of the setpoint signal. | required |
actual_uuid | str | UUID of the actual (process value) signal. | required |
output_uuid | str | None | UUID of the controller output signal, used by :meth:output_saturation. None (default) when there is none. | None |
event_uuid | str | UUID stamped on emitted events. | 'eng:control_loop_health' |
value_column | str | Numeric column holding the signal values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
error_integrals
error_integrals(
window: str = "1h", *, max_gap: str | None = None
) -> pd.DataFrame
Per-window error integrals for control loop performance.
The error e = PV - SP is piecewise constant between samples and
integrated over time; a step that crosses a window boundary is split
at the boundary, so every second between the first and the last
sample is booked to the window it falls in (none is lost at window
edges, and a window with no sample of its own still receives the
time a held error covers in it).
IAE = integral |e| dt,ISE = integral e**2 dt.ITAE = integral (t - window_start) * |e| dt: time is measured from the start of the window, and the integral is exact for the piecewise-constant error.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Resample window (e.g. '1h', '8h'). | '1h' |
max_gap | str | None | Default None gives each error the time since the previous sample (the step (t[i-1], t[i]] carries e[i]), with no gap cap. When set, each error is held until the next sample (zero-order hold, the step [t[i], t[i+1]) carries e[i]) and any step longer than max_gap contributes nothing, so a communication gap is not integrated as one huge error. In both modes no time is integrated before the first or after the last sample. | None |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, iae, ise, |
DataFrame | itae, bias, sample_count. end is start + window. |
DataFrame | bias is the mean error of the samples in the window (NaN for |
DataFrame | a window without samples) and sample_count their number. |
DataFrame | Windows that receive no integrated time are omitted. |
detect_oscillation
detect_oscillation(
window: str = "5min", min_crossings: int = 4
) -> pd.DataFrame
Detect sustained oscillation in the error signal.
A zero-crossing is a change of the error's sign; a sample with zero
(or NaN) error carries the last non-zero sign, so 1, 0, -1 is one
crossing and touching zero (1, 0, 1) is none. A crossing is
timed at the sample where the carried sign changes, and
estimated_period_seconds is twice the mean time between
consecutive crossings (0 with fewer than two).
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Analysis window size. | '5min' |
min_crossings | int | Minimum zero-crossings to flag oscillation. | 4 |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid (setpoint and actual uuids, comma-joined), is_delta, |
DataFrame | crossing_count, estimated_period_seconds, amplitude, |
DataFrame | damping_direction. |
output_saturation
output_saturation(
upper_limit: float = 100.0, lower_limit: float = 0.0, window: str = "1h"
) -> pd.DataFrame
Detect when controller output is pegged at limits.
Requires output_uuid in constructor.
| Name | Type | Description | Default |
|---|---|---|---|
upper_limit | float | Upper output limit, in the output signal's units. Samples within 1% of the upper_limit - lower_limit range of it count as saturated high. Default 100.0. | 100.0 |
lower_limit | float | Lower output limit, in the output signal's units. Samples within 1% of the range of it count as saturated low. Default 0.0. | 0.0 |
window | str | Resample window as a pandas offset string (e.g. '1h'). | '1h' |
Shares and run lengths are measured in time, not samples: each
output sample is held until the next one (zero-order hold, the
module's interval_end="next_change" convention), steps are split
at the window boundaries, and the time after the last sample is not
observed (the last sample opens no step). A single saturated sample
therefore counts for the time until the next sample.
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid (the output uuid), pct_time_at_high, pct_time_at_low, |
DataFrame | pct_time_saturated, longest_saturation_seconds. One row per |
DataFrame | window that holds observed time; end is start + |
DataFrame | window. The percentages are shares of the observed (held) |
DataFrame | time in the window; longest_saturation_seconds is the |
DataFrame | longest stretch of consecutive saturated time inside the window |
DataFrame | (a run that crosses a window boundary is cut there). |
DataFrame | Canonical twin columns: time_at_high_pct (after pct_time_at_high), |
DataFrame | time_at_low_pct (after pct_time_at_low), time_saturated_pct |
DataFrame | (after pct_time_saturated); each holds the same values as the deprecated |
DataFrame | column right before it, which is removed in the next major release. |
loop_health_summary
loop_health_summary(
window: str = "8h", oscillation_window: str = "5min", min_crossings: int = 4
) -> pd.DataFrame
Shift-level report card combining all loop health metrics.
Oscillation is detected with :meth:detect_oscillation on short
analysis windows of oscillation_window (not on the report
window: a whole shift would almost always contain enough
zero-crossings). oscillation_count is the number of merged
oscillation episodes that start inside each report window.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Report window as a pandas offset string (e.g. '8h' for a shift). Used for the error integrals, the saturation share and to bucket the oscillation episodes. | '8h' |
oscillation_window | str | Analysis window passed to :meth:detect_oscillation (default '5min'). | '5min' |
min_crossings | int | Minimum zero-crossings per oscillation_window to flag oscillation, passed to :meth:detect_oscillation. | 4 |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, iae, bias, |
DataFrame | oscillation_count, pct_saturated, health_grade. end is |
DataFrame | start + window. |
DataFrame | Canonical twin columns: saturated_pct (after pct_saturated); each |
DataFrame | holds the same values as the deprecated column right before it, which is |
DataFrame | removed in the next major release. |