ts_shape.events.development.recipe_phase_adherence
Recipe-phase adherence: check each batch phase against a spec.
Batch processes execute a sequence of named phases (heat-up, hold, cool-down, ...). Each phase has a development-defined spec: an expected duration window, a hold-value window, a maximum ramp rate, sometimes a peak ceiling. This detector iterates the phase intervals in a batch and emits one event per phase carrying pass/fail plus which criterion failed.
The spec format is intentionally a plain dict so it can be authored by a
process engineer (or loaded from YAML/JSON) without inventing a new
schema class -- see :meth:evaluate for the recognized keys.
| Name | Description |
|---|---|
RecipePhaseAdherenceEvents | Evaluate batch recipe phases against a declarative spec. |
RecipePhaseAdherenceEvents
RecipePhaseAdherenceEvents(
dataframe: pd.DataFrame,
phase_uuid: str,
value_uuid: str,
spec: dict[str, dict[str, Any]],
*,
event_uuid: str = "dev:recipe_phase_adherence",
value_column: str = "value_double",
time_column: str = "systime"
) -> None
Bases: Base
Evaluate batch recipe phases against a declarative spec.
The spec is a mapping {phase_name: criteria_dict}. Recognized
criteria keys (all optional) per phase:
duration_seconds--(min, max)seconds.duration_sis the deprecated spelling of the same criterion: it still works, with aDeprecationWarning, until the next major release (giving both for one phase raisesValueError);criteria_failednames the key the spec used.hold_value--(min, max)for the mean value during the phase.ramp_rate_max-- maximum absolute slope (value-units per second) computed from the first to the last sample.peak_value--(min, max)for the phase max.trough_value--(min, max)for the phase min.
Missing criteria are not checked. A phase whose name is absent from
the spec is reported with pass=True and an empty
criteria_failed list (the phase was observed but not constrained).
| Name | Description |
|---|---|
evaluate | Evaluate every observed phase interval against the spec. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
phase_uuid | str | UUID of the signal holding the active phase name. | required |
value_uuid | str | UUID of the process value evaluated per phase. | required |
spec | dict[str, dict[str, Any]] | Mapping of phase name to criteria dict (see the class docstring for the recognized keys). | required |
event_uuid | str | UUID stamped on emitted events. | 'dev:recipe_phase_adherence' |
value_column | str | Column holding the signal values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
evaluate
evaluate(
*, interval_end: str = "next_change", data_end: pd.Timestamp | None = None
) -> pd.DataFrame
Evaluate every observed phase interval against the spec.
| Name | Type | Description | Default |
|---|---|---|---|
interval_end | str | How each phase interval is closed. "next_change" (default) closes a phase at the next phase change; value samples are taken from start, end) (the sample at the transition belongs to the next phase), and the final phase is closed at data_end when given, otherwise at its own last sample. "last_sample" spans the first to the last phase-signal sample carrying the phase; on a change-encoded (is_delta) phase signal, which logs one row per transition, every phase is then zero-length. | 'next_change' |
data_end | [Timestamp | None | Optional bound for the final phase when interval_end="next_change" (e.g. the batch end). | None |
| Name | Type | Description |
|---|---|---|
DataFrame | Interval-shape DataFrame, one row per phase occurrence, | |
columns | DataFrame | start, end, duration_seconds, uuid, |
DataFrame | phase, mean_value, min_value, max_value, | |
DataFrame | observed_ramp_per_s, criteria_failed (list[str]), | |
DataFrame | pass. |