Skip to main content
Version: 0.0.98

ts_shape.events.production.changeover

Classes
NameDescription
ChangeoverEventsProduction: Changeover

ChangeoverEvents​

classsource
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
NameDescription
detect_changeoverEmit point events when the product/recipe changes value.
changeover_windowCompute changeover windows per product change with enhanced configurability.
changeover_quality_metricsPer-product changeover frequency: how often, and how far apart.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format timeseries frame (one row per sample, uuid identifies the signal).required
event_uuidstrUUID stamped on emitted events.'prod:changeover'
time_columnstrTimestamp column.'systime'

detect_changeover​

methodsource
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
NameTypeDescriptionDefault
product_uuidstrUUID of the product/recipe signal.required
value_columnstrColumn containing the product value.'value_string'
min_durationstrMinimum time the new product must persist to count (formerly min_hold).'0s'
include_initialboolWhen 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​

methodsource
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
NameTypeDescriptionDefault
product_uuidstrUUID of the product/recipe signal.required
value_columnstrColumn containing the product value.'value_string'
start_timeTimestamp | NoneOnly changes at or after this timestamp are used. None uses all changes.None
untilstrHow 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'
configdict[str, Any] | NoneMethod 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'
fallbackdict[str, Any] | NoneUsed 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
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds (float
DataFrameseconds, end - start), uuid, source_uuid, is_delta, method,
DataFramecompleted.

changeover_quality_metrics​

methodsource
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
NameTypeDescriptionDefault
product_uuidstrUUID of the product/recipe signal.required
value_columnstrColumn containing the product value.'value_string'
Returns
TypeDescription
DataFrameDataFrame with one row per product: product, changeover_count,
DataFrameavg_time_between_seconds, min_time_between_seconds,
DataFramemax_time_between_seconds, std_time_between_seconds (time between
DataFrameconsecutive changeovers to that product; None with fewer than
DataFrametwo). Empty when there are fewer than two changeovers.