source: MML/trunk/mml/plotbpmrespsym.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: 5.1 KB
Line 
1function plotbpmrespsym(R)
2%PLOTBPMRESPSYM - Looks for symmetry of the orbit response matrix
3%  plotbpmrespsym(R)
4%  plotbpmrespsym(FileName)
5%
6%  NOTES
7%  1. This function is only informative if the lattice is
8%     symmetric by sector.
9%  2. This function only works if the corrector and BPM
10%     placement is symmetric in each sector.
11%
12%  Written by Greg Portmann
13
14
15if nargin == 0
16    R = getbpmresp('Struct');
17end
18if isempty(R)
19    R = getbpmresp('','Struct');
20end
21if isempty(R)
22    return;
23end
24
25
26% Use physics units for scaling
27R = hw2physics(R);
28
29
30FontSize = 10;
31Buffer = .01;
32HeightBuffer = .08;
33
34
35Sx = R(1,1).Data;
36Sy = R(2,2).Data;
37
38NSectors = R(1,1).Monitor.DeviceList(end,1);
39NBPMxperSector = max(R(1,1).Monitor.DeviceList(:,2));
40NBPMyperSector = max(R(2,2).Monitor.DeviceList(:,2));
41
42NBPMx = size(Sx,1);
43NBPMy = size(Sy,1);
44
45NHCMperSector = max(R(1,1).Actuator.DeviceList(:,2));
46NVCMperSector = max(R(2,2).Actuator.DeviceList(:,2));
47
48%NHCMperSector = size(Sx,2) / NSectors;
49%NVCMperSector = size(Sy,2) / NSectors;
50
51Circumference = getfamilydata('Circumference');
52
53BPMxs = getspos(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);
54BPMxs = BPMxs(:);
55BPMys = getspos(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);
56BPMys = BPMys(:);
57
58BPMxDev = R(1,1).Monitor.DeviceList;
59BPMyDev = R(2,2).Monitor.DeviceList;
60% BPMxelem = dev2elem(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);
61% BPMyelem = dev2elem(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);
62
63% BPMxGain = getgain(R(1,1).Monitor.FamilyName, R(1,1).Monitor.DeviceList);
64% BPMyGain = getgain(R(2,2).Monitor.FamilyName, R(2,2).Monitor.DeviceList);
65
66HCMDev = R(1,1).Actuator.DeviceList;
67VCMDev = R(2,2).Actuator.DeviceList;
68% HCMelem = dev2elem('HCM', R(1,1).Actuator.DeviceList);
69% VCMelem = dev2elem('VCM', R(2,2).Actuator.DeviceList);
70
71% % Hardware units to mradian
72% %HCMGain = getgain('HCM', R(1,1).Actuator.DeviceList);
73% HCMGain = 1 ./ (hw2physics('HCM', 'Setpoint', R(1,1).ActuatorDelta, HCMDev) ./ R(1,1).ActuatorDelta) / 1000;
74%
75% %VCMGain = getgain('VCM', R(2,2).Actuator.DeviceList);
76% VCMGain = 1 ./ (hw2physics('VCM', 'Setpoint', R(2,2).ActuatorDelta, VCMDev) ./ R(2,2).ActuatorDelta) / 1000;
77
78XUnitsString = R(1,1).UnitsString;
79XUnitsString(findstr(XUnitsString,'(')) = [];
80XUnitsString(findstr(XUnitsString,')')) = [];
81YUnitsString = R(2,2).UnitsString;
82YUnitsString(findstr(YUnitsString,'(')) = [];
83YUnitsString(findstr(YUnitsString,')')) = [];
84
85
86L = getfamilydata('Circumference');
87
88
89
90%%%%%%%%%%%%%%
91% Horizontal %
92%%%%%%%%%%%%%%
93
94% % Scale response matrix by the BPM gains
95% for i = 1:size(Sx,2)
96%    Sx(:,i) = Sx(:,i) .* BPMxGain(:);
97% end
98%
99% % Scale response matrix by the HCM gains
100% for i = 1:size(Sx,1)
101%    Sx(i,:) = Sx(i,:) .* HCMGain(:)';
102%    %Sx(i,:) = Sx(i,:) ./ hw2physics('HCM', 'Setpoint', 1, HCMDev)'/1000;
103%    %Sx(i,:) = Sx(i,:) / (1000*amps2rad('HCM',1,i));
104% end
105
106
107figure;
108clf reset
109set(gcf,'units','normal','position',[.0+Buffer .27+Buffer .5-2*Buffer .72-2*Buffer-HeightBuffer]);
110for Mag = 1:NHCMperSector   
111    S = [];
112    P = [];
113    for i = 1:NSectors
114        j = findrowindex([i Mag], HCMDev);
115        if ~isempty(j)
116            k = min(find(BPMxDev(:,1)==i));
117            S = [S [Sx(k:end, j); Sx(1:k-1, j)]];
118            P = [P [BPMxs(k:end); BPMxs(1:k-1)+L]-BPMxs(k)+BPMxs(1)];
119        end
120    end
121   
122    subplot(NHCMperSector, 1, Mag);
123    if isempty(S)
124        plot(BPMxs, NaN*ones(size(BPMxs)));       
125    else
126        plot(P, S);
127    end
128    ylabel(sprintf('Mag #%d', Mag), 'FontSize', FontSize);
129end
130
131subplot(NHCMperSector,1,1);
132title(sprintf('Horizontal Corrector Magnet Response (%s)', XUnitsString), 'FontSize', FontSize);
133
134subplot(NHCMperSector,1,NHCMperSector);
135xlabel('BPM Position [meters]', 'FontSize', FontSize);
136if isfield(R(1,1), 'TimeStamp')
137    addlabel(1,0,sprintf('%s', datestr(R(1,1).TimeStamp)));
138end
139orient tall
140
141
142%%%%%%%%%%%%
143% Vertical %
144%%%%%%%%%%%%
145
146% % Scale response matrix by the BPM gains
147% for i = 1:size(Sy,2)
148%    Sy(:,i) = Sy(:,i) .* BPMyGain(:);
149% end
150%
151% % Scale response matrix by the VCM gains
152% for i = 1:size(Sy,1)
153%    Sy(i,:) = Sy(i,:) .* VCMGain(:)';
154%    %Sy(i,:) = Sy(i,:) / (1000*amps2rad('VCM',1,i));
155% end
156
157figure(gcf+1);
158clf reset
159set(gcf,'units','normal','position',[.5+Buffer .27+Buffer .5-2*Buffer .72-2*Buffer-HeightBuffer]);
160
161for Mag = 1:NVCMperSector     
162    S = [];
163    P = [];
164    for i = 1:NSectors
165        j = findrowindex([i Mag], VCMDev);
166        if ~isempty(j)
167            k = min(find(BPMyDev(:,1)==i));
168            S = [S [Sy(k:end, j); Sy(1:k-1, j)]];
169            P = [P [BPMys(k:end); BPMys(1:k-1)+L]-BPMys(k)+BPMys(1)];
170        end
171    end
172 
173    subplot(NVCMperSector, 1, Mag);
174    if isempty(S)
175        plot(BPMys, NaN*ones(size(BPMys)));       
176    else
177        plot(P, S);
178    end
179    ylabel(sprintf('Mag #%d', Mag), 'FontSize', FontSize);
180end
181
182subplot(NVCMperSector,1,1);
183title(sprintf('Vertical Corrector Magnet Response (%s)', XUnitsString), 'FontSize', FontSize);
184
185subplot(NVCMperSector,1,NVCMperSector);
186xlabel('BPM Position [meters]', 'FontSize', FontSize);
187if isfield(R(1,1), 'TimeStamp')
188    addlabel(1,0,sprintf('%s', datestr(R(1,1).TimeStamp)));
189end
190orient tall
191
192
Note: See TracBrowser for help on using the repository browser.