This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orm_info.py
executable file
·67 lines (48 loc) · 1.67 KB
/
orm_info.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
#! /usr/bin/env python
"""
orm_show
Usage:
./orm_info.py [-o DIR] [-m MODEL] [-b] [--base-orbit]
[-e ERRORS]... [RECORDS]...
Options:
-e FILE, --errors FILE apply errors from file
-o DIR, --output DIR set output directory [default: results]
-m PATH, --model PATH model path [default: ../hit_models/hht3]
-b, --backtrack use backtracking
--base-orbit plot unmodified orbit as well
Arguments:
MODEL madx model file
RECORDS measured ORM records
"""
import os
from docopt import docopt
import madgui.util.yaml as yaml
from madgui.model.errors import import_errors
from orm_util import Analysis
def main(args=None):
opts = docopt(__doc__, args)
prefix = opts['--output'] + '/'
os.makedirs(prefix, exist_ok=True)
model = opts['--model']
record_files = (
opts['RECORDS'] or
'../data/orm/2018-10-20-orm_measurements/M8-E108-F1-I9-G1/*.yml')
ana = Analysis.app(model, record_files)
if opts['--base-orbit']:
ana.init()
base_orm = ana.model_orbits
else:
base_orm = None
for filename in opts['--errors']:
import_errors(ana.model, yaml.load_file(filename))
ana.init({})
if opts['--backtrack']:
ana._init_twiss = ana.extrapolate(
['t3dg2g', 't3dg1g', 't3df1'], to='#s')
ana.info()
ana.plot_monitors(base_orm=base_orm, save_to=f'{prefix}mon_response')
ana.plot_steerers(base_orm=base_orm, save_to=f'{prefix}mon_response')
ana.plot_orbit(save_to=f'{prefix}orbit')
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv[1:]))