source: MML/trunk/mml/doc_html/mml/gettuneresp.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: 21.9 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 gettuneresp</title>
6  <meta name="keywords" content="gettuneresp">
7  <meta name="description" content="GETTUNERESP - Loads the tune response vector (or matrix) for multiple quadrupole families">
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; gettuneresp.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>gettuneresp
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>GETTUNERESP - Loads the tune response vector (or matrix) for multiple quadrupole families</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 [TuneMatrix, FileName] = gettuneresp(varargin) </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">GETTUNERESP - Loads the tune response vector (or matrix) for multiple quadrupole families
31  [TuneMatrix, FileName] = gettuneresp(FamilyName1, DeviceList1, FamilyName2, DeviceList2, ... , FileName, GeV)
32  [TuneMatrix, FileName] = gettuneresp(DataStructure1, DataStructure2, ... , FileName, GeV)
33
34  INPUTS
35  1. FamilyName - Quadrupole family name
36  2. DeviceList - DeviceList for a quadrupole family.  If [] or no input, then TuneMatrix
37                  will be a column vector which is the cumulative sum of all magnets in the family.
38  3. FileName - File name to look for the response matrix (or cell array of file names)
39                '' prompts the user to choose a response matrix file
40  4. GeV will linearly scale the response matrix from the measured energy {Default: getenergy}.
41
42  OUTPUTS
43  1. TuneMatrix = Response matrix
44
45     It is assumed that most common use of this function is with the 
46     Q7 and Q9 families on a ganged power supply.  Hence, the default
47     behavior is to return the cumulative sum of all the magnets in the chain.
48     If there is more than one FamilyName, then TuneMatrix will be a matrix 
49     where each column is the sum of the contribution of all magnets in that family.
50
51     To get the response matrix for individual magnets in the family use getrespmat:
52     getrespmat('TUNE', [1 1;1 2], MagnetFamilyName, MagnetDeviceList)
53     For instance, getrespmat('TUNE', [1 1;1 2], 'Q1', [])
54
55  EXAMPLES
56  1. M = gettuneresp
57     M = gettuneresp({'Q7','Q9'})
58     M = gettuneresp({'Q7','Q9'},{[],[]})
59     M = gettuneresp('Q7',getlist('Q9'))
60     All returns the same 2x2 matrix of Q7 and Q9 to horizontal and vertical tune
61
62  2. M = gettuneresp('Q7')
63     M = gettuneresp('Q7', [])
64     Returns a 2x1 matrix representing the cumulative sum of all the magnets in the chain
65
66  3. Q9_DataStruct = getsp('Q9','Struct');
67     M = gettuneresp(Q9_DataStruct);
68     Returns a 2x1 matrix representing the cumulative sum of all the magnets in the chain
69
70  4. Change the tune by [.01; -.01] using the entire 'Q7' and 'Q9' families (see stepchro)
71     DeltaTune = [.01; -.01];
72     DeltaAmps = inv(gettuneresp) * DeltaTune;
73     setsp({'Q7', 'Q9'}, {getsp('Q7')+DeltaAmps(1), getsp('Q9')+DeltaAmps(2)});</pre></div>
74
75<!-- crossreference -->
76<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
77This function calls:
78<ul style="list-style-image:url(../matlabicon.gif)">
79<li><a href="findmemberof.html" class="code" title="function  FamilyName = findmemberof(MemberString, Field)">findmemberof</a>  FINDMEMBEROF - Finds all family members</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="getrespmat.html" class="code" title="function [S, FileName] = getrespmat(varargin)">getrespmat</a>   GETRESPMAT - Get response matrix data from a file</li><li><a href="isfamily.html" class="code" title="function  [FamilyFlag, AO] = isfamily(Family, Field)">isfamily</a>        ISFAMILY - True for family names</li><li><a href="meastuneresp.html" class="code" title="function [Rmat, OutputFileName] = meastuneresp(varargin)">meastuneresp</a>     MEASTUNERESP - Measures the response from quadrupole to tune</li></ul>
80This function is called by:
81<ul style="list-style-image:url(../matlabicon.gif)">
82<li><a href="measidfftable.html" class="code" title="function ffgettbl(Sector, BPMFlag)">measidfftable</a>      FFGETTBL - Measures an insertion device feed forward table for the vertical gap</li><li><a href="settune.html" class="code" title="function [DelQuad, ActuatorFamily] = settune(varargin)">settune</a>  SETTUNE - Set the tune</li><li><a href="steptune.html" class="code" title="function [DelQuad, ActuatorFamily] = steptune(varargin)">steptune</a>        STEPTUNE - Step the tune</li></ul>
83<!-- crossreference -->
84
85
86<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
87<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [TuneMatrix, FileName] = gettuneresp(varargin)</a>
880002 <span class="comment">%GETTUNERESP - Loads the tune response vector (or matrix) for multiple quadrupole families</span>
890003 <span class="comment">%  [TuneMatrix, FileName] = gettuneresp(FamilyName1, DeviceList1, FamilyName2, DeviceList2, ... , FileName, GeV)</span>
900004 <span class="comment">%  [TuneMatrix, FileName] = gettuneresp(DataStructure1, DataStructure2, ... , FileName, GeV)</span>
910005 <span class="comment">%</span>
920006 <span class="comment">%  INPUTS</span>
930007 <span class="comment">%  1. FamilyName - Quadrupole family name</span>
940008 <span class="comment">%  2. DeviceList - DeviceList for a quadrupole family.  If [] or no input, then TuneMatrix</span>
950009 <span class="comment">%                  will be a column vector which is the cumulative sum of all magnets in the family.</span>
960010 <span class="comment">%  3. FileName - File name to look for the response matrix (or cell array of file names)</span>
970011 <span class="comment">%                '' prompts the user to choose a response matrix file</span>
980012 <span class="comment">%  4. GeV will linearly scale the response matrix from the measured energy {Default: getenergy}.</span>
990013 <span class="comment">%</span>
1000014 <span class="comment">%  OUTPUTS</span>
1010015 <span class="comment">%  1. TuneMatrix = Response matrix</span>
1020016 <span class="comment">%</span>
1030017 <span class="comment">%     It is assumed that most common use of this function is with the</span>
1040018 <span class="comment">%     Q7 and Q9 families on a ganged power supply.  Hence, the default</span>
1050019 <span class="comment">%     behavior is to return the cumulative sum of all the magnets in the chain.</span>
1060020 <span class="comment">%     If there is more than one FamilyName, then TuneMatrix will be a matrix</span>
1070021 <span class="comment">%     where each column is the sum of the contribution of all magnets in that family.</span>
1080022 <span class="comment">%</span>
1090023 <span class="comment">%     To get the response matrix for individual magnets in the family use getrespmat:</span>
1100024 <span class="comment">%     getrespmat('TUNE', [1 1;1 2], MagnetFamilyName, MagnetDeviceList)</span>
1110025 <span class="comment">%     For instance, getrespmat('TUNE', [1 1;1 2], 'Q1', [])</span>
1120026 <span class="comment">%</span>
1130027 <span class="comment">%  EXAMPLES</span>
1140028 <span class="comment">%  1. M = gettuneresp</span>
1150029 <span class="comment">%     M = gettuneresp({'Q7','Q9'})</span>
1160030 <span class="comment">%     M = gettuneresp({'Q7','Q9'},{[],[]})</span>
1170031 <span class="comment">%     M = gettuneresp('Q7',getlist('Q9'))</span>
1180032 <span class="comment">%     All returns the same 2x2 matrix of Q7 and Q9 to horizontal and vertical tune</span>
1190033 <span class="comment">%</span>
1200034 <span class="comment">%  2. M = gettuneresp('Q7')</span>
1210035 <span class="comment">%     M = gettuneresp('Q7', [])</span>
1220036 <span class="comment">%     Returns a 2x1 matrix representing the cumulative sum of all the magnets in the chain</span>
1230037 <span class="comment">%</span>
1240038 <span class="comment">%  3. Q9_DataStruct = getsp('Q9','Struct');</span>
1250039 <span class="comment">%     M = gettuneresp(Q9_DataStruct);</span>
1260040 <span class="comment">%     Returns a 2x1 matrix representing the cumulative sum of all the magnets in the chain</span>
1270041 <span class="comment">%</span>
1280042 <span class="comment">%  4. Change the tune by [.01; -.01] using the entire 'Q7' and 'Q9' families (see stepchro)</span>
1290043 <span class="comment">%     DeltaTune = [.01; -.01];</span>
1300044 <span class="comment">%     DeltaAmps = inv(gettuneresp) * DeltaTune;</span>
1310045 <span class="comment">%     setsp({'Q7', 'Q9'}, {getsp('Q7')+DeltaAmps(1), getsp('Q9')+DeltaAmps(2)});</span>
1320046
1330047 <span class="comment">%</span>
1340048 <span class="comment">%  Written by Gregory J. Portmann</span>
1350049 <span class="comment">%  Modified by Laurent S. Nadolski</span>
1360050
1370051 FileName = <span class="string">''</span>;
1380052 NumericFlag = 1;
1390053 InputFlags = {};
1400054 <span class="keyword">for</span> i = length(varargin):-1:1
1410055     <span class="keyword">if</span> isstruct(varargin{i})
1420056         <span class="comment">% Ignore structures</span>
1430057     <span class="keyword">elseif</span> iscell(varargin{i})
1440058         <span class="comment">% Ignore cells</span>
1450059     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Struct'</span>)
1460060         <span class="comment">% Remove</span>
1470061         varargin(i) = [];
1480062     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Numeric'</span>)
1490063         <span class="comment">% Remove</span>
1500064         varargin(i) = [];
1510065     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Online'</span>)
1520066         <span class="comment">% Remove</span>
1530067         fprintf(<span class="string">'GETTUNERESP WARNING: ''Online'' input ignored.  Used meastuneresp to get the chromaticity response matrix.'</span>);
1540068         varargin(i) = [];
1550069     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Simulator'</span>)
1560070         <span class="comment">% Remove</span>
1570071         fprintf(<span class="string">'GETTUNERESP WARNING: ''Simulator'' input ignored.  Used meastuneresp to get the chromaticity response matrix.'</span>);
1580072         varargin(i) = [];
1590073     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Model'</span>)
1600074         <span class="comment">% Remove</span>
1610075         fprintf(<span class="string">'GETTUNERESP WARNING: ''Model'' input ignored.  Used meastuneresp to get the model chromaticity response matrix.'</span>);
1620076         varargin(i) = [];
1630077     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Model'</span>)
1640078         fprintf(<span class="string">'WARNING: ''Model'' input ignored.  Used meastuneresp to get the model tune response matrix.'</span>);
1650079         varargin(i) = [];
1660080     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'NoEnergyScaling'</span>)
1670081         InputFlags = [InputFlags varargin(i)];
1680082         varargin(i) = [];
1690083     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'EnergyScaling'</span>)
1700084         InputFlags = [InputFlags varargin(i)];
1710085         varargin(i) = [];
1720086     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Physics'</span>)
1730087         InputFlags = [InputFlags varargin(i)];
1740088         varargin(i) = [];
1750089     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'Hardware'</span>)
1760090         InputFlags = [InputFlags varargin(i)];
1770091         varargin(i) = [];
1780092     <span class="keyword">elseif</span> strcmpi(varargin{i},<span class="string">'FileName'</span>)
1790093         <span class="keyword">if</span> length(varargin) &gt;= i+1 &amp; ischar(varargin{i+1})
1800094             FileName = varargin{i+1};
1810095             varargin(i:i+1) = [];
1820096         <span class="keyword">else</span>
1830097             varargin(i) = [];
1840098         <span class="keyword">end</span>
1850099         <span class="keyword">if</span> isempty(FileName)
1860100             DirectoryName = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Directory'</span>, <span class="string">'TuneResponse'</span>);
1870101             [FileName, DirectoryName] = uigetfile(<span class="string">'*.mat'</span>, <span class="string">'Select a TUNE response matrix file'</span>, DirectoryName);
1880102             InputFlags = [InputFlags {[DirectoryName FileName]}];
1890103         <span class="keyword">else</span>
1900104             InputFlags = [InputFlags {FileName}];
1910105         <span class="keyword">end</span>
1920106     <span class="keyword">end</span>
1930107 <span class="keyword">end</span>
1940108
1950109 ActuatorFamilyDefault = <a href="findmemberof.html" class="code" title="function  FamilyName = findmemberof(MemberString, Field)">findmemberof</a>(<span class="string">'Tune Corrector'</span>)';
1960110 <span class="keyword">if</span> isempty(ActuatorFamilyDefault)
1970111     ActuatorFamilyDefault = {<span class="string">'Q7'</span>,<span class="string">'Q9'</span>};
1980112 <span class="keyword">end</span>
1990113
2000114 <span class="keyword">if</span> length(varargin) == 0
2010115     FamilyNameCell = ActuatorFamilyDefault;
2020116     DeviceListCell = cell(size(ActuatorFamilyDefault));
2030117     NumFamilies = length(FamilyNameCell);
2040118     
2050119 <span class="keyword">elseif</span> length(varargin) == 1 &amp; isempty(varargin{1})
2060120     FamilyNameCell = ActuatorFamilyDefault;
2070121     DeviceListCell = cell(size(ActuatorFamilyDefault));
2080122     NumFamilies = length(FamilyNameCell);
2090123     
2100124 <span class="keyword">elseif</span> iscell(varargin{1})
2110125     FamilyNameCell = varargin{1};
2120126     varargin(1) = [];
2130127     <span class="keyword">if</span> length(varargin) &gt;= 1
2140128         DeviceListCell = varargin{1};
2150129         varargin(1) = [];
2160130     <span class="keyword">else</span>
2170131         <span class="keyword">for</span> i = 1:length(FamilyNameCell)
2180132             DeviceListCell{i} = [];
2190133         <span class="keyword">end</span>
2200134     <span class="keyword">end</span>
2210135     NumFamilies = length(FamilyNameCell);
2220136     <span class="keyword">if</span> ~iscell(DeviceListCell)
2230137         error(<span class="string">'If FamilyName is a cell array then DeviceList must be a cell array'</span>)
2240138     <span class="keyword">end</span>
2250139     
2260140 <span class="keyword">elseif</span> isstruct(varargin{1})
2270141     NumFamilies = 0;
2280142     <span class="keyword">while</span> ~isempty(varargin)
2290143         <span class="comment">% Look for Family and DeviceList</span>
2300144         <span class="keyword">if</span> length(varargin) &gt;= 1
2310145             <span class="keyword">if</span> ~isstruct(varargin{1})
2320146                 <span class="keyword">break</span>
2330147             <span class="keyword">end</span>
2340148             <span class="keyword">if</span> ~<a href="isfamily.html" class="code" title="function  [FamilyFlag, AO] = isfamily(Family, Field)">isfamily</a>(varargin{1}.FamilyName)
2350149                 error(<span class="string">'Unknown family name in data structure'</span>);
2360150             <span class="keyword">end</span>
2370151             NumFamilies = NumFamilies + 1;
2380152             FamilyNameCell{NumFamilies} = varargin{1}.FamilyName;
2390153             DeviceListCell{NumFamilies} = varargin{1}.DeviceList;
2400154             varargin(1) = [];
2410155         <span class="keyword">end</span>
2420156     <span class="keyword">end</span>
2430157     
2440158 <span class="keyword">else</span>
2450159     NumFamilies = 0;
2460160     <span class="keyword">while</span> ~isempty(varargin)
2470161         <span class="comment">% Look for Family and DeviceList</span>
2480162         <span class="keyword">if</span> length(varargin) &gt;= 1
2490163             <span class="keyword">if</span> ~<a href="isfamily.html" class="code" title="function  [FamilyFlag, AO] = isfamily(Family, Field)">isfamily</a>(varargin{1})
2500164                 <span class="keyword">break</span>
2510165             <span class="keyword">end</span>
2520166             NumFamilies = NumFamilies + 1;
2530167             FamilyNameCell{NumFamilies} = varargin{1};
2540168             varargin(1) = [];
2550169         <span class="keyword">end</span>
2560170         <span class="keyword">if</span> length(varargin) &gt;= 1
2570171             <span class="keyword">if</span> isnumeric(varargin{1}) | isempty(varargin{1})
2580172                 DeviceListCell{NumFamilies} = varargin{1};
2590173                 varargin(1) = [];
2600174             <span class="keyword">else</span>
2610175                 DeviceListCell{NumFamilies} = [];
2620176             <span class="keyword">end</span>
2630177         <span class="keyword">else</span>
2640178             DeviceListCell{NumFamilies} = [];
2650179         <span class="keyword">end</span>
2660180     <span class="keyword">end</span>
2670181 <span class="keyword">end</span>
2680182
2690183 <span class="comment">% FileName should be the next input (if a string, or [] for dialog box)</span>
2700184 <span class="keyword">if</span> length(varargin) &gt;= 1
2710185     <span class="keyword">if</span> ischar(varargin{1}) | isempty(varargin{1})
2720186         FileName = varargin{1};
2730187         varargin(1) = [];
2740188
2750189         <span class="keyword">if</span> isempty(FileName)
2760190             <span class="comment">% Note: This only works if all families are in the same file</span>
2770191             DirectoryName = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Directory'</span>, <span class="string">'TuneResponse'</span>); 
2780192             [FileName, DirectoryName, FilterIndex] = uigetfile(<span class="string">'*.mat'</span>,<span class="string">'Select Quadrupole-to-Tune Response Matrix File'</span>, DirectoryName);
2790193             <span class="keyword">if</span> FilterIndex == 0
2800194                 TuneMatrix = [];
2810195                 FileName = [];
2820196                 <span class="keyword">return</span>
2830197             <span class="keyword">end</span>
2840198             
2850199             FileName = [DirectoryName FileName];
2860200             InputFlags = [{FileName} InputFlags];
2870201         <span class="keyword">end</span>
2880202     <span class="keyword">end</span>
2890203 <span class="keyword">end</span>
2900204
2910205
2920206 <span class="comment">% The only thing left on the input line can be energy which can be left in varargin</span>
2930207
2940208
2950209 <span class="comment">% Get the response matrix</span>
2960210 <span class="keyword">if</span> NumericFlag == 1
2970211     TuneMatrix = [];
2980212 <span class="keyword">end</span>
2990213 <span class="keyword">for</span> i = 1:NumFamilies
3000214     <span class="keyword">if</span> NumericFlag == 1
3010215         <span class="keyword">try</span>
3020216             [M, FileName] = <a href="getrespmat.html" class="code" title="function [S, FileName] = getrespmat(varargin)">getrespmat</a>(<span class="string">'TUNE'</span>, [1 1;1 2], FamilyNameCell{i}, DeviceListCell{i}, <span class="string">'Numeric'</span>, InputFlags{:}, varargin{:});
3030217         <span class="keyword">catch</span>
3040218             fprintf(<span class="string">'   Could not find a TUNE response matrix file, so using the model (%s).\n'</span>, FamilyNameCell{i});
3050219             M = <a href="meastuneresp.html" class="code" title="function [Rmat, OutputFileName] = meastuneresp(varargin)">meastuneresp</a>(FamilyNameCell{i}, DeviceListCell{i}, <span class="string">'Model'</span>, <span class="string">'Numeric'</span>, InputFlags{:}, varargin{:});
3060220             <span class="comment">%M = measrespmat('TUNE', [1 1;1 2], FamilyNameCell{i}, DeviceListCell{i}, 'Model', 'Numeric', InputFlags{:}, varargin{:});</span>
3070221             FileName = <span class="string">''</span>;
3080222         <span class="keyword">end</span>
3090223         TuneMatrix = [TuneMatrix sum(M,2)];
3100224     <span class="keyword">else</span>
3110225         <span class="keyword">try</span>
3120226             [TuneMatrix(1,i), FileName] = <a href="getrespmat.html" class="code" title="function [S, FileName] = getrespmat(varargin)">getrespmat</a>(<span class="string">'TUNE'</span>, [1 1;1 2], FamilyNameCell{i}, DeviceListCell{i}, <span class="string">'Struct'</span>, InputFlags{:}, varargin{:});
3130227         <span class="keyword">catch</span>
3140228             fprintf(<span class="string">'   Could not find a TUNE response matrix file, so using the model (%s).\n'</span>, FamilyNameCell{i});
3150229             TuneMatrix(1,i) = <a href="meastuneresp.html" class="code" title="function [Rmat, OutputFileName] = meastuneresp(varargin)">meastuneresp</a>(FamilyNameCell{i}, DeviceListCell{i}, <span class="string">'Model'</span>, <span class="string">'Struct'</span>, InputFlags{:}, varargin{:});
3160230             FileName = <span class="string">''</span>;
3170231         <span class="keyword">end</span>
3180232     <span class="keyword">end</span>
3190233 <span class="keyword">end</span>
3200234
3210235</pre></div>
322<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>
323</body>
324</html>
Note: See TracBrowser for help on using the repository browser.