PeriodSummaryEvents
Weekly and monthly production summaries and a comparison of two date ranges from a production counter, or a weekly/monthly roll-up of any daily metrics table.
ts_shape.events.production.period_summary · Production guide · API reference
Example
import numpy as np
import pandas as pd
from ts_shape.events.production.period_summary import PeriodSummaryEvents
t = pd.date_range("2024-01-01", periods=60 * 144, freq="10min") # 60 days
df = pd.DataFrame({"systime": t, "uuid": "line1:parts", "value_integer": np.arange(len(t)) * 3})
summary = PeriodSummaryEvents(df)
result = summary.weekly_summary(counter_uuid="line1:parts").head()
print(result[["week_start", "total_production", "daily_avg", "production_days"]])
monthly = summary.monthly_summary(counter_uuid="line1:parts")
comparison = summary.compare_periods(counter_uuid="line1:parts",
period_a=("2024-01-01", "2024-01-31"),
period_b=("2024-02-01", "2024-02-29"))
Methods
| Method | Returns |
|---|---|
weekly_summary(counter_uuid, ok_counter_uuid=None, nok_counter_uuid=None) | per week: week_start, week_end, total_production, daily_avg, production_days (+ ok_parts, nok_parts, quality_pct, resets) |
monthly_summary(counter_uuid, ok_counter_uuid=None, nok_counter_uuid=None) | per month: year, month, same metrics |
compare_periods(counter_uuid, period_a, period_b) | one row per metric: metric, period_a_value, period_b_value, change, change_pct |
from_daily_data(daily_df, window='W', date_column='date', aggregations=None) (static) | start, end, days and the aggregated numeric columns |
Notes
-
Weeks run Monday to Monday midnight; months are calendar months. Partial weeks or months at the edges of the data lower the averages.
-
from_daily_datatakes any daily table with adatecolumn (for exampleQualityEvents.daily_quality_summary()merged withDowntimeEvents.availability_trend(window="1D"), orOEEEvents.oee()withdate_column="start").window='W'gives Monday-to-Sunday weeks,'W-<DAY>'weeks ending on that day,'MS'calendar months. -
Each numeric column has a declared roll-up rule. Counts, durations and energy are summed. A ratio KPI is recomputed from the period's summed basis columns (ISO 22400-2), so the daily tables the library produces roll up exactly:
Column Period value quality_pct,first_pass_yield_pct100 × Σgood / Σtotal ( good_parts/ok_parts,total_partsor ok + nok)nok_rate_pct100 × Σnok / Σtotal availability_pct100 × Σ run_seconds/ Σplanned_seconds(OEE), Σuptime / Σ(uptime + downtime) (downtime), Σoperating_hours/ Σ(operating + repair) (reliability)performance_pct100 × Σ actual_parts/ Σideal_partsoee_pctavailability × performance × quality of the period mttr_hours,mtbf_hoursΣ repair_hours/ Σfailures, Σoperating_hours/ Σfailuresmtbf_iso22400_hours,failure_rate_per_hourΣoperating / (Σfailures + 1), Σfailures / Σoperating enpi,sec,efficiencyΣ energy_kwh/ Σunits_produced, Σtotal_energy/ Σtotal_output, Σunits/ Σenergy(ISO 50006)Without the basis columns a ratio is the mean weighted by its denominator when that column is present (e.g. MTTR by
failures, quality bytotal_parts, which is exact), availability, OEE and otherpctcolumns by the rows'duration_seconds, and otherwise the plain mean with aDataQualityWarningnaming the columns. Other ratio-like columns (avg,mean,rate,ratio, cycle times) are averaged the same way, never summed. A numeric column that matches no rule is dropped with aDataQualityWarning;aggregations={"col": "sum" | "mean" | "min" | "max" | "first" | "last" | "drop"}sets the rule per column. -
Counters are reset-aware by default (
handle_resets=True); increments are booked to the day of the reading that reports them.