-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfast2h5_new_s2e_fake.py
56 lines (39 loc) · 1.31 KB
/
fast2h5_new_s2e_fake.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
# coding: utf-8
# Contact L.Samoylova <[email protected]>, A.Buzmakov <[email protected]>
# SPB S2E simulation project, European XFEL Hamburg <www.xfel.eu>
# May 2014
# Wave optics software is based on
# SRW core library <https://github.com/ochubar/SRW>, and
# WPG framework <https://github.com/samoylv/WPG>
# This is a fake pulses generator for Demo version only. Realy return only 3fs_20 pulse (AB)
# In[ ]:
import shutil
import os
import errno
def mkdir_p(path):
"""
Create directory tree, if not exists (mkdir -p)
:param path: Path to be created
"""
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
def main():
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-o", "--output-dir", dest="out_dir", help="Output directory")
(options, args) = parser.parse_args()
if not options.out_dir: # if output directory not given
parser.error('Output directory is not specified')
else:
out_dir=options.out_dir
mkdir_p(out_dir)
shutil.copyfile('FELsource_out_0000001.h5',
os.path.join(out_dir,'FELsource_out_0000001.h5'))
# In[ ]:
if __name__ == '__main__':
main()