source: MML/trunk/mml/doc_html/mml/plotbpmrespsym.html @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 13.3 KB
Line 
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 &copy; 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> &gt;  <a href="index.html">mml</a> &gt; plotbpmrespsym.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for mml&nbsp;<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>
44This 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>
47This 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>
550002 <span class="comment">%PLOTBPMRESPSYM - Looks for symmetry of the orbit response matrix</span>
560003 <span class="comment">%  plotbpmrespsym(R)</span>
570004 <span class="comment">%  plotbpmrespsym(FileName)</span>
580005 <span class="comment">%</span>
590006 <span class="comment">%  NOTES</span>
600007 <span class="comment">%  1. This function is only informative if the lattice is</span>
610008 <span class="comment">%     symmetric by sector.</span>
620009 <span class="comment">%  2. This function only works if the corrector and BPM</span>
630010 <span class="comment">%     placement is symmetric in each sector.</span>
640011 <span class="comment">%</span>
650012 <span class="comment">%  Written by Greg Portmann</span>
660013
670014
680015 <span class="keyword">if</span> nargin == 0
690016     R = <a href="getbpmresp.html" class="code" title="function [S, FileName] = getbpmresp(varargin)">getbpmresp</a>(<span class="string">'Struct'</span>);
700017 <span class="keyword">end</span>
710018 <span class="keyword">if</span> isempty(R)
720019     R = <a href="getbpmresp.html" class="code" title="function [S, FileName] = getbpmresp(varargin)">getbpmresp</a>(<span class="string">''</span>,<span class="string">'Struct'</span>);
730020 <span class="keyword">end</span>
740021 <span class="keyword">if</span> isempty(R)
750022     <span class="keyword">return</span>;
760023 <span class="keyword">end</span>
770024
780025
790026 <span class="comment">% Use physics units for scaling</span>
800027 R = <a href="hw2physics.html" class="code" title="function S = hw2physics(Family, Field, value, DeviceList, Energy)">hw2physics</a>(R);
810028
820029
830030 FontSize = 10;
840031 Buffer = .01;
850032 HeightBuffer = .08;
860033
870034
880035 Sx = R(1,1).Data;
890036 Sy = R(2,2).Data;
900037
910038 NSectors = R(1,1).Monitor.DeviceList(<span class="keyword">end</span>,1);
920039 NBPMxperSector = max(R(1,1).Monitor.DeviceList(:,2));
930040 NBPMyperSector = max(R(2,2).Monitor.DeviceList(:,2));
940041
950042 NBPMx = size(Sx,1);
960043 NBPMy = size(Sy,1);
970044
980045 NHCMperSector = max(R(1,1).Actuator.DeviceList(:,2));
990046 NVCMperSector = max(R(2,2).Actuator.DeviceList(:,2));
1000047
1010048 <span class="comment">%NHCMperSector = size(Sx,2) / NSectors;</span>
1020049 <span class="comment">%NVCMperSector = size(Sy,2) / NSectors;</span>
1030050
1040051 Circumference = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Circumference'</span>);
1050052
1060053 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);
1070054 BPMxs = BPMxs(:);
1080055 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);
1090056 BPMys = BPMys(:);
1100057
1110058 BPMxDev = R(1,1).Monitor.DeviceList;
1120059 BPMyDev = R(2,2).Monitor.DeviceList;
1130060 <span class="comment">% BPMxelem = dev2elem(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);</span>
1140061 <span class="comment">% BPMyelem = dev2elem(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);</span>
1150062
1160063 <span class="comment">% BPMxGain = getgain(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);</span>
1170064 <span class="comment">% BPMyGain = getgain(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);</span>
1180065
1190066 HCMDev = R(1,1).Actuator.DeviceList;
1200067 VCMDev = R(2,2).Actuator.DeviceList;
1210068 <span class="comment">% HCMelem = dev2elem('HCM', R(1,1).Actuator.DeviceList);</span>
1220069 <span class="comment">% VCMelem = dev2elem('VCM', R(2,2).Actuator.DeviceList);</span>
1230070
1240071 <span class="comment">% % Hardware units to mradian</span>
1250072 <span class="comment">% %HCMGain = getgain('HCM', R(1,1).Actuator.DeviceList);</span>
1260073 <span class="comment">% HCMGain = 1 ./ (hw2physics('HCM', 'Setpoint', R(1,1).ActuatorDelta, HCMDev) ./ R(1,1).ActuatorDelta) / 1000;</span>
1270074 <span class="comment">%</span>
1280075 <span class="comment">% %VCMGain = getgain('VCM', R(2,2).Actuator.DeviceList);</span>
1290076 <span class="comment">% VCMGain = 1 ./ (hw2physics('VCM', 'Setpoint', R(2,2).ActuatorDelta, VCMDev) ./ R(2,2).ActuatorDelta) / 1000;</span>
1300077
1310078 XUnitsString = R(1,1).UnitsString;
1320079 XUnitsString(findstr(XUnitsString,<span class="string">'('</span>)) = [];
1330080 XUnitsString(findstr(XUnitsString,<span class="string">')'</span>)) = [];
1340081 YUnitsString = R(2,2).UnitsString;
1350082 YUnitsString(findstr(YUnitsString,<span class="string">'('</span>)) = [];
1360083 YUnitsString(findstr(YUnitsString,<span class="string">')'</span>)) = [];
1370084
1380085
1390086 L = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Circumference'</span>);
1400087
1410088
1420089
1430090 <span class="comment">%%%%%%%%%%%%%%</span>
1440091 <span class="comment">% Horizontal %</span>
1450092 <span class="comment">%%%%%%%%%%%%%%</span>
1460093
1470094 <span class="comment">% % Scale response matrix by the BPM gains</span>
1480095 <span class="comment">% for i = 1:size(Sx,2)</span>
1490096 <span class="comment">%    Sx(:,i) = Sx(:,i) .* BPMxGain(:);</span>
1500097 <span class="comment">% end</span>
1510098 <span class="comment">%</span>
1520099 <span class="comment">% % Scale response matrix by the HCM gains</span>
1530100 <span class="comment">% for i = 1:size(Sx,1)</span>
1540101 <span class="comment">%    Sx(i,:) = Sx(i,:) .* HCMGain(:)';</span>
1550102 <span class="comment">%    %Sx(i,:) = Sx(i,:) ./ hw2physics('HCM', 'Setpoint', 1, HCMDev)'/1000;</span>
1560103 <span class="comment">%    %Sx(i,:) = Sx(i,:) / (1000*amps2rad('HCM',1,i));</span>
1570104 <span class="comment">% end</span>
1580105
1590106
1600107 figure;
1610108 clf reset
1620109 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]);
1630110 <span class="keyword">for</span> Mag = 1:NHCMperSector   
1640111     S = [];
1650112     P = [];
1660113     <span class="keyword">for</span> i = 1:NSectors
1670114         j = findrowindex([i Mag], HCMDev);
1680115         <span class="keyword">if</span> ~isempty(j)
1690116             k = min(find(BPMxDev(:,1)==i));
1700117             S = [S [Sx(k:<span class="keyword">end</span>, j); Sx(1:k-1, j)]];
1710118             P = [P [BPMxs(k:end); BPMxs(1:k-1)+L]-BPMxs(k)+BPMxs(1)];
1720119         <span class="keyword">end</span>
1730120     <span class="keyword">end</span>
1740121     
1750122     subplot(NHCMperSector, 1, Mag);
1760123     <span class="keyword">if</span> isempty(S)
1770124         plot(BPMxs, NaN*ones(size(BPMxs)));       
1780125     <span class="keyword">else</span>
1790126         plot(P, S);
1800127     <span class="keyword">end</span>
1810128     ylabel(sprintf(<span class="string">'Mag #%d'</span>, Mag), <span class="string">'FontSize'</span>, FontSize);
1820129 <span class="keyword">end</span>
1830130
1840131 subplot(NHCMperSector,1,1);
1850132 title(sprintf(<span class="string">'Horizontal Corrector Magnet Response (%s)'</span>, XUnitsString), <span class="string">'FontSize'</span>, FontSize);
1860133
1870134 subplot(NHCMperSector,1,NHCMperSector);
1880135 xlabel(<span class="string">'BPM Position [meters]'</span>, <span class="string">'FontSize'</span>, FontSize);
1890136 <span class="keyword">if</span> isfield(R(1,1), <span class="string">'TimeStamp'</span>)
1900137     addlabel(1,0,sprintf(<span class="string">'%s'</span>, datestr(R(1,1).TimeStamp)));
1910138 <span class="keyword">end</span>
1920139 orient tall
1930140
1940141
1950142 <span class="comment">%%%%%%%%%%%%</span>
1960143 <span class="comment">% Vertical %</span>
1970144 <span class="comment">%%%%%%%%%%%%</span>
1980145
1990146 <span class="comment">% % Scale response matrix by the BPM gains</span>
2000147 <span class="comment">% for i = 1:size(Sy,2)</span>
2010148 <span class="comment">%    Sy(:,i) = Sy(:,i) .* BPMyGain(:);</span>
2020149 <span class="comment">% end</span>
2030150 <span class="comment">%</span>
2040151 <span class="comment">% % Scale response matrix by the VCM gains</span>
2050152 <span class="comment">% for i = 1:size(Sy,1)</span>
2060153 <span class="comment">%    Sy(i,:) = Sy(i,:) .* VCMGain(:)';</span>
2070154 <span class="comment">%    %Sy(i,:) = Sy(i,:) / (1000*amps2rad('VCM',1,i));</span>
2080155 <span class="comment">% end</span>
2090156
2100157 figure(gcf+1);
2110158 clf reset
2120159 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]);
2130160
2140161 <span class="keyword">for</span> Mag = 1:NVCMperSector     
2150162     S = [];
2160163     P = [];
2170164     <span class="keyword">for</span> i = 1:NSectors
2180165         j = findrowindex([i Mag], VCMDev);
2190166         <span class="keyword">if</span> ~isempty(j)
2200167             k = min(find(BPMyDev(:,1)==i));
2210168             S = [S [Sy(k:<span class="keyword">end</span>, j); Sy(1:k-1, j)]];
2220169             P = [P [BPMys(k:end); BPMys(1:k-1)+L]-BPMys(k)+BPMys(1)];
2230170         <span class="keyword">end</span>
2240171     <span class="keyword">end</span>
2250172   
2260173     subplot(NVCMperSector, 1, Mag);
2270174     <span class="keyword">if</span> isempty(S)
2280175         plot(BPMys, NaN*ones(size(BPMys)));       
2290176     <span class="keyword">else</span>
2300177         plot(P, S);
2310178     <span class="keyword">end</span>
2320179     ylabel(sprintf(<span class="string">'Mag #%d'</span>, Mag), <span class="string">'FontSize'</span>, FontSize);
2330180 <span class="keyword">end</span>
2340181
2350182 subplot(NVCMperSector,1,1);
2360183 title(sprintf(<span class="string">'Vertical Corrector Magnet Response (%s)'</span>, XUnitsString), <span class="string">'FontSize'</span>, FontSize);
2370184
2380185 subplot(NVCMperSector,1,NVCMperSector);
2390186 xlabel(<span class="string">'BPM Position [meters]'</span>, <span class="string">'FontSize'</span>, FontSize);
2400187 <span class="keyword">if</span> isfield(R(1,1), <span class="string">'TimeStamp'</span>)
2410188     addlabel(1,0,sprintf(<span class="string">'%s'</span>, datestr(R(1,1).TimeStamp)));
2420189 <span class="keyword">end</span>
2430190 orient tall
2440191
2450192</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> &copy; 2003</address>
247</body>
248</html>
Note: See TracBrowser for help on using the repository browser.