1 #!/usr/bin/env python
2
3 # Copyright (C) 2004 Kurt Schwehr
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
20 """Takes s_eigs output and converts it to xyz with y north, x east, z up"""
21
22 # Kurt Schwehr, Sept 2004
23 # http://schwehr.org/xcore
24
25 from math import *
26 import os, os.path, string, sys, math
27 import re # Regular expressions
28 if (2 != len(sys.argv)):
29 print "crap"
30 sys.exit(1)
31
32 if (1 != os.access(sys.argv[1],os.F_OK)):
33 print "ERROR: output file exists. do not want to over write!!"
34 print " ", sys.argv[1]
35 sys.exit(1)
36
37 infile = open(sys.argv[1],"r");
38
39
40 def printXyzFromEigs(len, dec, inc):
41 incRad = inc * pi/180
42 decRad = dec * pi/180
43 y = len * cos(incRad) * cos(decRad)
44 x = len * cos(incRad) * sin(decRad)
45 z = -sin(incRad)*len # inclination 90 is straigh down
46 v = [ x, y, z]
47 #v[0] = x
48 #v[1] = y
49 #v[2] = z
50 return v
51
52 #def checkXyzFromEigs():
53 #print "FIX - implement checkXyzFromEigs: ok"
54
55 #checkXyzFromEigs()
56
57 for line in infile.xreadlines():
58 s = line.split()
59 vMin = printXyzFromEigs(float(s[0]),float(s[1]),float(s[2]))
60 vInt = printXyzFromEigs(float(s[3]),float(s[4]),float(s[5]))
61 vMax = printXyzFromEigs(float(s[6]),float(s[7]),float(s[8]))
62 print vMin[0],vMin[1],vMin[2], vInt[0],vInt[1],vInt[2], vMax[0],vMax[1],vMax[2]
63
64
syntax highlighted by Code2HTML, v. 0.9.1