/
trace3_py.py
49 lines (41 loc) · 1.02 KB
/
trace3_py.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
#
#
# Shadow3 python script to run a source and an optical system from files
#
#
# It uses the currently defined Shadow system defined in the (existing)
# files start.xx and systemfile.dat
#
# Author: Niccolo Canestrari, Manuel Sanchew del Rio
# ESRF (c) 2011
#
#
# import block
#
import Shadow
import sys
src = Shadow.Source()
oe1 = Shadow.OE()
beam = Shadow.Beam()
i=0
if len(sys.argv)==1:
print ("Usage: \n trace3_py.py -a ->creates source \n trace3_py.py -t ->runs trace (optical system) \n trace3_py.py -a ->runs both source and trace \n" )
exit()
if sys.argv[1]=='-s':
src.load('start.00')
beam.genSource(src)
if sys.argv[1]=='-t':
beam.load('begin.dat')
for file in open("systemfile.dat","r").readlines():
if file!="":
oe1.load(file.strip())
beam.traceOE(oe1,i)
i=i+1
if sys.argv[1]=='-a':
src.load('start.00')
beam.genSource(src)
for file in open("systemfile.dat","r").readlines():
if file!="":
oe1.load(file.strip())
beam.traceOE(oe1,i)
i=i+1