master
John Lauer Publish thermal bottleneck planner, accepted candidate, analysis and native recording scripts 0049da5 29d ago
import sys,xml.etree.ElementTree as ET
from pathlib import Path
P=Path(__file__).resolve().parent;sys.path.insert(0,str(P.parent/'thermal-expansion'))
from analyze import copper,M
import matplotlib;matplotlib.use('Agg')
import matplotlib.pyplot as plt
B=P.parent/'thermal-expansion/recording/bq25792-expanded-thermal.brd'
fig,ax=plt.subplots(figsize=(15,8))
colors={'VAC1':'gold','VBUS':'orange','VAC2':'khaki','VBAT':'pink','PGND':'lightblue'}
for n,g in copper(B).items():
 for p in g.geoms if hasattr(g,'geoms') else [g]:
  if p.geom_type!='Polygon':continue
  x,y=p.exterior.xy;ax.fill(x,y,color=colors.get(n,'gray'),alpha=.65)
  for h in p.interiors:x,y=h.xy;ax.fill(x,y,color='white')
for s in ET.parse(B).findall('.//signals/signal'):
 for w in s.findall('wire'):
  if w.get('layer')!='16':continue
  a,z=(float(w.get('x1')),float(w.get('y1'))),(float(w.get('x2')),float(w.get('y2')))
  ax.plot([a[0],z[0]],[a[1],z[1]],'k-',lw=1)
  if ((a[0]-z[0])**2+(a[1]-z[1])**2)**.5>2.5:ax.text((a[0]+z[0])/2,(a[1]+z[1])/2,s.get('name'),fontsize=8,color='blue')
ax.set_aspect('equal');ax.set_xlim(0,50.4);ax.set_ylim(0,26.4);fig.savefig(P/'bottleneck-map.png',dpi=140)