-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseff.py
executable file
·68 lines (52 loc) · 1.55 KB
/
seff.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
#!/usr/bin/env python
from pylab import *
import pylab
import sys
print(sys.argv)
def print_array(arr, colnumber=5, precision=6, number=14, type='e'):
""" Print the array in the formatted way:
arr : the array
colnumber : the number of printed columns
precision :
number
type: e, f, g, i
"""
prefix = '\t\t\t'
islogger = False
formatstr = "%i.%i" % (number, precision)
formatstr = '%'+formatstr+type
size = len(arr)
tbl = [formatstr for i in range(colnumber)]
colformat = '\t'.join(tbl)
for i in range(int(size/colnumber)):
print prefix, colformat % tuple(arr[i*colnumber:(i+1)*colnumber])
reste = size % colnumber
if reste != 0:
colfort = '\t'.join([formatstr for i in range(reste)])
print prefix, colfort % tuple(arr[-reste:])
if len(sys.argv) != 2:
print "you should give an argument"
sys.exit()
position = int(sys.argv[1])
if position == 0:
print "error : position should not be 0"
sys.exit()
seff = pylab.loadtxt("data.dat")
wavelength = seff[:, 0]
data = seff[:, position]
wavelength = 1239.842/wavelength
wavelength = wavelength[::-1]
data = data[::-1]*1E-18
# print "wavelength",wavelength
# print "data",data
print "\t\t<Process name=\"\" electrons=\"\" threshold=\"\">"
print "\t\t\t<Species>"
print "\t\t\t\t<Specie name=\"\" state=\"\"/>"
print "\t\t\t</Species>"
print "\t\t\t<Egrid unit=\"eV\">"
print_array(wavelength, type='f')
print "\t\t\t</Egrid>"
print "\t\t\t<Cross unit=\"cm2\">"
print_array(data)
print "\t\t\t</Cross>"
print "\t\t</Process>"