1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of plotbpmrespsym</title> |
---|
6 | <meta name="keywords" content="plotbpmrespsym"> |
---|
7 | <meta name="description" content="PLOTBPMRESPSYM - Looks for symmetry of the orbit response matrix"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../index.html">Home</a> > <a href="index.html">mml</a> > plotbpmrespsym.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for mml <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>plotbpmrespsym |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
24 | <div class="box"><strong>PLOTBPMRESPSYM - Looks for symmetry of the orbit response matrix</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function plotbpmrespsym(R) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">PLOTBPMRESPSYM - Looks for symmetry of the orbit response matrix |
---|
31 | plotbpmrespsym(R) |
---|
32 | plotbpmrespsym(FileName) |
---|
33 | |
---|
34 | NOTES |
---|
35 | 1. This function is only informative if the lattice is |
---|
36 | symmetric by sector. |
---|
37 | 2. This function only works if the corrector and BPM |
---|
38 | placement is symmetric in each sector. |
---|
39 | |
---|
40 | Written by Greg Portmann</pre></div> |
---|
41 | |
---|
42 | <!-- crossreference --> |
---|
43 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
44 | This function calls: |
---|
45 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
46 | <li><a href="getbpmresp.html" class="code" title="function [S, FileName] = getbpmresp(varargin)">getbpmresp</a> GETBPMRESP - Returns the BPM response matrix in the horizontal and vertical planes</li><li><a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a> GETFAMILYDATA - Gets data associated with the accelerator control</li><li><a href="getspos.html" class="code" title="function S = getspos(Family, DeviceList)">getspos</a> GETSPOS - Returns the longitudinal position in meters</li><li><a href="hw2physics.html" class="code" title="function S = hw2physics(Family, Field, value, DeviceList, Energy)">hw2physics</a> HW2PHYSICS - Converts from 'Hardware' units to 'Physics' units</li></ul> |
---|
47 | This function is called by: |
---|
48 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
49 | </ul> |
---|
50 | <!-- crossreference --> |
---|
51 | |
---|
52 | |
---|
53 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
54 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function plotbpmrespsym(R)</a> |
---|
55 | 0002 <span class="comment">%PLOTBPMRESPSYM - Looks for symmetry of the orbit response matrix</span> |
---|
56 | 0003 <span class="comment">% plotbpmrespsym(R)</span> |
---|
57 | 0004 <span class="comment">% plotbpmrespsym(FileName)</span> |
---|
58 | 0005 <span class="comment">%</span> |
---|
59 | 0006 <span class="comment">% NOTES</span> |
---|
60 | 0007 <span class="comment">% 1. This function is only informative if the lattice is</span> |
---|
61 | 0008 <span class="comment">% symmetric by sector.</span> |
---|
62 | 0009 <span class="comment">% 2. This function only works if the corrector and BPM</span> |
---|
63 | 0010 <span class="comment">% placement is symmetric in each sector.</span> |
---|
64 | 0011 <span class="comment">%</span> |
---|
65 | 0012 <span class="comment">% Written by Greg Portmann</span> |
---|
66 | 0013 |
---|
67 | 0014 |
---|
68 | 0015 <span class="keyword">if</span> nargin == 0 |
---|
69 | 0016 R = <a href="getbpmresp.html" class="code" title="function [S, FileName] = getbpmresp(varargin)">getbpmresp</a>(<span class="string">'Struct'</span>); |
---|
70 | 0017 <span class="keyword">end</span> |
---|
71 | 0018 <span class="keyword">if</span> isempty(R) |
---|
72 | 0019 R = <a href="getbpmresp.html" class="code" title="function [S, FileName] = getbpmresp(varargin)">getbpmresp</a>(<span class="string">''</span>,<span class="string">'Struct'</span>); |
---|
73 | 0020 <span class="keyword">end</span> |
---|
74 | 0021 <span class="keyword">if</span> isempty(R) |
---|
75 | 0022 <span class="keyword">return</span>; |
---|
76 | 0023 <span class="keyword">end</span> |
---|
77 | 0024 |
---|
78 | 0025 |
---|
79 | 0026 <span class="comment">% Use physics units for scaling</span> |
---|
80 | 0027 R = <a href="hw2physics.html" class="code" title="function S = hw2physics(Family, Field, value, DeviceList, Energy)">hw2physics</a>(R); |
---|
81 | 0028 |
---|
82 | 0029 |
---|
83 | 0030 FontSize = 10; |
---|
84 | 0031 Buffer = .01; |
---|
85 | 0032 HeightBuffer = .08; |
---|
86 | 0033 |
---|
87 | 0034 |
---|
88 | 0035 Sx = R(1,1).Data; |
---|
89 | 0036 Sy = R(2,2).Data; |
---|
90 | 0037 |
---|
91 | 0038 NSectors = R(1,1).Monitor.DeviceList(<span class="keyword">end</span>,1); |
---|
92 | 0039 NBPMxperSector = max(R(1,1).Monitor.DeviceList(:,2)); |
---|
93 | 0040 NBPMyperSector = max(R(2,2).Monitor.DeviceList(:,2)); |
---|
94 | 0041 |
---|
95 | 0042 NBPMx = size(Sx,1); |
---|
96 | 0043 NBPMy = size(Sy,1); |
---|
97 | 0044 |
---|
98 | 0045 NHCMperSector = max(R(1,1).Actuator.DeviceList(:,2)); |
---|
99 | 0046 NVCMperSector = max(R(2,2).Actuator.DeviceList(:,2)); |
---|
100 | 0047 |
---|
101 | 0048 <span class="comment">%NHCMperSector = size(Sx,2) / NSectors;</span> |
---|
102 | 0049 <span class="comment">%NVCMperSector = size(Sy,2) / NSectors;</span> |
---|
103 | 0050 |
---|
104 | 0051 Circumference = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Circumference'</span>); |
---|
105 | 0052 |
---|
106 | 0053 BPMxs = <a href="getspos.html" class="code" title="function S = getspos(Family, DeviceList)">getspos</a>(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList); |
---|
107 | 0054 BPMxs = BPMxs(:); |
---|
108 | 0055 BPMys = <a href="getspos.html" class="code" title="function S = getspos(Family, DeviceList)">getspos</a>(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList); |
---|
109 | 0056 BPMys = BPMys(:); |
---|
110 | 0057 |
---|
111 | 0058 BPMxDev = R(1,1).Monitor.DeviceList; |
---|
112 | 0059 BPMyDev = R(2,2).Monitor.DeviceList; |
---|
113 | 0060 <span class="comment">% BPMxelem = dev2elem(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);</span> |
---|
114 | 0061 <span class="comment">% BPMyelem = dev2elem(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);</span> |
---|
115 | 0062 |
---|
116 | 0063 <span class="comment">% BPMxGain = getgain(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);</span> |
---|
117 | 0064 <span class="comment">% BPMyGain = getgain(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);</span> |
---|
118 | 0065 |
---|
119 | 0066 HCMDev = R(1,1).Actuator.DeviceList; |
---|
120 | 0067 VCMDev = R(2,2).Actuator.DeviceList; |
---|
121 | 0068 <span class="comment">% HCMelem = dev2elem('HCM', R(1,1).Actuator.DeviceList);</span> |
---|
122 | 0069 <span class="comment">% VCMelem = dev2elem('VCM', R(2,2).Actuator.DeviceList);</span> |
---|
123 | 0070 |
---|
124 | 0071 <span class="comment">% % Hardware units to mradian</span> |
---|
125 | 0072 <span class="comment">% %HCMGain = getgain('HCM', R(1,1).Actuator.DeviceList);</span> |
---|
126 | 0073 <span class="comment">% HCMGain = 1 ./ (hw2physics('HCM', 'Setpoint', R(1,1).ActuatorDelta, HCMDev) ./ R(1,1).ActuatorDelta) / 1000;</span> |
---|
127 | 0074 <span class="comment">%</span> |
---|
128 | 0075 <span class="comment">% %VCMGain = getgain('VCM', R(2,2).Actuator.DeviceList);</span> |
---|
129 | 0076 <span class="comment">% VCMGain = 1 ./ (hw2physics('VCM', 'Setpoint', R(2,2).ActuatorDelta, VCMDev) ./ R(2,2).ActuatorDelta) / 1000;</span> |
---|
130 | 0077 |
---|
131 | 0078 XUnitsString = R(1,1).UnitsString; |
---|
132 | 0079 XUnitsString(findstr(XUnitsString,<span class="string">'('</span>)) = []; |
---|
133 | 0080 XUnitsString(findstr(XUnitsString,<span class="string">')'</span>)) = []; |
---|
134 | 0081 YUnitsString = R(2,2).UnitsString; |
---|
135 | 0082 YUnitsString(findstr(YUnitsString,<span class="string">'('</span>)) = []; |
---|
136 | 0083 YUnitsString(findstr(YUnitsString,<span class="string">')'</span>)) = []; |
---|
137 | 0084 |
---|
138 | 0085 |
---|
139 | 0086 L = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Circumference'</span>); |
---|
140 | 0087 |
---|
141 | 0088 |
---|
142 | 0089 |
---|
143 | 0090 <span class="comment">%%%%%%%%%%%%%%</span> |
---|
144 | 0091 <span class="comment">% Horizontal %</span> |
---|
145 | 0092 <span class="comment">%%%%%%%%%%%%%%</span> |
---|
146 | 0093 |
---|
147 | 0094 <span class="comment">% % Scale response matrix by the BPM gains</span> |
---|
148 | 0095 <span class="comment">% for i = 1:size(Sx,2)</span> |
---|
149 | 0096 <span class="comment">% Sx(:,i) = Sx(:,i) .* BPMxGain(:);</span> |
---|
150 | 0097 <span class="comment">% end</span> |
---|
151 | 0098 <span class="comment">%</span> |
---|
152 | 0099 <span class="comment">% % Scale response matrix by the HCM gains</span> |
---|
153 | 0100 <span class="comment">% for i = 1:size(Sx,1)</span> |
---|
154 | 0101 <span class="comment">% Sx(i,:) = Sx(i,:) .* HCMGain(:)';</span> |
---|
155 | 0102 <span class="comment">% %Sx(i,:) = Sx(i,:) ./ hw2physics('HCM', 'Setpoint', 1, HCMDev)'/1000;</span> |
---|
156 | 0103 <span class="comment">% %Sx(i,:) = Sx(i,:) / (1000*amps2rad('HCM',1,i));</span> |
---|
157 | 0104 <span class="comment">% end</span> |
---|
158 | 0105 |
---|
159 | 0106 |
---|
160 | 0107 figure; |
---|
161 | 0108 clf reset |
---|
162 | 0109 set(gcf,<span class="string">'units'</span>,<span class="string">'normal'</span>,<span class="string">'position'</span>,[.0+Buffer .27+Buffer .5-2*Buffer .72-2*Buffer-HeightBuffer]); |
---|
163 | 0110 <span class="keyword">for</span> Mag = 1:NHCMperSector |
---|
164 | 0111 S = []; |
---|
165 | 0112 P = []; |
---|
166 | 0113 <span class="keyword">for</span> i = 1:NSectors |
---|
167 | 0114 j = findrowindex([i Mag], HCMDev); |
---|
168 | 0115 <span class="keyword">if</span> ~isempty(j) |
---|
169 | 0116 k = min(find(BPMxDev(:,1)==i)); |
---|
170 | 0117 S = [S [Sx(k:<span class="keyword">end</span>, j); Sx(1:k-1, j)]]; |
---|
171 | 0118 P = [P [BPMxs(k:end); BPMxs(1:k-1)+L]-BPMxs(k)+BPMxs(1)]; |
---|
172 | 0119 <span class="keyword">end</span> |
---|
173 | 0120 <span class="keyword">end</span> |
---|
174 | 0121 |
---|
175 | 0122 subplot(NHCMperSector, 1, Mag); |
---|
176 | 0123 <span class="keyword">if</span> isempty(S) |
---|
177 | 0124 plot(BPMxs, NaN*ones(size(BPMxs))); |
---|
178 | 0125 <span class="keyword">else</span> |
---|
179 | 0126 plot(P, S); |
---|
180 | 0127 <span class="keyword">end</span> |
---|
181 | 0128 ylabel(sprintf(<span class="string">'Mag #%d'</span>, Mag), <span class="string">'FontSize'</span>, FontSize); |
---|
182 | 0129 <span class="keyword">end</span> |
---|
183 | 0130 |
---|
184 | 0131 subplot(NHCMperSector,1,1); |
---|
185 | 0132 title(sprintf(<span class="string">'Horizontal Corrector Magnet Response (%s)'</span>, XUnitsString), <span class="string">'FontSize'</span>, FontSize); |
---|
186 | 0133 |
---|
187 | 0134 subplot(NHCMperSector,1,NHCMperSector); |
---|
188 | 0135 xlabel(<span class="string">'BPM Position [meters]'</span>, <span class="string">'FontSize'</span>, FontSize); |
---|
189 | 0136 <span class="keyword">if</span> isfield(R(1,1), <span class="string">'TimeStamp'</span>) |
---|
190 | 0137 addlabel(1,0,sprintf(<span class="string">'%s'</span>, datestr(R(1,1).TimeStamp))); |
---|
191 | 0138 <span class="keyword">end</span> |
---|
192 | 0139 orient tall |
---|
193 | 0140 |
---|
194 | 0141 |
---|
195 | 0142 <span class="comment">%%%%%%%%%%%%</span> |
---|
196 | 0143 <span class="comment">% Vertical %</span> |
---|
197 | 0144 <span class="comment">%%%%%%%%%%%%</span> |
---|
198 | 0145 |
---|
199 | 0146 <span class="comment">% % Scale response matrix by the BPM gains</span> |
---|
200 | 0147 <span class="comment">% for i = 1:size(Sy,2)</span> |
---|
201 | 0148 <span class="comment">% Sy(:,i) = Sy(:,i) .* BPMyGain(:);</span> |
---|
202 | 0149 <span class="comment">% end</span> |
---|
203 | 0150 <span class="comment">%</span> |
---|
204 | 0151 <span class="comment">% % Scale response matrix by the VCM gains</span> |
---|
205 | 0152 <span class="comment">% for i = 1:size(Sy,1)</span> |
---|
206 | 0153 <span class="comment">% Sy(i,:) = Sy(i,:) .* VCMGain(:)';</span> |
---|
207 | 0154 <span class="comment">% %Sy(i,:) = Sy(i,:) / (1000*amps2rad('VCM',1,i));</span> |
---|
208 | 0155 <span class="comment">% end</span> |
---|
209 | 0156 |
---|
210 | 0157 figure(gcf+1); |
---|
211 | 0158 clf reset |
---|
212 | 0159 set(gcf,<span class="string">'units'</span>,<span class="string">'normal'</span>,<span class="string">'position'</span>,[.5+Buffer .27+Buffer .5-2*Buffer .72-2*Buffer-HeightBuffer]); |
---|
213 | 0160 |
---|
214 | 0161 <span class="keyword">for</span> Mag = 1:NVCMperSector |
---|
215 | 0162 S = []; |
---|
216 | 0163 P = []; |
---|
217 | 0164 <span class="keyword">for</span> i = 1:NSectors |
---|
218 | 0165 j = findrowindex([i Mag], VCMDev); |
---|
219 | 0166 <span class="keyword">if</span> ~isempty(j) |
---|
220 | 0167 k = min(find(BPMyDev(:,1)==i)); |
---|
221 | 0168 S = [S [Sy(k:<span class="keyword">end</span>, j); Sy(1:k-1, j)]]; |
---|
222 | 0169 P = [P [BPMys(k:end); BPMys(1:k-1)+L]-BPMys(k)+BPMys(1)]; |
---|
223 | 0170 <span class="keyword">end</span> |
---|
224 | 0171 <span class="keyword">end</span> |
---|
225 | 0172 |
---|
226 | 0173 subplot(NVCMperSector, 1, Mag); |
---|
227 | 0174 <span class="keyword">if</span> isempty(S) |
---|
228 | 0175 plot(BPMys, NaN*ones(size(BPMys))); |
---|
229 | 0176 <span class="keyword">else</span> |
---|
230 | 0177 plot(P, S); |
---|
231 | 0178 <span class="keyword">end</span> |
---|
232 | 0179 ylabel(sprintf(<span class="string">'Mag #%d'</span>, Mag), <span class="string">'FontSize'</span>, FontSize); |
---|
233 | 0180 <span class="keyword">end</span> |
---|
234 | 0181 |
---|
235 | 0182 subplot(NVCMperSector,1,1); |
---|
236 | 0183 title(sprintf(<span class="string">'Vertical Corrector Magnet Response (%s)'</span>, XUnitsString), <span class="string">'FontSize'</span>, FontSize); |
---|
237 | 0184 |
---|
238 | 0185 subplot(NVCMperSector,1,NVCMperSector); |
---|
239 | 0186 xlabel(<span class="string">'BPM Position [meters]'</span>, <span class="string">'FontSize'</span>, FontSize); |
---|
240 | 0187 <span class="keyword">if</span> isfield(R(1,1), <span class="string">'TimeStamp'</span>) |
---|
241 | 0188 addlabel(1,0,sprintf(<span class="string">'%s'</span>, datestr(R(1,1).TimeStamp))); |
---|
242 | 0189 <span class="keyword">end</span> |
---|
243 | 0190 orient tall |
---|
244 | 0191 |
---|
245 | 0192</pre></div> |
---|
246 | <hr><address>Generated on Mon 21-May-2007 15:29:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
247 | </body> |
---|
248 | </html> |
---|