Files
Pier_v1/Code/교각모델링앱/tools/report_anchor_pier.py
T
ahnyongjooandClaude Sonnet 5.5 964a841de1 chore(rebar): Pier_T_rebar 작업 폴더 초기 구성 및 외부 의존 파일 통합
- Code\rebar_pipeline, review_pipeline, pier-program을 정션에서 실제 폴더로 전환
- Code\rhino_mcp 및 CLAUDE_rhino배경.md 추가, .mcp.json은 PYTHONPATH로 새 위치 사용
- pier-program 내부 .git 제거(이력은 backup\pier-program_20261028.bundle에 보관)
- worktree 가이드 반영(CLAUDE.local.md, HANDOFF.md)
- D:\Rhino-MCP 경로 참조를 새 위치로 치환

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 11:20:18 +09:00

69 lines
3.5 KiB
Python

"""Real-use check of the anchors on an unmodelled pier (2026-10-19): follow the anchors of a protected template into the pier's drawing and
cross-check every candidate that also has a table value (ELEVATION / 솔플레이트 / 철근재료표 candidates of engine/reader) — the table is the
independent truth for those fields. Reads only; writes nothing under data/.
usage: python tools/report_anchor_pier.py <pier> <template> [--detail]"""
import json
import sys
from collections import Counter, defaultdict
from pathlib import Path
APP = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(APP))
from engine import anchors, reader # noqa: E402
pier, tpl = sys.argv[1], sys.argv[2]
detail = "--detail" in sys.argv
D = APP / "data"
P, E = (json.loads((D / pier / f).read_text(encoding="utf-8")) for f in ("params.json", "expected.json"))
texts = json.loads((D / pier / "drawings" / "texts.json").read_text(encoding="utf-8"))
anc = json.loads((D / "_템플릿" / tpl / "anchors.json").read_text(encoding="utf-8"))
own = [a["source_sha256"] for a in json.loads((D / pier / "drawings" / "audit.json").read_text(encoding="utf-8")) if a.get("source_sha256")]
cand = anchors.follow(anc, texts, own)
docs = {"params": P, "expected": E}
def get(field):
which, path = field.split(":", 1)
x = docs[which]
for p in path.split("."):
x = x[int(p)] if isinstance(x, list) else x.get(p)
if x is None:
return None
return x
cand = {f: c for f, c in cand.items() if isinstance(get(f), (int, float))} # fields this pier's params really have (as the app does)
rows = reader.proposals(reader.field_candidates(reader.table_candidates(texts)), P, E)
table = {f"{r['file']}:" + ".".join(str(x) for x in r["path"]): r["candidate"] for r in rows}
print(f"== {pier} <- anchors of {tpl}: candidates {len(cand)}, frame coverage {next(iter(cand.values()))['coverage'] if cand else '-'}")
by = Counter(c["grade"] for c in cand.values())
print("grades", dict(by), "| differing from the current (template) value:", Counter(c["grade"] for f, c in cand.items() if abs(abs(get(f)) - abs(c["value"])) > 1.5))
agree = defaultdict(lambda: [0, 0])
bad = []
for f, c in cand.items():
t = table.get(f)
if t is None or isinstance(t, (list, dict)):
continue
ok = abs(abs(t) - abs(c["value"])) <= 1.5
agree[c["grade"]][0] += 1
agree[c["grade"]][1] += ok
if not ok:
bad.append((c["grade"], f, c["value"], t))
import copy # noqa: E402
after = anchors.cross_check(copy.deepcopy(cand), anchors.table_values(rows))
print("after the table cross-check (engine.anchors.cross_check):", dict(Counter(c["grade"] for c in after.values())),
"| table-confirmed A:", sum(1 for c in after.values() if c.get("table_confirmed")), "| lowered to C by a different table value:",
sum(1 for c in after.values() if c.get("table_confirmed") is False))
print("cross-check against the table value of the same field (independent truth):")
for g in "ABC":
n, k = agree[g]
print(f" grade {g}: {k}/{n} equal" + (f" ({k / n:.0%})" if n else ""))
for b in bad[:12 if detail else 5]:
print(" differs:", b)
if detail:
for g in "AB":
print(f"-- grade {g} candidates that differ from the current value")
for f, c in sorted(cand.items()):
if c["grade"] == g and abs(abs(get(f)) - abs(c["value"])) > 1.5:
print(f" {f:46s} {get(f)!s:>8} -> {c['value']!s:>8} ({c['followed']} places, {c['text']!r} {c['dwg']})")