January 1 pooled rate
111.11 kg/t
Fresh steam in kg divided by output in tonnes across 5 assigned records, including any shutdown at 0 kg and 0 t.
Fresh steam per tonne rose from 111.11 kg/t on January 1 to 307.14 kg/t on January 2 (utility_batches.xlsx, both sheets). The two-day comparison does not establish a loss of efficiency.
111.11 kg/t
Fresh steam in kg divided by output in tonnes across 5 assigned records, including any shutdown at 0 kg and 0 t.
307.14 kg/t
Fresh steam in kg divided by output in tonnes across 4 assigned records, including any shutdown at 0 kg and 0 t.
-38.89 kg/t
Difference of the two January 1 rates in kg/t. This subtraction has no numerator or denominator.
82.14 kg/t
Difference of the two January 2 rates in kg/t. This subtraction has no numerator or denominator.
daily_rates · n = 2
Excluded 0
batch_rates · n = 8
Excluded 0
| ID | Item | Status | Answer |
|---|---|---|---|
| A01 | Business process | resolved | The request identifies batch production and steam metering. Rows identify running batches and one shutdown.Evidence and options
|
| A02 | Decision | resolved | Compare fresh steam per tonne and assess what the change says about efficiency.Evidence and options
|
| A03 | Row meaning | resolved | User confirmed both rows represent one batch and chose row 10.Evidence and options
|
| A04 | Units and denominators | resolved | Use recorded output in tonnes for the pooled ratio and one equal weight per positive-output batch for the simple average, as requested.Evidence and options
|
| A04B | Meter reading meaning | resolved | User confirmed 80 kg and 120 kg are additive increments.Evidence and options
|
| A05 | Time basis | resolved | User assigned all of B-0016 to its January 1 start date in Korea Standard Time.Evidence and options
|
| A06 | Shutdown output | resolved | User confirmed zero output. The shutdown has an undefined individual rate.Evidence and options
|
| A06B | Shutdown steam | resolved | User confirmed measured zero steam during the shutdown.Evidence and options
|
| A07 | Missingness and zero steam on January 1 | resolved | User confirmed B-0016 used no fresh steam. No blank cells in the original data rows.Evidence and options
|
| A07B | Zero steam on January 2 | resolved | User confirmed B-0017 used no fresh steam.Evidence and options
|
| A08 | Join keys | resolved | All nine unique batch IDs match. Sum increments by batch_id before the one-to-one merge.Evidence and options
|
| Metric | Value | Definition | Numerator | Denominator | Condition | Sources |
|---|---|---|---|---|---|---|
| January 1 pooled rate | 111.11 kg/t | Fresh steam in kg divided by output in tonnes across 5 assigned records, including any shutdown at 0 kg and 0 t. | 500.0 | 4.5 |
| |
| January 1 simple batch average | 150 kg/t | Sum of individual batch kg/t rates divided by the number of positive-output batches, with equal weight per batch. | 600.0 | 4 |
| |
| January 1 pooled minus simple | -38.89 kg/t | Difference of the two January 1 rates in kg/t. This subtraction has no numerator or denominator. |
| |||
| January 1 product L pooled rate | 75 kg/t | Total fresh steam divided by total output for the 3 producing batch(es) of product L. | 300.0 | 4.0 |
| |
| January 1 product H pooled rate | 400 kg/t | Total fresh steam divided by total output for the 1 producing batch(es) of product H. | 200.0 | 0.5 |
| |
| January 1 product H output share | 11.11 % | Product H tonnes divided by all positive output tonnes. | 0.5 | 4.5 |
| |
| January 2 pooled rate | 307.14 kg/t | Fresh steam in kg divided by output in tonnes across 4 assigned records, including any shutdown at 0 kg and 0 t. | 4,300.0 | 14.0 |
| |
| January 2 simple batch average | 225 kg/t | Sum of individual batch kg/t rates divided by the number of positive-output batches, with equal weight per batch. | 900.0 | 4 |
| |
| January 2 pooled minus simple | 82.14 kg/t | Difference of the two January 2 rates in kg/t. This subtraction has no numerator or denominator. |
| |||
| January 2 product L pooled rate | 75 kg/t | Total fresh steam divided by total output for the 2 producing batch(es) of product L. | 300.0 | 4.0 |
| |
| January 2 product H pooled rate | 400 kg/t | Total fresh steam divided by total output for the 2 producing batch(es) of product H. | 4,000.0 | 10.0 |
| |
| January 2 product H output share | 71.43 % | Product H tonnes divided by all positive output tonnes. | 10.0 | 14.0 |
| |
| January 2 minus January 1 pooled rate | 196.03 kg/t | Difference of daily pooled rates in kg/t. This subtraction has no numerator or denominator. |
|
# Run from eda-work with Python 3.10+ and the supplied dependencies.
python3 -I delivery/clean.py ../utility_batches.xlsx delivery/cleaned_utility_batches.csv excluded.csv
python3 -I ../eda-skill/scripts/audit_clean.py ../utility_batches.xlsx --header-row 2 --cleaned delivery/cleaned_utility_batches.csv --excluded excluded.csv
python3 -I analyze.py
python3 -I ../eda-skill/scripts/plots.py --spec plot-spec.json --outdir delivery/figures
# Contents of analyze.py
import json
from pathlib import Path
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv("delivery/cleaned_utility_batches.csv", dtype={"batch_id": str, "reading_id": str})
batches = data.loc[data["_source_sheet"].eq("batches"), [
"_source_row", "batch_id", "product", "start_at", "end_at", "status", "production", "production_unit"
]].rename(columns={"_source_row": "batch_row"}).copy()
meter = data.loc[data["_source_sheet"].eq("meter_readings"), [
"_source_row", "reading_id", "batch_id", "reading_at", "steam_kg"
]].rename(columns={"_source_row": "meter_row"}).copy()
for frame in (batches, meter):
assert frame.notna().all().all()
assert not frame.drop(columns=frame.columns[0]).duplicated().any()
assert batches["batch_id"].is_unique and meter["reading_id"].is_unique
assert set(batches["batch_id"]) == set(meter["batch_id"])
assert set(batches["production_unit"]) == {"kg", "t"}
batches["output_t"] = pd.to_numeric(batches["production"]) * batches["production_unit"].map({"kg": 0.001, "t": 1})
batches["start_at"] = pd.to_datetime(batches["start_at"]).dt.tz_localize("Asia/Seoul")
batches["end_at"] = pd.to_datetime(batches["end_at"]).dt.tz_localize("Asia/Seoul")
meter["reading_at"] = pd.to_datetime(meter["reading_at"]).dt.tz_localize("Asia/Seoul")
meter["steam_kg"] = pd.to_numeric(meter["steam_kg"])
assert batches["output_t"].ge(0).all() and meter["steam_kg"].ge(0).all()
assert len(meter.merge(batches[["batch_id"]], on="batch_id", validate="many_to_one")) == len(meter)
by_batch = meter.groupby("batch_id", as_index=False).agg(steam_kg=("steam_kg", "sum"), meter_rows=("meter_row", list))
joined = batches.merge(by_batch, on="batch_id", validate="one_to_one")
assert len(joined) == len(batches) == len(by_batch)
assert joined["steam_kg"].sum() == meter["steam_kg"].sum()
assert joined["output_t"].sum() == batches["output_t"].sum()
assert sum(map(len, joined["meter_rows"])) == len(meter)
joined["day"] = joined["start_at"].dt.strftime("%Y-%m-%d")
joined["rate"] = joined["steam_kg"].div(joined["output_t"].where(joined["output_t"].gt(0)))
running = joined.loc[joined["output_t"].gt(0)]
assert running["status"].eq("running").all()
running.to_csv("batch_rates.csv", index=False)
daily = joined.groupby("day").agg(steam_kg=("steam_kg", "sum"), output_t=("output_t", "sum"),
rate_sum=("rate", "sum"), n_rates=("rate", "count"))
daily["pooled"] = daily["steam_kg"] / daily["output_t"]
daily["simple"] = daily["rate_sum"] / daily["n_rates"]
daily["gap"] = daily["pooled"] - daily["simple"]
product = running.groupby(["day", "product"]).agg(steam_kg=("steam_kg", "sum"),
output_t=("output_t", "sum"), batches=("rate", "count"))
product["pooled"] = product["steam_kg"] / product["output_t"]
product["output_share"] = product["output_t"] / product.groupby(level="day")["output_t"].transform("sum")
print(joined[["batch_row", "meter_rows", "product", "day", "output_t", "steam_kg", "rate"]].to_string(index=False))
print(daily.to_string())
print(product.to_string())
results = {
"daily": daily.reset_index().to_dict("records"),
"product": product.reset_index().to_dict("records"),
"records": json.loads(joined[["batch_row", "meter_rows", "day", "product", "output_t", "steam_kg", "rate"]].to_json(orient="records")),
}
Path("results.json").write_text(json.dumps(results, indent=2))
fig, ax = plt.subplots(figsize=(7.5, 4.2), layout="constrained")
figure_data = daily[["pooled", "simple"]].rename(columns={"pooled": "Total steam ÷ total output", "simple": "Simple batch average"})
figure_data.index = ["January 1", "January 2"]
figure_data.plot.bar(ax=ax, color=["#126A73", "#C76135"], width=0.58, rot=0)
for bars in ax.containers:
ax.bar_label(bars, fmt="%.2f", padding=4)
ax.set(ylim=(0, 365), xlabel="Batch start date (KST)", ylabel="Fresh steam (kg/t)",
title="Daily fresh-steam intensity by calculation")
ax.legend(frameon=False, loc="upper left")
ax.spines[["top", "right"]].set_visible(False)
fig.savefig("delivery/figures/daily_rates.png", dpi=160)