File: abisso2th.py

package info (click to toggle)
therion 5.3.16-10
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 19,400 kB
  • ctags: 16,579
  • sloc: ansic: 126,508; cpp: 100,089; tcl: 25,682; perl: 2,002; makefile: 1,114; asm: 219; python: 121; sh: 4
file content (39 lines) | stat: -rwxr-xr-x 986 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/python
#
# copyright 2009 Martin Budaj

import sys,os

if len(sys.argv) < 2:
  print "usage: ss2th <file.ss>"
  sys.exit()

file_in = open(sys.argv[1]);
file_out = open(os.path.splitext(sys.argv[1])[0]+'.th', 'w')

f_prev = 0
m = 2

print >>file_out, 'centreline'

for i,l in enumerate(file_in):
  if i < 8: continue
  toks = l.split()
  if i < 18 and float(toks[0]) < 0 and sum(abs(float(x)) for x in toks[1:4]):
    print >>file_out, '    fix ',
    for j in range(4): print >>file_out, toks[j],
    print >>file_out
  if i == 18:
    print >>file_out, '  units clino compass deg'
    print >>file_out, '  calibrate tape 0 0.01'
    print >>file_out, '  data normal from to compass clino length'
  if len(toks) < 9: continue
  l,s,a,f,t = [float(x) for x in toks[0:5]]
  if l == s == f == a == t == 0: continue
  t = m if t==0 else t
  f = t_prev if f == 0 else f
  t_prev = t
  m += 1
  print >>file_out, '%8d%8d%8s%8s%8s' % (f,t,a,s,l)

print >>file_out, 'endcentreline'