batch_tracking
batch_tracking ¤
Batch / recipe production tracking.
Detect batch boundaries from a string signal that carries the current batch ID, compute duration statistics, per-batch yield, and batch transition matrices.
BatchTrackingEvents ¤
BatchTrackingEvents(
dataframe: DataFrame,
batch_uuid: str,
*,
event_uuid: str = "prod:batch",
value_column: str = "value_string",
time_column: str = "systime"
)
Bases: Base
Track batch/recipe production from a batch-ID string signal.
A "batch" is defined as a contiguous period where the batch-ID value remains constant. A new batch begins when the value changes.
Example usage
batches = BatchTrackingEvents(df, batch_uuid='batch_id_signal')
detected = batches.detect_batches() stats = batches.batch_duration_stats() yields = batches.batch_yield('part_counter') transitions = batches.batch_transition_matrix()
Initialize batch tracker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame with timeseries data. |
required |
batch_uuid
|
str
|
UUID of the batch-ID signal. |
required |
event_uuid
|
str
|
UUID to tag derived events with. |
'prod:batch'
|
value_column
|
str
|
Column holding the batch ID string. |
'value_string'
|
time_column
|
str
|
Name of timestamp column. |
'systime'
|
detect_batches ¤
detect_batches() -> pd.DataFrame
Detect batch start/end from value changes in the batch-ID signal.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
batch_duration_stats ¤
batch_duration_stats() -> pd.DataFrame
Compute duration statistics grouped by batch type (batch_id).
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
batch_yield ¤
batch_yield(
counter_uuid: str,
*,
value_column_counter: str = "value_integer"
) -> pd.DataFrame
Compute production quantity for each detected batch.
Uses a monotonic counter signal. The yield per batch is the counter increase during the batch interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid
|
str
|
UUID of the monotonic part counter. |
required |
value_column_counter
|
str
|
Column holding counter values. |
'value_integer'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
batch_transition_matrix ¤
batch_transition_matrix() -> pd.DataFrame
Build a transition frequency matrix: which batch follows which.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame (pivot table) where index = from_batch, columns = to_batch, |
DataFrame
|
values = transition count. An extra |