forked from PmagPy/PmagPy
/
revtest.py
executable file
·79 lines (72 loc) · 2.13 KB
/
revtest.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import sys,pmagplotlib,pmag,exceptions
import matplotlib
def main():
"""
NAME
revtest.py
DESCRIPTION
calculates bootstrap statistics to test for antipodality
INPUT FORMAT
takes dec/inc as first two columns in space delimited file
SYNTAX
revtest.py [-h] [-i] [command line options]
OPTION
-h prints help message and quits
-i for interactive entry of file names from command line
-f FILE, sets input filename on command line
-fmt [svg,png,jpg], sets format for image output
"""
D,fmt=[],'svg'
if '-h' in sys.argv: # check if help is needed
print main.__doc__
sys.exit() # graceful quit
if '-i' in sys.argv: # ask for filename
file=raw_input("Enter file name with dec, inc data: ")
f=open(file,'rU')
data=f.readlines()
elif '-f' in sys.argv:
ind=sys.argv.index('-f')
file=sys.argv[ind+1]
f=open(file,'rU')
data=f.readlines()
if '-fmt' in sys.argv:
ind=sys.argv.index('-fmt')
fmt=sys.argv[ind+1]
for line in data:
if '\t' in line:
rec=line.split('\t') # split each line on space to get records
else:
rec=line.split() # split each line on space to get records
Dec,Inc=float(rec[0]),float(rec[1])
D.append([Dec,Inc,1.])
# set up plots
d=""
CDF={'X':1,'Y':2,'Z':3}
pmagplotlib.plot_init(CDF['X'],5,5)
pmagplotlib.plot_init(CDF['Y'],5,5)
pmagplotlib.plot_init(CDF['Z'],5,5)
#
# flip reverse mode
#
D1,D2=pmag.flip(D)
counter,NumSims=0,500
#
# get bootstrapped means for each data set
#
print 'doing first mode, be patient'
BDI1=pmag.di_boot(D1)
print 'doing second mode, be patient'
BDI2=pmag.di_boot(D2)
pmagplotlib.plotCOM(CDF,BDI1,BDI2,[""])
pmagplotlib.drawFIGS(CDF)
ans= raw_input("s[a]ve plots, [q]uit: ")
if ans=='a':
files={}
for key in CDF.keys():
files[key]='REV'+'_'+key+'.'+fmt
pmagplotlib.saveP(CDF,files)
else:
print 'good bye'
sys.exit()
main()