source: MML/trunk/mml/plotorbit.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 3.0 KB
Line 
1function plotorbit(varargin)
2%PLOTORBIT - Plot the present orbit w.r.t. the golden or offset orbit
3%  plotorbit
4%
5%  KEY WORDS
6%  1. 'Golden' - Plot w.r.t. the golden orbit {Default}
7%  2. 'Offset' - Plot w.r.t. the offset orbit
8%  3. 'Position' - X-axis is the position along the ring {Default}
9%  4. 'Phase'    - X-axis is the phase along the ring
10
11XAxisFlag = 'Position';
12RefFlag = 'Golden';
13
14% Input parsing
15for i = length(varargin):-1:1
16    if isstruct(varargin{i})
17        % Ignor structures
18    elseif iscell(varargin{i})
19        % Ignor cells
20    elseif strcmpi(varargin{i},'struct')
21        % Just remove
22        varargin(i) = [];
23    elseif strcmpi(varargin{i},'numeric')
24        % Just remove
25        varargin(i) = [];
26    elseif strcmpi(varargin{i},'Position')
27        XAxisFlag = 'Position';
28        varargin(i) = [];
29    elseif strcmpi(varargin{i},'Phase')
30        XAxisFlag = 'Phase';
31        varargin(i) = [];
32    elseif strcmpi(varargin{i},'Golden')
33        RefFlag = 'Golden';
34        varargin(i) = [];
35    elseif strcmpi(varargin{i},'Offset')
36        RefFlag = 'Offset';
37        varargin(i) = [];
38    end
39end
40
41
42% Default orbit families
43BPMxFamily = gethbpmfamily;
44BPMyFamily = getvbpmfamily;
45
46
47if strcmpi(XAxisFlag, 'Phase')
48    [BPMxspos, BPMyspos, Sx, Sy, Tune] = modeltwiss('Phase', BPMxFamily, [], BPMyFamily, []);
49    BPMxspos = BPMxspos/2/pi;
50    BPMyspos = BPMyspos/2/pi;
51    XLabel = 'BPM Phase';
52else
53    BPMxspos = getspos(BPMxFamily,family2dev(BPMxFamily));
54    BPMyspos = getspos(BPMyFamily,family2dev(BPMyFamily));
55    XLabel = 'BPM Position [meters]';
56end
57
58
59% Get data
60x = getam(BPMxFamily,'struct', varargin{:});
61y = getam(BPMyFamily,'struct', varargin{:});
62
63
64if strcmpi(RefFlag, 'Golden')
65    Xref = getgolden(BPMxFamily,family2dev(BPMxFamily), varargin{:});
66    Yref = getgolden(BPMyFamily,family2dev(BPMyFamily), varargin{:});
67elseif strcmpi(RefFlag, 'Offset')
68    Xref = getoffset(BPMxFamily,family2dev(BPMxFamily), varargin{:});
69    Yref = getoffset(BPMyFamily,family2dev(BPMyFamily), varargin{:});
70else
71    error('Reference orbit not unknown');
72end
73
74
75% % Change to physics units
76% if any(strcmpi('Physics',varargin))
77%     Xref = hw2physics(BPMxFamily, 'Monitor', Xref, family2dev(BPMxFamily));
78%     Yref = hw2physics(BPMyFamily, 'Monitor', Yref, family2dev(BPMyFamily));
79% end
80
81
82Xerr = x.Data - Xref;
83Yerr = y.Data - Yref;
84
85L = getfamilydata('Circumference');
86
87clf reset
88subplot(2,1,1);
89plot(BPMxspos, Xerr, '.-');
90%xlabel(XLabel);
91ylabel(sprintf('Horizontal [%s]',x.UnitsString));
92title(sprintf('Storage Ring Orbit (Difference from the %s Orbit)',RefFlag));
93xaxis([0 L]);
94
95subplot(2,1,2);
96plot(BPMyspos, Yerr, '.-');
97xlabel(XLabel);
98ylabel(sprintf('Vertical [%s]',y.UnitsString));
99xaxis([0 L]);
100
101addlabel(1, 0, datestr(clock,0));
102%addlabel(0, 0, sprintf(sprintf('RMS Error: Horizontal %6.4f %s  Vertical %6.4f %s', std(Xerr), x.UnitsString, std(Yerr), y.UnitsString)));
103addlabel(0, 0, sprintf(sprintf('RMS Error:   Horizontal %f %s    Vertical %f %s', std(Xerr), x.UnitsString, std(Yerr), y.UnitsString)));
104
Note: See TracBrowser for help on using the repository browser.