master
John Lauer Preserve validated CRR thermal routing recipe and narrated demonstration 92d2870 1mo ago
"""Audit actual native replay, not the planned geometry."""
import json,math,sys,xml.etree.ElementTree as ET
from pathlib import Path
from measure_thermal import measure
P=Path(__file__).resolve().parent;T=P/'recording-02';f=T/'bq25792-astra-thermal-routed.brd';b=ET.parse(f).find('drawing/board')
angles=[];count=0
for s in b.findall('signals/signal'):
 for w in s.findall('wire'):
  if int(w.get('layer')) not in [1,2,15,16]:continue
  count+=1;dx=float(w.get('x2'))-float(w.get('x1'));dy=float(w.get('y2'))-float(w.get('y1'));a=math.degrees(math.atan2(dy,dx))%180;err=abs(a-round(a/45)*45)
  if err>.02 or float(w.get('curve','0')):angles.append({'net':s.get('name'),'angle':a,'deviationDegrees':err,'wire':w.attrib})
ref=P.parent/'ablation/take-02/bq25792-ablation-routed.brd'
r={'nativeExport':str(f),'segments':count,'vias':len(b.findall('signals/signal/via')),'pours':len(b.findall('signals/signal/polygonpour')),'offAngleSegments':angles,'angleToleranceDegrees':.02,'beforeThermalArea':measure(ref),'afterThermalArea':measure(f),'thermalAreaMethod':'Bottom native fill contours unioned with modeled pads, traces and via copper; subtract drilled voids; count connected regions touching thermal pad copper. Circular geometry approximated. Shared Q2/Q4 VBUS region is counted per device but must not be summed. Geometric area estimate, not measured heat transfer.'}
sys.path.insert(0,str(P.parent/'ablation'));from coverage import measure as coverage
r['coverage']=coverage(f);(T/'audit.json').write_text(json.dumps(r,indent=2));assert not angles,angles
print(json.dumps(r,indent=2))