1 | function plotoffsetorbit(varargin) |
---|
2 | %PLOTOFFSETORBIT - Plots the offset orbit |
---|
3 | % plotoffsetorbit(XAxisFlag) |
---|
4 | % |
---|
5 | % INPUTS |
---|
6 | % 1. XAxisFlag - 'Position' in meters {Default} or 'Phase' |
---|
7 | % |
---|
8 | % See also plotgoldenorbit |
---|
9 | % |
---|
10 | % See also plotgoldenorbit, setoffset, getoffset, saveoffsetorbit |
---|
11 | |
---|
12 | % |
---|
13 | % Written by Gregory J. Portmann |
---|
14 | % Modifed by Laurent S. Nadolski |
---|
15 | |
---|
16 | XAxisFlag = 'Position'; |
---|
17 | |
---|
18 | % Input parsing |
---|
19 | for i = length(varargin):-1:1 |
---|
20 | if isstruct(varargin{i}) |
---|
21 | % Ignor structures |
---|
22 | elseif iscell(varargin{i}) |
---|
23 | % Ignor cells |
---|
24 | elseif strcmpi(varargin{i},'struct') |
---|
25 | % Just remove |
---|
26 | varargin(i) = []; |
---|
27 | elseif strcmpi(varargin{i},'numeric') |
---|
28 | % Just remove |
---|
29 | varargin(i) = []; |
---|
30 | elseif strcmpi(varargin{i},'Position') |
---|
31 | XAxisFlag = 'Position'; |
---|
32 | varargin(i) = []; |
---|
33 | elseif strcmpi(varargin{i},'Phase') |
---|
34 | XAxisFlag = 'Phase'; |
---|
35 | varargin(i) = []; |
---|
36 | end |
---|
37 | end |
---|
38 | |
---|
39 | BPMxFamily = gethbpmfamily; |
---|
40 | BPMyFamily = getvbpmfamily; |
---|
41 | |
---|
42 | if strcmpi(XAxisFlag, 'Phase') |
---|
43 | [BPMxspos, BPMyspos, Sx, Sy, Tune] = modeltwiss('Phase', BPMxFamily, [], BPMyFamily, []); |
---|
44 | BPMxspos = BPMxspos/2/pi; |
---|
45 | BPMyspos = BPMyspos/2/pi; |
---|
46 | XLabel = 'BPM Phase'; |
---|
47 | else |
---|
48 | BPMxspos = getspos(BPMxFamily,family2dev(BPMxFamily)); |
---|
49 | BPMyspos = getspos(BPMyFamily,family2dev(BPMyFamily)); |
---|
50 | XLabel = 'BPM Position [meters]'; |
---|
51 | end |
---|
52 | |
---|
53 | |
---|
54 | % Get data |
---|
55 | Xoffset = getoffset(BPMxFamily); |
---|
56 | Yoffset = getoffset(BPMyFamily); |
---|
57 | |
---|
58 | |
---|
59 | % Change to physics units |
---|
60 | if any(strcmpi('Physics',varargin)) |
---|
61 | Xoffset = hw2physics(BPMxFamily, 'Monitor', Xoffset, family2dev(BPMxFamily)); |
---|
62 | Yoffset = hw2physics(BPMyFamily, 'Monitor', Yoffset, family2dev(BPMyFamily)); |
---|
63 | end |
---|
64 | |
---|
65 | UnitsString = getfamilydata('BPMx','Monitor','HWUnits'); |
---|
66 | |
---|
67 | figure |
---|
68 | clf reset |
---|
69 | subplot(2,1,1); |
---|
70 | plot(BPMxspos, Xoffset, '.-'); |
---|
71 | ylabel(sprintf('Horizontal [%s]',UnitsString)); |
---|
72 | title('Offset Orbit'); |
---|
73 | grid on |
---|
74 | |
---|
75 | subplot(2,1,2); |
---|
76 | plot(BPMyspos, Yoffset, '.-'); |
---|
77 | xlabel(XLabel); |
---|
78 | ylabel(sprintf('Vertical [%s]',UnitsString)); |
---|
79 | grid on |
---|
80 | |
---|
81 | orient tall |
---|
82 | |
---|