ts_shape.events.production.changeover
Classes
| Name | Description |
|---|---|
ChangeoverEvents | Production: Changeover |
ChangeoverEvents
ChangeoverEvents(
dataframe: pd.DataFrame,
*,
event_uuid: str = "prod:changeover",
time_column: str = "systime"
) -> None
Bases: Base
Production: Changeover
Detect product/recipe changes and compute changeover windows without requiring a dedicated 'first good' signal.
Methods:
- detect_changeover: point events when product/recipe changes.
- changeover_window: derive an end time via fixed window or 'stable_band' metrics.
- changeover_quality_metrics: per-product changeover counts and time between changeovers.
Functions
| Name | Description |
|---|---|
detect_changeover | Emit point events when the product/recipe changes value. |
changeover_window | Compute changeover windows per product change with enhanced configurability. |
changeover_quality_metrics | Per-product changeover frequency: how often, and how far apart. |
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
event_uuid | str | UUID stamped on emitted events. | 'prod:changeover' |
time_column | str | Timestamp column. | 'systime' |
detect_changeover
detect_changeover(
product_uuid: str,
*,
value_column: str = "value_string",
min_duration: str = "0s",
include_initial: bool = True
) -> pd.DataFrame
Emit point events when the product/recipe changes value.
Uses a hold check: the new product must persist for at least
min_duration until the next change.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
product_uuid | str | UUID of the product/recipe signal. | required |
value_column | str | Column containing the product value. | 'value_string' |
min_duration | str | Minimum time the new product must persist to count (formerly min_hold). | '0s' |
include_initial | bool | When True (default) the first reading is emitted as a changeover event, marking the product active at the start of the data. A changeover strictly requires a prior, different value, so pass include_initial=False to suppress this synthetic leading event and report only real value changes. | True |
changeover_window
changeover_window(
product_uuid: str,
*,
value_column: str = "value_string",
start_time: pd.Timestamp | None = None,
until: str = "fixed_window",
config: dict[str, Any] | None = None,
fallback: dict[str, Any] | None = None
) -> pd.DataFrame
Compute changeover windows per product change with enhanced configurability.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
product_uuid | str | UUID of the product/recipe signal. | required |
value_column | str | Column containing the product value. | 'value_string' |
start_time | Timestamp | None | Only changes at or after this timestamp are used. None uses all changes. | None |
until | str | How each window's end is found: - "fixed_window": end = start + config['duration'] (default '10min'). - "stable_band": end when every metric in config['metrics'] stays within its band of a reference for its hold; the window ends at the latest metric's stable start.Any other value, or a stable band that is never reached, uses fallback. | 'fixed_window' |
config | dict[str, Any] | None | Method settings. Keys: 'min_duration' (minimum hold of a new product, passed to :meth:detect_changeover, default '0s'; the former key 'min_hold' still works and warns), 'duration' (for fixed_window), and for stable_band::{ 'metrics': [ {'uuid': 'm1', 'value_column': 'value_double', 'band': 0.2, 'hold': '2min'}, ... ], 'reference_method': 'expanding_median' | 'rolling_mean' |
fallback | dict[str, Any] | None | Used when the window end cannot be determined: {'default_duration': '10min', 'completed': False} (also the default when None). completed is copied to the output. | None |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds (float |
DataFrame | seconds, end - start), uuid, source_uuid, is_delta, method, |
DataFrame | completed. |
changeover_quality_metrics
changeover_quality_metrics(
product_uuid: str, *, value_column: str = "value_string"
) -> pd.DataFrame
Per-product changeover frequency: how often, and how far apart.
For each product, counts the changeovers to that product and
summarizes the time between consecutive ones. Changeover durations
are not measured here (a product-signal change is a point, not an
interval); use :meth:changeover_window for when the process is
stable again after a changeover.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
product_uuid | str | UUID of the product/recipe signal. | required |
value_column | str | Column containing the product value. | 'value_string' |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with one row per product: product, changeover_count, |
DataFrame | avg_time_between_seconds, min_time_between_seconds, |
DataFrame | max_time_between_seconds, std_time_between_seconds (time between |
DataFrame | consecutive changeovers to that product; None with fewer than |
DataFrame | two). Empty when there are fewer than two changeovers. |