forked from Caoimhinmg/PmagPy
/
plot_cdf.py
executable file
·50 lines (46 loc) · 1.22 KB
/
plot_cdf.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
#!/usr/bin/env python
import sys,pmag,pmagplotlib,numpy
def main():
"""
NAME
plot_cdfs.py
DESCRIPTION
makes plots of cdfs of data in input file
SYNTAX
plot_cdfs.py [-h][command line options]
OPTIONS
-h prints help message and quits
-f FILE
-t TITLE
-fmt [svg,eps,png,pdf,jpg..] specify format of output figure, default is svg
"""
fmt='svg'
title=""
if '-h' in sys.argv:
print main.__doc__
sys.exit()
if '-f' in sys.argv:
ind=sys.argv.index('-f')
file=sys.argv[ind+1]
X=numpy.loadtxt(file)
# else:
# X=numpy.loadtxt(sys.stdin,dtype=numpy.float)
else:
print '-f option required'
print main.__doc__
sys.exit()
if '-fmt' in sys.argv:
ind=sys.argv.index('-fmt')
fmt=sys.argv[ind+1]
if '-t' in sys.argv:
ind=sys.argv.index('-t')
title=sys.argv[ind+1]
CDF={'X':1}
pmagplotlib.plot_init(CDF['X'],5,5)
pmagplotlib.plotCDF(CDF['X'],X,title,'r','')
pmagplotlib.drawFIGS(CDF)
ans= raw_input('S[a]ve plot, <Return> to quit ')
if ans=='a':
files={'X':'CDF_.'+fmt}
pmagplotlib.saveP(CDF,files)
main()