1 | function setskewcorrection(varargin) |
---|
2 | % setskewcorrection - coupling correction with CTCO and dispersion measurement method |
---|
3 | % setskewcorrection('Online') |
---|
4 | |
---|
5 | % INPUT |
---|
6 | % Optional |
---|
7 | % 'Archive', 'Display' |
---|
8 | % Optional override of the mode: |
---|
9 | % 'Online' - Set/Get data online |
---|
10 | % 'Model' - Get the model chromaticity directly from AT (uses modelchro, DeltaRF is ignored) |
---|
11 | % 'Simulator' - Set/Get data on the simulated accelerator using AT (ie, same commands as 'Online') |
---|
12 | % |
---|
13 | % OUPUTS |
---|
14 | % |
---|
15 | % |
---|
16 | % ALGORITHM |
---|
17 | |
---|
18 | % |
---|
19 | % See Also |
---|
20 | |
---|
21 | % |
---|
22 | % Written by M-A. Tordeux |
---|
23 | |
---|
24 | DisplayFlag = 1; |
---|
25 | ArchiveFlag = 1; |
---|
26 | FileName = ''; |
---|
27 | ModeFlag = 'Model'; % model, online, manual, 'Model' for default mode |
---|
28 | waittime = 0.5; %seconds taken into account for simulator and Online |
---|
29 | OutputFlag = 1; |
---|
30 | |
---|
31 | MeasurementFlag = 0 ; % s |
---|
32 | CorrectionFlag = 1 ; % Si à zéro pas de correction |
---|
33 | PostMeasurementFlag = 1 % Mesure aprÚs correction du couplage |
---|
34 | Params = [1e3 32 100] ; % ParamÚtres par défaut de la correction |
---|
35 | % Params(1) : poids Dz |
---|
36 | % Params(2) : nb de valeurs propres de lamatrice efficacite QT |
---|
37 | % Params(3) : pourcentage de correction appliqué |
---|
38 | |
---|
39 | for i = length(varargin):-1:1 |
---|
40 | if isstruct(varargin{i}) |
---|
41 | % Ignore structures |
---|
42 | handles.caller = varargin{i}.figure1; |
---|
43 | M = getappdata(handles.caller,'M'); % paramÚtres mesure |
---|
44 | S = getappdata(handles.caller,'S'); % paramÚtres correction |
---|
45 | Diaphonie = getappdata(handles.caller,'Diaphonie'); % |
---|
46 | DeltaI_HCOR = M.Param1 ; |
---|
47 | waittime = M.Param2 ; |
---|
48 | PoidsDz = S.Param1 ; |
---|
49 | nbvp = S.Param2 ; |
---|
50 | pourcentage = S.Param3 ; |
---|
51 | elseif iscell(varargin{i}) |
---|
52 | % Ignore cells |
---|
53 | % store handle from caller |
---|
54 | handles.caller = varargin{i}.figure1; |
---|
55 | elseif strcmpi(varargin{i},'Display') |
---|
56 | DisplayFlag = 1; |
---|
57 | varargin(i) = []; |
---|
58 | elseif strcmpi(varargin{i},'NoDisplay') |
---|
59 | DisplayFlag = O; |
---|
60 | varargin(i) = []; |
---|
61 | elseif strcmpi(varargin{i},'NoArchive') |
---|
62 | ArchiveFlag = 0; |
---|
63 | varargin(i) = []; |
---|
64 | elseif strcmpi(varargin{i},'Archive') |
---|
65 | ArchiveFlag = 1; |
---|
66 | varargin(i) = []; |
---|
67 | elseif strcmpi(varargin{i},'Simulator') || strcmpi(varargin{i},'Model') ... |
---|
68 | || strcmpi(varargin{i},'Online') || strcmpi(varargin{i},'Manual') |
---|
69 | ModeFlag = varargin{i}; |
---|
70 | varargin(i) = []; |
---|
71 | elseif strcmpi(varargin{i},'Measurement') |
---|
72 | MeasurementFlag = 1; |
---|
73 | varargin(i) = []; |
---|
74 | elseif strcmpi(varargin{i},'NoMeasurement') |
---|
75 | MeasurementFlag = 0; |
---|
76 | varargin(i) = []; |
---|
77 | elseif strcmpi(varargin{i},'Correction') |
---|
78 | CorrectionFlag = 1; |
---|
79 | varargin(i) = []; |
---|
80 | elseif strcmpi(varargin{i},'NoCorrection') |
---|
81 | CorrectionFlag = 0; |
---|
82 | varargin(i) = []; |
---|
83 | % elseif isnumeric(varargin{i}) |
---|
84 | % Params = varargin{i}; |
---|
85 | % varargin(i) = []; |
---|
86 | end |
---|
87 | end |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | if strcmpi(ModeFlag,'Model') |
---|
92 | waittime = -1; |
---|
93 | OutputFlag = 0; |
---|
94 | elseif strcmpi(ModeFlag,'Online') |
---|
95 | %waittime = 2.8; % 5 secondes car pb alim correcteurs % 2.8 s 24 octobre 08 |
---|
96 | end |
---|
97 | |
---|
98 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% en attente de mettre dans un fichier |
---|
99 | CT_DIAG = 0.01* [ -0.7000 -3.1700 -2.6800 -3.0200 -0.1500 -3.2000 -4.0300 2.7100 -3.3500 -0.6200 -2.4000 1.0000 -2.4000 -1.1600 -2.4100 0.8100 -1.4600 -2.8500 -4.2300... |
---|
100 | 0.9200 -0.9600 -3.4100 0.3100 1.4600 -4.9700 -3.1100 -1.5700 -3.3600 -5.6000 -4.7800 3.2300 -4.9300 -4.2700 -3.5100 -6.6700 -2.3700 -3.2000 -0.3800 -3.5000... |
---|
101 | -3.8600 -4.0300 0.0800 -2.9000 -5.0300 -3.0300 1.5300 -6.5200 -4.3900 -1.7500 1.0700 -5.1400 -3.1300 -4.5200 -1.4500 -1.9800 3.4100 0.9100 -2.3100 -0.0800... |
---|
102 | -0.5400 1.2200 -3.3600 -2.9100 -3.5900 -3.6500 -4.5700 -2.5200 2.2800 -2.4200 -1.1400 -4.4900 2.2900 -5.9800 -4.2700 -3.1300 -0.1500 -4.5700 -4.8700 -2.9700... |
---|
103 | 1.1400 0.9100 -2.2000 -0.3800 -2.9600 -1.2900 -0.3800 -0.2300 -0.3800 -0.4900 -3.5700 -0.3500 -1.4700 -1.4800 -1.6800 -3.5300 -0.6300 -4.1500 1.5400 -2.3200... |
---|
104 | -1.7300 -2.0200 3.1500 -0.6100 -3.9200 -3.8300 1.9500 -1.8900 2.5400 -2.3900 1.0500 -0.3500 -1.6100 -3.3000 1.7100 0.6200 0.1500 -2.2500 -0.080 -0.080 -3.1900]; |
---|
105 | % crosstalk mesuré par groupe diag avril 2007 |
---|
106 | % attention premier BPM mml = [1 2] d'ou la permutation du premier crosstalk (-3.19%) |
---|
107 | |
---|
108 | CT_LOCO = [ ... |
---|
109 | -0.0088 -0.0268 -0.0133 -0.0200 -0.0190 -0.0218 -0.0527 -0.0073 -0.0127 -0.0153 -0.0272 0.0026 -0.0284 ... |
---|
110 | -0.0157 -0.0215 0.0055 -0.0463 -0.0139 -0.0532 -0.0046 -0.0466 -0.0357 -0.0174 0.0165 -0.0249 -0.0296 ... |
---|
111 | -0.0364 -0.0327 -0.0387 -0.0445 0.0209 -0.0416 -0.0342 -0.0286 -0.0317 -0.0417 -0.0284 -0.0219 -0.0455 ... |
---|
112 | -0.0267 -0.0280 -0.0051 -0.0402 -0.0641 -0.0442 -0.0018 -0.0523 -0.0252 -0.0314 0.0074 -0.0301 -0.0320 ... |
---|
113 | -0.0298 0.0068 -0.0126 -0.0137 -0.0180 -0.0174 -0.0157 0.0011 -0.0015 -0.0292 -0.0256 -0.0393 -0.0419 ... |
---|
114 | -0.0405 -0.0453 0.0055 -0.0254 -0.0120 -0.0349 0.0092 -0.0165 -0.0133 -0.0368 -0.0108 -0.0199 -0.0276 ... |
---|
115 | -0.0259 0.0076 -0.0147 -0.0408 -0.0077 -0.0158 -0.0049 -0.0190 -0.0135 -0.0082 -0.0212 -0.0499 0.0004 ... |
---|
116 | -0.0194 -0.0123 -0.0155 -0.0115 -0.0200 -0.0487 0.0081 -0.0325 -0.0099 -0.0343 0.0147 -0.0063 -0.0149 ... |
---|
117 | -0.0323 0.0099 -0.0183 -0.0058 -0.0205 0.0131 -0.0121 -0.0042 -0.0342 0.0116 -0.0189 -0.0176 -0.0033 ... |
---|
118 | -0.0186 -0.0287 -0.0273... |
---|
119 | ]; % !!!!! fausses valeurs !! |
---|
120 | CT_LOCO_bis_H = [ ... |
---|
121 | -0.0132 -0.0003 -0.0043 -0.0171 -0.0233 0.0112 -0.0297 -0.0180 0.0071 -0.0046 ... |
---|
122 | -0.0217 -0.0112 -0.0054 0.0040 -0.0264 -0.0127 -0.0262 -0.0096 -0.0279 -0.0195 ... |
---|
123 | -0.0338 -0.0141 -0.0124 -0.0080 -0.0157 -0.0093 -0.0132 0.0022 -0.0168 -0.0246 ... |
---|
124 | -0.0029 -0.0151 -0.0166 -0.0304 -0.0181 -0.0067 -0.0060 -0.0136 -0.0156 -0.0233 ... |
---|
125 | -0.0168 -0.0102 -0.0234 -0.0313 -0.0225 -0.0107 -0.0158 -0.0205 -0.0201 -0.0049 ... |
---|
126 | -0.0150 -0.0086 -0.0151 -0.0014 0.0028 0.0041 -0.0164 -0.0002 -0.0021 -0.0018 ... |
---|
127 | -0.0060 -0.0176 -0.0171 -0.0244 -0.0175 -0.0093 -0.0234 -0.0114 -0.0024 -0.0041 ... |
---|
128 | -0.0224 0.0073 -0.0086 -0.0041 -0.0197 -0.0115 0.0148 -0.0245 -0.0254 0.0009 ... |
---|
129 | 0.0021 -0.0159 -0.0096 -0.0171 -0.0195 -0.0284 -0.0160 -0.0085 -0.0152 -0.0242 ... |
---|
130 | -0.0115 -0.0138 -0.0090 -0.0212 -0.0091 -0.0147 -0.0310 -0.0124 -0.0122 -0.0028 ... |
---|
131 | -0.0250 -0.0100 -0.0186 -0.0078 -0.0109 -0.0068 0.0045 -0.0062 -0.0239 -0.0009 ... |
---|
132 | -0.0036 -0.0083 -0.0196 -0.0074 -0.0207 -0.0096 0.0086 0.0095 -0.0165 -0.0090 ... |
---|
133 | ]; % 14 décembre 2009 |
---|
134 | CT_LOCO_bis_V = [... |
---|
135 | -0.0015 -0.0240 -0.0121 -0.0192 -0.0196 -0.0173 -0.0528 -0.0049 -0.0123 -0.0176 ... |
---|
136 | -0.0323 0.0035 -0.0300 -0.0137 -0.0177 0.0040 -0.0423 -0.0166 -0.0563 -0.0058 ... |
---|
137 | -0.0485 -0.0287 -0.0082 0.0141 -0.0255 -0.0333 -0.0386 -0.0217 -0.0382 -0.0430 ... |
---|
138 | 0.0161 -0.0375 -0.0347 -0.0291 -0.0293 -0.0398 -0.0239 -0.0178 -0.0371 -0.0317 ... |
---|
139 | -0.0309 -0.0072 -0.0466 -0.0580 -0.0340 -0.0038 -0.0454 -0.0289 -0.0248 0.0088 ... |
---|
140 | -0.0359 -0.0300 -0.0252 0.0101 -0.0089 -0.0151 -0.0220 -0.0217 -0.0173 0.0005 ... |
---|
141 | -0.0004 -0.0215 -0.0283 -0.0419 -0.0468 -0.0388 -0.0440 0.0032 -0.0216 -0.0130 ... |
---|
142 | -0.0368 0.0121 -0.0191 -0.0125 -0.0332 -0.0076 -0.0178 -0.0315 -0.0302 0.0115 ... |
---|
143 | -0.0163 -0.0332 -0.0033 -0.0170 -0.0053 -0.0230 -0.0130 -0.0104 -0.0203 -0.0505 ... |
---|
144 | -0.0011 -0.0198 -0.0124 -0.0142 -0.0120 -0.0195 -0.0467 0.0060 -0.0325 -0.0165 ... |
---|
145 | -0.0412 0.0144 -0.0213 -0.0182 -0.0314 0.0084 -0.0164 -0.0097 -0.0208 0.0189 ... |
---|
146 | -0.0102 -0.0004 -0.0286 0.0142 -0.0236 -0.0203 -0.0064 -0.0192 -0.0323 -0.0344 ... |
---|
147 | ]; |
---|
148 | |
---|
149 | if isequal(Diaphonie,'LOCO') |
---|
150 | %CT = CT_LOCO; |
---|
151 | disp('Diaphonie calculée par LOCO') |
---|
152 | else |
---|
153 | %CT = CT_DIAG; |
---|
154 | disp('Diaphonie mesurée en labo') |
---|
155 | end |
---|
156 | |
---|
157 | %% Résultats fit LOCO redémarrage run 2 2009 |
---|
158 | if strcmpi(ModeFlag,'Online') |
---|
159 | %load('/home/matlabML/measdata/SOLEIL/StorageRingdata/LOCO/2009-03-06a/160quad.mat') % LOCO/2009-03-06a |
---|
160 | load('/home/matlabML/measdata/SOLEIL/StorageRingdata/LOCO/2009-11-22/160quad.mat') |
---|
161 | iter = 3; |
---|
162 | HBPMgain = BPMData(iter).HBPMGain; |
---|
163 | VBPMgain = BPMData(iter).VBPMGain; |
---|
164 | HBPMcoupling = BPMData(iter).HBPMCoupling; |
---|
165 | VBPMcoupling = BPMData(iter).VBPMCoupling; |
---|
166 | HCMkick = CMData(iter).HCMKicks; |
---|
167 | meanHCMkick = mean(HCMkick); |
---|
168 | |
---|
169 | C = zeros(120,2,2); |
---|
170 | for ik =1:120, |
---|
171 | C(ik,:,:)= [ HBPMgain(ik) HBPMcoupling(ik) |
---|
172 | VBPMcoupling(ik) VBPMgain(ik) ]; |
---|
173 | Cinv(ik,:,:) = inv(squeeze(C(ik,:,:))); |
---|
174 | end |
---|
175 | end |
---|
176 | %% |
---|
177 | |
---|
178 | if MeasurementFlag |
---|
179 | %Indexskewquad = family2atindex('QT');% Index of skew quadrupoles |
---|
180 | %Meffskewquad_CTO = zeros(120,120,32); % premiÚre matrice : efficacité vis à vis des orbites fermées croisées |
---|
181 | %Etalonnage = zeros(2,120,32); |
---|
182 | DeviceNumber_HCOR = 0; |
---|
183 | |
---|
184 | % graphe |
---|
185 | lim = 0.10* DeltaI_HCOR / 0.6; % en mm, valeur max estimée des CTCO pour graphe |
---|
186 | |
---|
187 | |
---|
188 | if ArchiveFlag % enregistrement de la matrice reponse dispersion |
---|
189 | if isempty(FileName) |
---|
190 | FileName = appendtimestamp('SkewMeasurement'); |
---|
191 | DirectoryName = getfamilydata('Directory', 'SkewResponse'); |
---|
192 | if isempty(DirectoryName) |
---|
193 | % DirectoryName = [getfamilydata('Directory','DataRoot'), 'Response', filesep, 'BPM', filesep]; |
---|
194 | else |
---|
195 | % Make sure default directory exists |
---|
196 | DirStart = pwd; |
---|
197 | [DirectoryName, ErrorFlag] = gotodirectory(DirectoryName); |
---|
198 | cd(DirStart); |
---|
199 | end |
---|
200 | [FileName, DirectoryName] = uiputfile('*.mat', 'Select a Skew File ("Save" starts measurement)', [DirectoryName FileName]); |
---|
201 | if FileName == 0 |
---|
202 | ArchiveFlag = 0; |
---|
203 | disp(' Skew efficiency measurement canceled.'); |
---|
204 | return |
---|
205 | end |
---|
206 | FileName = [DirectoryName, FileName]; |
---|
207 | elseif FileName == -1 |
---|
208 | FileName = appendtimestamp(getfamilydata('Default', 'SkewArchiveFile')); |
---|
209 | DirectoryName = getfamilydata('Directory', 'SkewResponse'); |
---|
210 | FileName = [DirectoryName, FileName]; |
---|
211 | end |
---|
212 | end |
---|
213 | |
---|
214 | % Starting time |
---|
215 | t0 = clock; |
---|
216 | |
---|
217 | %for k1 = 1:length(QuadFam), |
---|
218 | |
---|
219 | if ~isfamily('QT') |
---|
220 | error('%s is not a valid Family \n', 'QT'); |
---|
221 | return; |
---|
222 | end |
---|
223 | |
---|
224 | DeviceList_QT = family2dev('QT'); |
---|
225 | DeviceList_HCOR = family2dev('HCOR'); |
---|
226 | |
---|
227 | if strcmpi(ModeFlag,'Online') |
---|
228 | %%%% |
---|
229 | temp=tango_read_attribute2('ANS-C02/DG/PHC-EMIT','EmittanceH'); pinhole.emitH= temp.value; |
---|
230 | temp=tango_read_attribute2('ANS-C02/DG/PHC-EMIT','EmittanceV'); pinhole.emitV= temp.value; |
---|
231 | temp=tango_read_attribute2('ANS-C02/DG/PHC-EMIT','Coupling'); pinhole.coupling= temp.value; |
---|
232 | temp=tango_read_attribute2('ANS-C02/DG/PHC-IMAGEANALYZER','XProjFitSigma'); pinhole.XProjFitSigma=temp.value; |
---|
233 | temp=tango_read_attribute2('ANS-C02/DG/PHC-IMAGEANALYZER','YProjFitSigma'); pinhole.YProjFitSigma= temp.value; |
---|
234 | temp=tango_read_attribute2('ANS-C02/DG/PHC-IMAGEANALYZER','GaussianFitCovarianceXY'); pinhole.GaussianFitCovarianceXY=temp.value; |
---|
235 | temp=tango_read_attribute2('ANS-C03/DG/DCCT','current'); pinhole.cur=temp.value; |
---|
236 | %%%%%% |
---|
237 | end |
---|
238 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
239 | % dispersion measurement |
---|
240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
241 | if strcmpi(ModeFlag,'Online') |
---|
242 | FileName_DISP = appendtimestamp('Dispersion_V') |
---|
243 | FileName_DISP = ['/home/matlabML/machine/SOLEIL/StorageRing/fonction_test/couplage/' FileName_DISP]; |
---|
244 | measdisp('Archive',FileName_DISP,'NoDisplay'); % on sauvegarde les mesures brutes cette fois |
---|
245 | Dx_Meas = getdisp('BPMx',FileName_DISP,'Physics'); |
---|
246 | Dy_Meas = getdisp('BPMz',FileName_DISP,'Physics'); |
---|
247 | |
---|
248 | figure(304);plot(Dy_Meas,'bo-'),title('Mesures brutes') |
---|
249 | Dy_plot = Dx_Meas.*Cinv(:,2,1) + Dy_Meas.*Cinv(:,2,2); |
---|
250 | figure(305);plot(Dy_plot,'ro-'),title('Mesures corrigées') |
---|
251 | sleep(waittime*2) |
---|
252 | else |
---|
253 | [Dx_Meas Dy_Meas] = modeldisp('BPMx'); |
---|
254 | figure(689);plot(Dy_Meas,'o-');ylabel('Dispersion V (m)') |
---|
255 | figure(690);plot(Dx_Meas,'o-');ylabel('Dispersion H (m)') |
---|
256 | end |
---|
257 | % if strcmpi(ModeFlag,'Online') |
---|
258 | % Dy_Meas = Dy_Meas - Dx_Meas.*CT'; |
---|
259 | % end |
---|
260 | |
---|
261 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
262 | % CrossTalk closed orbit measurement |
---|
263 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
264 | |
---|
265 | |
---|
266 | for k2 = 1:length(DeviceList_HCOR), |
---|
267 | |
---|
268 | Xof0 = getx(ModeFlag); % Horizontal reference orbit |
---|
269 | Zof0 = getz(ModeFlag); % Vertical reference orbit |
---|
270 | if strcmpi(ModeFlag,'Online') |
---|
271 | Zof0 = Zof0 - Xof0.*CT_DIAG'; |
---|
272 | end |
---|
273 | |
---|
274 | DeviceNumber_HCOR = DeviceNumber_HCOR + 1; |
---|
275 | Ic_HCOR = getam('HCOR', DeviceList_HCOR(k2,:), ModeFlag); |
---|
276 | if OutputFlag |
---|
277 | fprintf('Measuring %s [%d %d] actual current %f A : ... \n', ... |
---|
278 | 'HCOR', DeviceList_HCOR(k2,:),Ic_HCOR) % pour suivi |
---|
279 | end |
---|
280 | |
---|
281 | %DeltaI_HCOR = 0.6*1.; % 0.6 Amp : choix d'une orbite inférieure à 1 mm |
---|
282 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
283 | stepsp('HCOR', DeltaI_HCOR, DeviceList_HCOR(k2,:), ModeFlag); % Step value |
---|
284 | sleep(waittime) % wait for HCOR reaching new setpoint value |
---|
285 | |
---|
286 | Xof1 = getx(ModeFlag) ; orbiteX1(:,DeviceNumber_HCOR) = Xof1; |
---|
287 | Zof1 = getz(ModeFlag) ; orbiteZ1(:,DeviceNumber_HCOR) = Zof1; |
---|
288 | if strcmpi(ModeFlag,'Online') |
---|
289 | Zof1 = Zof1 - Xof1.*CT_DIAG'; |
---|
290 | end |
---|
291 | DevMaxX = max(Xof0-Xof1); |
---|
292 | fprintf('- Déviation maximale induite : %4.3f mm \n',DevMaxX) % pour tester la validité de DeltaI |
---|
293 | |
---|
294 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
295 | stepsp('HCOR', -2*DeltaI_HCOR, DeviceList_HCOR(k2,:), ModeFlag); % Step value |
---|
296 | sleep(waittime) % wait for HCOR reaching new setpoint value |
---|
297 | |
---|
298 | Xof2 = getx(ModeFlag) ; orbiteX2(:,DeviceNumber_HCOR) = Xof2; |
---|
299 | Zof2 = getz(ModeFlag) ; orbiteZ2(:,DeviceNumber_HCOR) = Zof2; |
---|
300 | if strcmpi(ModeFlag,'Online') |
---|
301 | Zof2 = Zof2 - Xof2.*CT_DIAG'; |
---|
302 | end |
---|
303 | |
---|
304 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
305 | stepsp('HCOR', DeltaI_HCOR, DeviceList_HCOR(k2,:), ModeFlag); % Initial value |
---|
306 | sleep(waittime) % wait for HCOR reaching new setpoint value |
---|
307 | |
---|
308 | |
---|
309 | %% computation part |
---|
310 | |
---|
311 | DeltaZof = Zof2-Zof1 ; % HCOR induced Orbit shift |
---|
312 | figure(13) ; plot(getspos('BPMz'),DeltaZof) ; grid on ; |
---|
313 | title('orbite verticale induite par le kick horizontal'); |
---|
314 | ylabel('différence d''orbite V en mm'); |
---|
315 | xlabel('abscisse machine (m)') |
---|
316 | ylim([-0.05 0.05]) |
---|
317 | DevMaxZ = max(DeltaZof); |
---|
318 | |
---|
319 | CTCO_Meas(:,DeviceNumber_HCOR) = DeltaZof/(-2*DeltaI_HCOR) ; % mm/A |
---|
320 | CTCO_Etalonnage(1,DeviceNumber_HCOR) = DevMaxX; |
---|
321 | CTCO_Etalonnage(2,DeviceNumber_HCOR) = DevMaxZ ; % Amplitude test |
---|
322 | |
---|
323 | end |
---|
324 | |
---|
325 | |
---|
326 | |
---|
327 | % if DisplayFlag |
---|
328 | % |
---|
329 | % end |
---|
330 | |
---|
331 | if ArchiveFlag |
---|
332 | directory_actuelle = pwd; |
---|
333 | cd(DirectoryName) |
---|
334 | if strcmpi(ModeFlag,'Online') |
---|
335 | save(FileName,'CTCO_Meas','CTCO_Etalonnage','Dx_Meas','Dy_Meas',... |
---|
336 | 'orbiteX1','orbiteX2','orbiteZ1','orbiteZ2','DeltaI_HCOR','pinhole','-mat'); |
---|
337 | else |
---|
338 | save(FileName,'CTCO_Meas','CTCO_Etalonnage','Dx_Meas','Dy_Meas',... |
---|
339 | 'orbiteX1','orbiteX2','orbiteZ1','orbiteZ2','DeltaI_HCOR','-mat'); |
---|
340 | end |
---|
341 | %save(FileName,'CTCO_Meas','CTCO_Etalonnage','-mat'); % cas ou DCCT pb communication |
---|
342 | cd(directory_actuelle); |
---|
343 | end |
---|
344 | |
---|
345 | disp('Registration ended') |
---|
346 | |
---|
347 | end |
---|
348 | |
---|
349 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
350 | % Coupling correction |
---|
351 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
352 | |
---|
353 | if CorrectionFlag |
---|
354 | if ~MeasurementFlag |
---|
355 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
356 | % Measurement loading |
---|
357 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
358 | %%%%%%%%%%%%%%%%%%%%%%%%% model |
---|
359 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewRespMat_2007-06-05_19-33-04.mat') |
---|
360 | % S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-06-07_15-22-51.mat') % défauts = QT=[1 -1 1 -1,etc.. |
---|
361 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-06-08_11-27-15_tirage_defauts.mat') % tirage défauts |
---|
362 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-06-18_15-40-27_graine_n9.mat') |
---|
363 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-10_15-32-57_graine_DIPOLE+-5mrad.mat') |
---|
364 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-11_10-29-00_graine_dipole+-5mrad.mat') |
---|
365 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-11_10-54-56_graine_dipoles_++5mrad.mat') |
---|
366 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-11_11-21-19_graine_n18.mat') |
---|
367 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-13_14-32-22_graine_+1-1AcorrV.mat') |
---|
368 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-13_17-45-18_graine18.mat') |
---|
369 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-16_18-34-14_orbite_non_moyennee.mat'); |
---|
370 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-16_20-42-47_orbite_non_moyennee_iter2.mat'); |
---|
371 | %S = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-07-18_17-23-38_graine_n9bis.mat') |
---|
372 | %S = load('-mat','/home/matlabML/measdata/SOLEIL/Ringdata/Response/Skew/SkewMeasurement_2007-09-02_14-28-06_HU640_-600A_nux-2600_avant_corr.mat') |
---|
373 | %S = load('-mat','/home/matlabML/measdata/SOLEIL/Ringdata/Response/Skew/SkewMeasurement_2007-09-10_11-50-11_HU640_p600A_nux_-26.mat') |
---|
374 | |
---|
375 | DirectoryName = getfamilydata('Directory', 'SkewResponse'); |
---|
376 | if isempty(DirectoryName) |
---|
377 | % DirectoryName = [getfamilydata('Directory','DataRoot'), 'Response', filesep, 'BPM', filesep]; |
---|
378 | else |
---|
379 | % Make sure default directory exists |
---|
380 | DirStart = pwd; |
---|
381 | [DirectoryName, ErrorFlag] = gotodirectory(DirectoryName); |
---|
382 | cd(DirStart); |
---|
383 | end |
---|
384 | [FileName, DirectoryName] = uigetfile('*.mat', 'Select a Skew File ("Save" starts measurement)', [DirectoryName FileName]); |
---|
385 | if FileName == 0 |
---|
386 | ArchiveFlag = 0; |
---|
387 | disp(' Skew efficiency measurement canceled.'); |
---|
388 | return |
---|
389 | end |
---|
390 | FileName = [DirectoryName, FileName]; |
---|
391 | |
---|
392 | S = load(FileName); |
---|
393 | % Dy_Meas = S.Dy_Meas; |
---|
394 | % CTCO_Meas = S.CTCO_Meas; |
---|
395 | |
---|
396 | if strcmpi(ModeFlag,'Model') |
---|
397 | Dy_Meas = S.Dy_Meas; |
---|
398 | DeviceList_HCOR = family2dev('HCOR'); |
---|
399 | CTCO_Meas = S.CTCO_Meas; |
---|
400 | disp('?') |
---|
401 | |
---|
402 | else |
---|
403 | |
---|
404 | if strcmp(Diaphonie,'DIAG') % Diaphonie mesurée en labo |
---|
405 | if isfield(S,'DeltaI_HCOR') % alors on a enregistré les mesures brutes |
---|
406 | Dy_Meas = S.Dy_Meas - S.Dx_Meas.*CT_DIAG'; |
---|
407 | else % anciennes mesures : on avait corrigé les mesures brutes avant de les enregistrer |
---|
408 | Dy_Meas = S.Dy_Meas; |
---|
409 | end |
---|
410 | |
---|
411 | CTCO_Meas = S.CTCO_Meas; |
---|
412 | else % Diaphonie calculée par LOCO |
---|
413 | |
---|
414 | DeviceList_HCOR = family2dev('HCOR'); |
---|
415 | if isfield(S,'orbiteX1') |
---|
416 | |
---|
417 | for k = 1:length(DeviceList_HCOR) |
---|
418 | %Zof1(:,k) = S.orbiteZ1(:,k) - S.orbiteX1(:,k).*CT'; |
---|
419 | Zof1(:,k) = S.orbiteX1(:,k).*Cinv(:,2,1) +S.orbiteZ1(:,k).*Cinv(:,2,2); |
---|
420 | end |
---|
421 | |
---|
422 | |
---|
423 | for k = 1:length(DeviceList_HCOR) |
---|
424 | %Zof2(:,k) = S.orbiteZ2(:,k) - S.orbiteX2(:,k).*CT'; |
---|
425 | Zof2(:,k) = S.orbiteX2(:,k).*Cinv(:,2,1) +S.orbiteZ2(:,k).*Cinv(:,2,2); |
---|
426 | |
---|
427 | end |
---|
428 | |
---|
429 | DeltaZof = Zof2-Zof1 ; |
---|
430 | |
---|
431 | if isfield(S,'DeltaI_HCOR') |
---|
432 | CTCO_Meas = DeltaZof/(-2*S.DeltaI_HCOR) ; |
---|
433 | else |
---|
434 | DeltaI_HCOR = 0.2 ; % A VERIFIER !!!!! |
---|
435 | CTCO_Meas = DeltaZof/(-2*DeltaI_HCOR) ; |
---|
436 | end |
---|
437 | % s.CTCO_Meas./DeltaZof % verification |
---|
438 | |
---|
439 | if isfield(S,'DeltaI_HCOR') |
---|
440 | Dy_Meas = S.Dx_Meas.*Cinv(:,2,1) + S.Dy_Meas.*Cinv(:,2,2); % Dy mesurᅵ est brut puisqu'on a enregistrᅵ DeltaI_HCOR |
---|
441 | figure(302); plot(Dy_Meas,'ro-');title(' CHECK !! reconstitution de la dispersion verticale') |
---|
442 | else |
---|
443 | Dy_Measbrut = S.Dy_Meas + S.Dx_Meas.*CT_DIAG'; % retour au Dz originel car oubli dans script enregistrement |
---|
444 | %%Dy_Meas = S.Dy_Measbrut - S.Dx_Meas.*CT'; % |
---|
445 | Dy_Meas = S.Dx_Meas.*Cinv(:,2,1) + Dy_Measbrut.*Cinv(:,2,2); |
---|
446 | end |
---|
447 | else |
---|
448 | disp('l''enregistrement ne contiens pas les valeurs orbiteX1, etc..') |
---|
449 | return |
---|
450 | end |
---|
451 | |
---|
452 | end |
---|
453 | end |
---|
454 | %%%%%%%%%%%%%%%%%%%%%%%%% online |
---|
455 | % S1 = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-06-11_12-53-30.mat') % mesure sur machine du lundi 11 juin |
---|
456 | % Dy_Meas = S1.Dy_Meas; |
---|
457 | % S2 = load('-mat','/home/matlabML/measdata/Ringdata/Response/Skew/SkewMeasurement_2007-06-11_12-25-27.mat') % mesure sur machine du lundi 11 juin |
---|
458 | % CTCO_Meas = S2.CTCO_Meas; |
---|
459 | end |
---|
460 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
461 | % Efficiency Matrix loading |
---|
462 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
463 | %pourcentage = 100 ; % 100% de la correction proposée sera appliquée |
---|
464 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2007-03-09_16-46-16_deuxieme_test.mat') |
---|
465 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2010-06-17_13-41-00_DISP_nano_20_64.mat') |
---|
466 | %%% S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-10_13-47-38_alphaby10_maher_opt_32QT_DISP') |
---|
467 | % S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-14_10-36-42_alphaby10_maher_opt_DISP_BIS') |
---|
468 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-21_19-02-21_32QT_optique_nanoscopiumLIKE_DISP') |
---|
469 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-09-23_11-18-19_lat_nanoscopiumLIKE_122BPM_DISP') |
---|
470 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-10-06_09-23-22_lat_nano_17_25_chicane_0_disp') |
---|
471 | |
---|
472 | S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-10-11_17-51-37_lat_nano_17_25_disp') |
---|
473 | % S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-09-22_15-46-11_lat_nano_17_25_bis_DISP') |
---|
474 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-13_13-27-54_betax5m_32QT_DISP') |
---|
475 | % run 27 octobre 08 |
---|
476 | %S_D = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2008-10-24_15-03-20_DISP_nux_0-27_nuz_0-32.mat') |
---|
477 | Meffskewquad_D = S_D.Meffskewquad_D; |
---|
478 | %Meffskewquad_D = [Meffskewquad_D(:,1:23) Meffskewquad_D(:,25:32)] % exclure le Skew monté en Quad |
---|
479 | % S_CTCO = |
---|
480 | % load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2007-06-03_23-13-56_CTCO_theorique.mat') nominal |
---|
481 | %%%% S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-10_11-52-51_alphaby10_maher_opt_32QT_CTCO') |
---|
482 | % S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-13_14-30-15_alphaby10_maher_opt_32QT_CTCO_DeltaH0_2A') |
---|
483 | % S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-21_18-03-17_32QT_optique_NanoscopiumLIKE_CTCO') |
---|
484 | %S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-09-23_09-18-24_lat_nanoscopiumLIKE_122BPM_CTCO') |
---|
485 | %S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-10-05_18-30-43_lat_nano_17_25_chicane_0_CTCO') |
---|
486 | S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-10-11_18-08-11_lat_nano_17_25_CTCO') |
---|
487 | |
---|
488 | |
---|
489 | % S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-09-22_13-58-13_lat_nano_17_25_CTCO_bis_CTCO') |
---|
490 | %S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2011-06-13_11-06-05_betax5m_32QT_CTCO') |
---|
491 | %S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2010-06-17_12-13-58_CTCO_lat_nano_20_64.mat') |
---|
492 | % run 27 octobre 08 |
---|
493 | %S_CTCO = load('-mat','/home/matlabML/measdata/SOLEIL/StorageRingdata/Response/Skew/SkewRespMat_2008-10-24_09-19-19_CTCO_nux_0-27_nuz_0-32.mat') |
---|
494 | Meffskewquad_CTCO = S_CTCO.Meffskewquad_CTCO; |
---|
495 | |
---|
496 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
497 | % Coupling Matrix construction (depending on Relative Dispersion correction weigth) |
---|
498 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
499 | |
---|
500 | %PoidsDz = Params(1)*ones(1,120); % 1e3*ones(1,120); % Relative Dispersion correction weigth |
---|
501 | |
---|
502 | |
---|
503 | DeviceList_QT = family2dev('QT'); |
---|
504 | DeviceList_HCOR = family2dev('HCOR'); |
---|
505 | DeviceList_BPMz = family2dev('BPMz'); |
---|
506 | |
---|
507 | nb = length(DeviceList_BPMz); |
---|
508 | PoidsDz = PoidsDz*ones(1,nb); % 1e3*ones(1,120); % Relative Dispersion correction weigth |
---|
509 | |
---|
510 | for l = 1:length(DeviceList_QT) |
---|
511 | for k = 1:length(DeviceList_QT) |
---|
512 | A_Dz(l,k) = sum(PoidsDz'.*Meffskewquad_D(:,l).*Meffskewquad_D(:,k)); % Vérifier dimension de PoidsDz |
---|
513 | end |
---|
514 | end |
---|
515 | for l = 1:length(DeviceList_QT) |
---|
516 | for k = 1:length(DeviceList_QT) |
---|
517 | for j = 1:length(DeviceList_HCOR) |
---|
518 | T(j) = sum(Meffskewquad_CTCO(:,j,l).*Meffskewquad_CTCO(:,j,k)); |
---|
519 | end |
---|
520 | A_CTCO(l,k) = sum(T(:)); |
---|
521 | end |
---|
522 | end |
---|
523 | MeffSkewQuad = A_Dz + A_CTCO; |
---|
524 | |
---|
525 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
526 | % Second member vector evaluation ( also depending on Relative Dispersion correction weigth !!) |
---|
527 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
528 | |
---|
529 | for l = 1:length(DeviceList_QT) |
---|
530 | B_Dz(l) = sum(PoidsDz'.*Meffskewquad_D(:,l).*Dy_Meas(:)); % Vérifier dimension de PoidsDz |
---|
531 | end |
---|
532 | for l = 1:length(DeviceList_QT) |
---|
533 | |
---|
534 | for j = 1:length(DeviceList_HCOR) |
---|
535 | T(j) = sum(Meffskewquad_CTCO(:,j,l).*CTCO_Meas(:,j)); |
---|
536 | end |
---|
537 | B_CTCO(l) = sum(T(:)); |
---|
538 | |
---|
539 | end |
---|
540 | coeff_Dz = -1; coeff_CTCO = 0 ; % coeff_Dz / coeff_CTCO = -1 -> annulation du couplage dispersion / orbites croisées (betatron) |
---|
541 | SecondMember = + coeff_Dz * B_Dz + coeff_CTCO * B_CTCO; |
---|
542 | |
---|
543 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
544 | % Correction ( also depending on Relative Dispersion correction weigth !!) |
---|
545 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
546 | |
---|
547 | couleur = 'k-o' % changer la couleur pour chaque valeur de nbvp (sauf blue) |
---|
548 | [U,S,V] = svd(MeffSkewQuad); |
---|
549 | figure(4) ; semilogy(diag(S));title('MeffSkewQuad - PoidsDz = 0');xlabel('No EigenValue'); |
---|
550 | DiagS = diag(S); |
---|
551 | %nbvp = Params(2) ; % 32 % length(DiagS); % NOMBRE DE VALEURS PROPRES |
---|
552 | Rmod1 = MeffSkewQuad * V(:,1:nbvp); |
---|
553 | B1 = Rmod1\ (SecondMember' ); % SeconMember en ? |
---|
554 | Deltaskewquad = V(:,1:nbvp) * B1 |
---|
555 | %figure(20) ; hold on ; plot(Deltaskewquad,couleur) ; title('Valeur des QT en A') |
---|
556 | figure(20) ; hold on ; plot(Deltaskewquad,'Color',nxtcolor) ; title('Valeur des QT en A') |
---|
557 | consigne = getsp('QT',ModeFlag); |
---|
558 | %consigne = [consigne(1:23)' consigne(25:32)']' |
---|
559 | |
---|
560 | %pourcentage = Params(3) % 100; % POURCENTAGE DE LA CORRECTION |
---|
561 | val_max = 7 ; val_min = -7 ; |
---|
562 | if all((consigne + Deltaskewquad* pourcentage*0.01)<val_max)*all((consigne +Deltaskewquad* pourcentage*0.01)>val_min); |
---|
563 | %Deltaskewquad = [Deltaskewquad(1:23)' 0 Deltaskewquad(24:31)']' |
---|
564 | %% |
---|
565 | |
---|
566 | stepsp('QT',Deltaskewquad* pourcentage*0.01,ModeFlag); % |
---|
567 | correction = getam('QT',ModeFlag) |
---|
568 | |
---|
569 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% mesure sur la machine aprÚs correction |
---|
570 | if PostMeasurementFlag |
---|
571 | [Dxapres,Dyapres] = measdisp('Physics',ModeFlag) |
---|
572 | if strcmpi(ModeFlag,'Online') |
---|
573 | Dyapres = Dxapres.*Cinv(:,2,1) + Dyapres.*Cinv(:,2,2); % |
---|
574 | end |
---|
575 | sleep(waittime) |
---|
576 | figure(25) ; hold on ; plot(getspos('BPMz'),Dy_Meas,'bo-') ; |
---|
577 | hold on ; plot(getspos('BPMz'),Dyapres,couleur );legend('Dispersion V avant correction','apres correction') |
---|
578 | |
---|
579 | DeviceNumber_HCOR = 0; |
---|
580 | for k2 =1:3 |
---|
581 | DeviceNumber_HCOR = DeviceNumber_HCOR + 1; |
---|
582 | Ic_HCOR = getam('HCOR', DeviceList_HCOR(k2,:), ModeFlag); |
---|
583 | if OutputFlag |
---|
584 | fprintf('Measuring %s [%d %d] actual current %f A : ... \n', ... |
---|
585 | 'HCOR', DeviceList_HCOR(k2,:),Ic_HCOR) % pour suivi |
---|
586 | end |
---|
587 | |
---|
588 | %DeltaI_HCOR = 0.6*1.; % 0.6 Amp : choix d'une orbite inférieure à 1 mm |
---|
589 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
590 | stepsp('HCOR', DeltaI_HCOR, DeviceList_HCOR(k2,:), ModeFlag); % Step value |
---|
591 | sleep(waittime) % wait for HCOR reaching new setpoint value |
---|
592 | |
---|
593 | Xof1 = getx(ModeFlag) ; |
---|
594 | Zof1 = getz(ModeFlag) ; |
---|
595 | if strcmpi(ModeFlag,'Online') |
---|
596 | Zof1(:,k) = Xof1(:,k).*Cinv(:,2,1) +Zof1(:,k).*Cinv(:,2,2); |
---|
597 | end |
---|
598 | |
---|
599 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
600 | stepsp('HCOR', -2*DeltaI_HCOR, DeviceList_HCOR(k2,:), ModeFlag); % Step value |
---|
601 | sleep(waittime) % wait for HCOR reaching new setpoint value |
---|
602 | |
---|
603 | Xof2 = getx(ModeFlag) ; |
---|
604 | Zof2 = getz(ModeFlag) ; |
---|
605 | if strcmpi(ModeFlag,'Online') |
---|
606 | Zof2(:,k) = Xof2(:,k).*Cinv(:,2,1) +Zof2(:,k).*Cinv(:,2,2); |
---|
607 | end |
---|
608 | |
---|
609 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
610 | stepsp('HCOR', DeltaI_HCOR, DeviceList_HCOR(k2,:), ModeFlag); % Initial value |
---|
611 | sleep(waittime) % wait for HCOR reaching new setpoint value |
---|
612 | |
---|
613 | %% computation part |
---|
614 | |
---|
615 | DeltaZof = Zof2-Zof1 ; % HCOR induced Orbit shift |
---|
616 | |
---|
617 | if k2 == 1 |
---|
618 | figure(21) ; hold on ; plot(getspos('BPMz'),DeltaZof,couleur) ; |
---|
619 | if exist('lim') ylim([-lim lim]) |
---|
620 | end; % CTCO aprÚs correction |
---|
621 | hold on ; plot(getspos('BPMz'),-CTCO_Meas(:,1)*2*DeltaI_HCOR,'bo-') % réference avant correction |
---|
622 | title('HCOR [1 1]') ; legend('CTCO aprÚs correction','CTCO avant correction') |
---|
623 | elseif k2 == 2 |
---|
624 | figure(22) ; hold on ; plot(getspos('BPMz'),DeltaZof,couleur) ; |
---|
625 | if exist('lim') ylim([-lim lim]) |
---|
626 | end ; % CTCO aprÚs correction |
---|
627 | hold on ; plot(getspos('BPMz'),-CTCO_Meas(:,2)*2*DeltaI_HCOR,'bo-') % réference avant correction |
---|
628 | title('HCOR [1 4]') ; legend('CTCO aprÚs correction','CTCO avant correction') |
---|
629 | elseif k2 == 3 |
---|
630 | figure(23) ; hold on ; plot(getspos('BPMz'),DeltaZof,couleur) ; |
---|
631 | if exist('lim') ylim([-lim lim]) |
---|
632 | end ; % CTCO aprÚs correction |
---|
633 | hold on ; plot(getspos('BPMz'),-CTCO_Meas(:,3)*2*DeltaI_HCOR,'bo-') % réference avant correction |
---|
634 | title('HCOR [1 7]') ; legend('CTCO aprÚs correction','CTCO avant correction') |
---|
635 | end |
---|
636 | end |
---|
637 | end |
---|
638 | |
---|
639 | |
---|
640 | if ~strcmpi(ModeFlag,'Online') |
---|
641 | E = modelemit; |
---|
642 | fprintf('EmittanceX = %4.2f nm , EmittanceZ = %4.2f pm \n',E(1),E(2)*1e3 ) |
---|
643 | fprintf('Couplage = %4.2f % \n',100*E(2)/E(1) ) |
---|
644 | disp('contente ?!') |
---|
645 | %setsp('QT',consigne,ModeFlag); |
---|
646 | else |
---|
647 | % prendre mesure pinhole |
---|
648 | emit = tango_read_attributes('ANS-C02/DG/PHC-EMIT',{'EmittanceH','EmittanceV'}); |
---|
649 | fprintf('EmittanceX = %4.2f nm , EmittanceZ = %4.2f pm \n',emit(1).value,emit(2).value ) |
---|
650 | end |
---|
651 | %% |
---|
652 | |
---|
653 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
654 | |
---|
655 | disp('eh oui') |
---|
656 | |
---|
657 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
658 | %%% à faire à la main sur demande : setsp('QT',consigne,'Model') % go back to initial value for QT |
---|
659 | else |
---|
660 | consigne-Deltaskewquad |
---|
661 | errordlg('un QT au moins dépasse les valeurs admises !','Attention'); |
---|
662 | return |
---|
663 | end |
---|
664 | end |
---|