source: MML/trunk/mml/mm2amp.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 2.2 KB
Line 
1function Amps = mm2amp(CMfamily, mm, CMDevList, varargin)
2%MM2AMPS - Returns the change in corrector need for a maximum orbit change
3%  Amps = mm2amp(CMFamily, mm, CMDevList, varargin)
4%
5%  INPUTS
6%  1. CMFamily - Corrector magnet family name (ex. 'HCM', 'VCM')
7%  2. mm - Maximum change in orbit produces by a change in
8%           corrector strength of Amps.
9%  3. CMDevList - Corrector magnet device list
10%  4. varargin - Inputs sent to getrespmat function call
11%
12%  OUTPUTS
13%  1. Amps - Change in corrector magnet strength
14%
15%  NOTES
16%  1. mm and Amps happen to be the hardware units for the ALS.  This function
17%     actually works in whatever the hardware units are for the middlelayer.
18%
19%  ALGORITHM
20%  Based on the response matrix, mm = R * Amps, the maximum change in the
21%  orbit due to a corrector change can be found.
22%
23%  See also amp2mm
24%
25%  Written by Greg Portmann
26
27BPMxFamily = gethbpmfamily;
28BPMyFamily = getvbpmfamily;
29
30% Input checking
31if nargin < 2
32    error('Must have at least two inputs (Family & Amps)');
33end
34if nargin < 3
35    CMDevList = [];
36end
37if isempty(CMDevList)
38    CMDevList = family2dev(CMfamily);
39end
40if (size(CMDevList,1) == 1)
41    CMDevList = elem2dev(CMfamily, CMDevList);
42end
43
44
45% Response matrix
46if ~isempty(findstr(upper(CMfamily),'H')) | ~isempty(findstr(upper(CMfamily),'X'))
47    Smat = getrespmat(BPMxFamily, [], CMfamily, CMDevList, varargin{:});
48elseif ~isempty(findstr(upper(CMfamily),'V')) | ~isempty(findstr(upper(CMfamily),'Y')) | ...
49       ~isempty(findstr(upper(CMfamily),'Z'))
50    Smat = getrespmat(BPMyFamily, [], CMfamily, CMDevList, varargin{:});
51else
52    error('Not sure if corrector family is horizontal or vertical.');
53end
54
55
56if isempty(mm)
57    error('mm is empty');
58elseif all(size(mm) == [1 1])
59    mm = mm * ones(size(CMDevList,1),1);
60elseif size(mm,1) == size(CMDevList,1)
61    % input OK
62else
63    error('Rows of mm must be equal to the rows of CMDevList or a scalar!');
64end
65
66
67% Check for missing correctors
68[iFound, iNotFound] = findrowindex(CMDevList, family2dev(CMfamily,0));
69if ~isempty(iNotFound)
70    error('   Not all correctors found.\n');
71end
72
73
74% Main
75for j = 1:size(mm,2)
76    for i = 1:size(CMDevList,1)
77        Amps(i,j) = mm(i,j) / max(Smat(:,i));
78    end
79end
Note: See TracBrowser for help on using the repository browser.