Mercurial > hg > python
view util.py @ 74:0245bc07f16c simple
try to simplify Rows/Cols (do without?) by hiving off the run-counts copletely
| author | Henry Thompson <ht@markup.co.uk> |
|---|---|
| date | Sat, 09 Aug 2025 15:59:19 -0400 |
| parents | 668d788cac47 |
| children |
line wrap: on
line source
'''Utility fns for dealing with block .tsv files''' import math,re IPAT=re.compile('-?[0-9][0-9]*$') PPAT=re.compile('[ ,;\[\]]') Red='[31m' eRed='[39m' RedFmt=Red+'%s'+eRed def intsMaybe(ii): return (int(i) for i in ii if IPAT.match(i)) def readHeaders(host,infile,skipColHdrs=True): l=infile.readline().rstrip() ff=PPAT.split(l) (host.nr,host.ox,host.oy,host.oz)=intsMaybe(ff) host.et=ff[9] l=infile.readline().rstrip() l2=PPAT.split(l) if l2[-1]=='bounded': host.orad=int(l2[1]) host.ymin=host.ymax=-1 else: (host.orad,host.ymin,host.ymax)=intsMaybe(PPAT.split(l)) if skipColHdrs: _=infile.readline() def d(p1,p2): dx=p1[0]-p2[0] dz=p1[1]-p2[1] dy=p1[2]-p2[2] return math.sqrt((dx*dx)+(dy*dy)+(dz*dz))
