1 | function setorbitdefault(varargin) |
---|
2 | % setorbitdefault - Basic orbit correction for SOLEIL storage ring |
---|
3 | % |
---|
4 | % OPTIONAL INPUTS |
---|
5 | % 'Display' {'NoDisplay'} |
---|
6 | % 'Struct' |
---|
7 | % 'x' or 'h' or 'Horizontal' |
---|
8 | % 'y' or 'z' or 'v' or 'vertical' |
---|
9 | |
---|
10 | % Defaults |
---|
11 | PlaneFlag = 0; |
---|
12 | Iters = 1; |
---|
13 | Evectors = []; |
---|
14 | RemoveBPMDeviceList = []; |
---|
15 | RemoveHCMDeviceList = []; |
---|
16 | RemoveVCMDeviceList = []; |
---|
17 | DisplayFlag = 'NoDisplay'; |
---|
18 | |
---|
19 | HCMFamily = gethcmfamily; |
---|
20 | VCMFamily = getvcmfamily; |
---|
21 | |
---|
22 | |
---|
23 | % Input parsing |
---|
24 | for i = length(varargin):-1:1 |
---|
25 | if isstruct(varargin{i}) |
---|
26 | % Just remove |
---|
27 | varargin(i) = []; |
---|
28 | elseif iscell(varargin{i}) |
---|
29 | % Just remove |
---|
30 | varargin(i) = []; |
---|
31 | elseif strcmpi(varargin{i},'struct') |
---|
32 | % Just remove |
---|
33 | varargin(i) = []; |
---|
34 | elseif strcmpi(varargin{i},'numeric') |
---|
35 | % Just remove |
---|
36 | varargin(i) = []; |
---|
37 | elseif strcmpi(varargin{i},'Display') |
---|
38 | DisplayFlag = 'Display'; |
---|
39 | varargin(i) = []; |
---|
40 | elseif strcmpi(varargin{i},'NoDisplay') |
---|
41 | DisplayFlag = 'NoDisplay'; |
---|
42 | varargin(i) = []; |
---|
43 | elseif any(strcmpi(varargin{i},{'x', 'h', 'Horizontal'})) |
---|
44 | PlaneFlag = 1; |
---|
45 | varargin(i) = []; |
---|
46 | elseif any(strcmpi(varargin{i},{'y', 'z', 'v', 'Vertical'})) |
---|
47 | PlaneFlag = 2; |
---|
48 | varargin(i) = []; |
---|
49 | end |
---|
50 | end |
---|
51 | |
---|
52 | |
---|
53 | if length(varargin) >= 1 |
---|
54 | if isnumeric(varargin{1}) |
---|
55 | Evectors = varargin{1}; |
---|
56 | varargin(i) = []; |
---|
57 | end |
---|
58 | end |
---|
59 | if isempty(Evectors) |
---|
60 | nxcor = 57; |
---|
61 | nycor = 57; |
---|
62 | if PlaneFlag == 0 |
---|
63 | % Both planes |
---|
64 | Evectors = 1:(nxcor + nycor); |
---|
65 | elseif PlaneFlag == 1 |
---|
66 | % Horizontal |
---|
67 | Evectors = 1:nxcor; |
---|
68 | elseif PlaneFlag == 2 |
---|
69 | Evectors = 1:nycor; |
---|
70 | end |
---|
71 | end |
---|
72 | |
---|
73 | if length(varargin) >= 1 |
---|
74 | if isnumeric(varargin{1}) |
---|
75 | Iters = varargin{1}; |
---|
76 | varargin(i) = []; |
---|
77 | end |
---|
78 | end |
---|
79 | |
---|
80 | if length(varargin) >= 1 |
---|
81 | if isnumeric(varargin{1}) |
---|
82 | RemoveBPMDeviceList = varargin{1}; |
---|
83 | varargin(i) = []; |
---|
84 | end |
---|
85 | end |
---|
86 | |
---|
87 | if PlaneFlag == 0 |
---|
88 | % Get BPM and CM structures |
---|
89 | CM = {getsp(HCMFamily,'struct'),getsp(VCMFamily,'struct')}; |
---|
90 | BPM = {getx('struct'), gety('struct')}; |
---|
91 | |
---|
92 | |
---|
93 | % Remove devices |
---|
94 | |
---|
95 | % HCM |
---|
96 | i = findrowindex(RemoveHCMDeviceList, CM{1}.DeviceList); |
---|
97 | CM{1}.DeviceList(i,:) = []; |
---|
98 | CM{1}.Data(i,:) = []; |
---|
99 | CM{1}.Status(i,:) = []; |
---|
100 | |
---|
101 | % VCM |
---|
102 | i = findrowindex(RemoveVCMDeviceList, CM{2}.DeviceList); |
---|
103 | CM{2}.DeviceList(i,:) = []; |
---|
104 | CM{2}.Data(i,:) = []; |
---|
105 | CM{2}.Status(i,:) = []; |
---|
106 | |
---|
107 | % BPMx and BPMy |
---|
108 | i = findrowindex(RemoveBPMDeviceList, BPM{1}.DeviceList); |
---|
109 | BPM{1}.DeviceList(i,:) = []; |
---|
110 | BPM{1}.Data(i,:) = []; |
---|
111 | BPM{1}.Status(i,:) = []; |
---|
112 | |
---|
113 | i = findrowindex(RemoveBPMDeviceList, BPM{2}.DeviceList); |
---|
114 | BPM{2}.DeviceList(i,:) = []; |
---|
115 | BPM{2}.Data(i,:) = []; |
---|
116 | BPM{2}.Status(i,:) = []; |
---|
117 | |
---|
118 | elseif PlaneFlag == 1 |
---|
119 | |
---|
120 | % Get BPM and CM structures |
---|
121 | CM = getsp(HCMFamily,'struct'); |
---|
122 | BPM = getx('struct'); |
---|
123 | |
---|
124 | |
---|
125 | % Remove devices |
---|
126 | |
---|
127 | % HCM |
---|
128 | i = findrowindex(RemoveHCMDeviceList, CM.DeviceList); |
---|
129 | CM.DeviceList(i,:) = []; |
---|
130 | CM.Data(i,:) = []; |
---|
131 | CM.Status(i,:) = []; |
---|
132 | |
---|
133 | % BPMx |
---|
134 | i = findrowindex(RemoveBPMDeviceList, BPM.DeviceList); |
---|
135 | BPM.DeviceList(i,:) = []; |
---|
136 | BPM.Data(i,:) = []; |
---|
137 | BPM.Status(i,:) = []; |
---|
138 | |
---|
139 | elseif PlaneFlag == 2 |
---|
140 | |
---|
141 | % Get BPM and CM structures |
---|
142 | CM = getsp(VCMFamily,'struct'); |
---|
143 | BPM = gety('struct'); |
---|
144 | |
---|
145 | |
---|
146 | % Remove devices |
---|
147 | |
---|
148 | % VCM |
---|
149 | i = findrowindex(RemoveVCMDeviceList, CM.DeviceList); |
---|
150 | CM.DeviceList(i,:) = []; |
---|
151 | CM.Data(i,:) = []; |
---|
152 | CM.Status(i,:) = []; |
---|
153 | |
---|
154 | % BPMy |
---|
155 | i = findrowindex(RemoveBPMDeviceList, BPM.DeviceList); |
---|
156 | BPM.DeviceList(i,:) = []; |
---|
157 | BPM.Data(i,:) = []; |
---|
158 | BPM.Status(i,:) = []; |
---|
159 | end |
---|
160 | |
---|
161 | |
---|
162 | % Corrector orbit |
---|
163 | setorbit('Golden', BPM, CM, Iters, Evectors, DisplayFlag, varargin{:}); |
---|