Repository navigation
Expand file tree
/
Copy pathmake_schema_figure.py
More file actions
120 lines (100 loc) · 4.55 KB
/
Copy pathmake_schema_figure.py
File metadata and controls
120 lines (100 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""Generate the schema-contrast figure for the Medium essay.
Shows two raw asset schemas (topology-dependent shape) collapsing into one
canonical process-run row. Column names are taken from the real PoC schemas.
"""
import matplotlib.pyplot as plt
from matplotlib.patches import FancyArrowPatch, FancyBboxPatch
INK = "#172126"
MUTED = "#667176"
ASSET = "#b23a32"
PROCESS = "#087e6a"
SIGNAL = "#dc8c22"
NAVY = "#23425b"
PAPER = "#f7f4ec"
SURFACE = "#fffef9"
def card(ax, x, y, w, h, edge, fill=SURFACE, lw=2.0):
box = FancyBboxPatch(
(x, y), w, h,
boxstyle="round,pad=0.02,rounding_size=0.12",
linewidth=lw, edgecolor=edge, facecolor=fill, zorder=2,
)
ax.add_patch(box)
def main():
fig, ax = plt.subplots(figsize=(13.5, 7.4))
ax.set_xlim(0, 13.5)
ax.set_ylim(0, 7.4)
ax.axis("off")
fig.patch.set_facecolor(PAPER)
ax.set_facecolor(PAPER)
mono = {"family": "monospace", "fontsize": 8.2}
# ---- Left column: two raw asset schemas ------------------------------
ax.text(3.0, 7.15, "RAW ASSET DATA", ha="center", color=ASSET,
weight="bold", fontsize=12)
ax.text(3.0, 6.82, "schema morphs with topology", ha="center",
color=MUTED, fontsize=9.5, style="italic")
# Factory A card (5 cols)
card(ax, 0.4, 4.05, 5.2, 2.35, ASSET)
ax.text(0.65, 6.08, "Factory A · 1×200 HL · analog · °C", color=INK,
weight="bold", fontsize=10)
ax.text(0.65, 5.72, "5 columns", color=ASSET, fontsize=9, weight="bold")
ax.text(0.65, 5.35,
"raw_temp=10.1 unit=C\n"
"raw_intra_spread=0.41\n"
"raw_actuator=0.0 type=analog\n"
"raw_gravity=1.048 raw_cooling_total=0.0",
color=INK, va="top", **mono)
# Factory B card (17 cols)
card(ax, 0.4, 1.15, 5.2, 2.55, ASSET)
ax.text(0.65, 3.42, "Factory B · 4×100 HL · solenoid · °F", color=INK,
weight="bold", fontsize=10)
ax.text(0.65, 3.05, "17 columns", color=ASSET, fontsize=9, weight="bold")
ax.text(0.65, 2.68,
"vessel_1.temp_f=50.2 .solenoid=0\n"
"vessel_2.temp_f=50.4 .solenoid=1\n"
"vessel_3.temp_f=... vessel_4...\n"
"cooling.total_effect_hl_c_per_min=...",
color=INK, va="top", **mono)
ax.text(3.0, 0.62, "The two schemas don't even align:\na model trained on A cannot read B.",
ha="center", color=ASSET, fontsize=9.2, style="italic")
# ---- Arrow: aggregator ----------------------------------------------
arrow = FancyArrowPatch((5.75, 3.75), (7.55, 3.75),
arrowstyle="-|>", mutation_scale=22,
linewidth=2.4, color=NAVY, zorder=3)
ax.add_patch(arrow)
ax.text(6.65, 4.15, "role-based\naggregator", ha="center", color=NAVY,
fontsize=8.6, weight="bold")
# ---- Right column: canonical process row -----------------------------
ax.text(10.4, 7.15, "PROCESS CONTRACT", ha="center", color=PROCESS,
weight="bold", fontsize=12)
ax.text(10.4, 6.82, "exactly the same row in every topology", ha="center",
color=MUTED, fontsize=9.5, style="italic")
card(ax, 7.7, 1.75, 5.4, 4.65, PROCESS, fill="#f1f8f5", lw=2.4)
ax.text(7.95, 6.06, "ProcessRun · canonical row", color=INK,
weight="bold", fontsize=10)
ax.text(7.95, 5.70, "~9 columns · key: run_id", color=PROCESS,
fontsize=9, weight="bold")
ax.text(7.95, 5.33,
"run_id=..._Pilsner_HEALTHY_00\n"
"product=Pilsner phase_progress_pct=41.2\n"
"active_volume_hl=200 active_equipment_count=1\n"
"process_temp_mean_c=12.0\n"
"process_temp_spread_c=0.3\n"
"intra_vessel_spread_c=0.4\n"
"gravity_weighted_mean=1.021\n"
"cooling_intensity_c_per_min=0.06",
color=INK, va="top", **mono)
# quality flags highlighted
ax.text(7.95, 2.62,
"measurement_coverage_pct=100\n"
"utility_scope=aggregated\n"
"allocation_to_equipment_available=True",
color=SIGNAL, va="top",
family="monospace", fontsize=8.2, weight="bold")
ax.text(10.4, 1.30, "number of machines does not change the row ·\ncommon unit · quality flags inside",
ha="center", color=PROCESS, fontsize=9.2, style="italic")
fig.savefig("figures/figure_0_schema_contrast.png", dpi=190,
bbox_inches="tight", facecolor=PAPER)
plt.close(fig)
print("wrote figures/figure_0_schema_contrast.png")
if __name__ == "__main__":
main()