Commit b7a0dcd6 authored by Simone Liuzzo's avatar Simone Liuzzo

Debugged RM measurement for ESRF SR

parent 7a559db9
......@@ -6,10 +6,10 @@ function [h,v,h2v,v2h,rfh,rfv] = MeasureOrbitResponseMatrix(obj,varargin)
% INPUT (variable):
% 'Hsteerers' : vector of indexes in steerer list or mask of boolean
% these are the steerers used for RM measurement.
% default = 1:TOT/(TOT/32*2):TOT (1 every two cells)
% default = 1:(TOT/32*2):TOT (1 every two cells)
% 'Vsteerers' : vector of indexes in steerer list or mask of boolean
% these are the steerers used for RM measurement.
% default = 1:TOT/(TOT/32*2):TOT (1 every two cells)
% default = 1:(TOT/32*2):TOT (1 every two cells)
% 'Frequency' : boolean, measure or not RF response. default: true
% 'TwoSide' : boolean, compute - kick and + kick. default: true
% 'delta' : 3x1 vector of variations for H,V steerers and RF.
......@@ -80,7 +80,7 @@ addParameter(p,'Hsteerers',1:(NHall/32*2):NHall,@(x)(isnumeric(x) | islogical(x)
addParameter(p,'Vsteerers',1:(NVall/32*2):NVall,@(x)(isnumeric(x) | islogical(x)));
addParameter(p,'Frequency',true,@islogical);
addParameter(p,'TwoSide',true,@islogical);
addParameter(p,'delta',[5e-5 5e-5 50],@(x)(isnumeric(x) & length(x)==3));
addParameter(p,'delta',[2e-5 2e-5 50],@(x)(isnumeric(x) & length(x)==3));
addParameter(p,'ignoreinch',false);
addParameter(p,'num_acquisitions',obj.n_acquisitions);
addParameter(p,'threshold_orbit_drifting',1e-4);
......@@ -123,7 +123,11 @@ switch obj.machine
hnames = ebs.hsteername(hlist');
vnames = ebs.vsteername(vlist');
% case 'esrf-sr'
case 'esrf-sr'
hnames = sr.steername(hlist');
vnames = sr.steername(vlist');
%
% case 'esrf-sy'
%
......@@ -193,7 +197,9 @@ NBPM = length(o0(1,:));
function [ok,st,mx] = checkorbit(o,ref)
% get orbit sum, std, maximum
if ~isempty(ref)
o = o- ref;
o = o([1,2],:)- ref([1,2],:);
else
o = o([1,2],:);
end
ok = sum2(isfinite(o),2);
st = std2(o,0,2);
......@@ -235,7 +241,7 @@ NBPM = length(o0(1,:));
A = obj.sh;% moovable class object instance
filename = ['steer' mode num2str(hlist(actuatorindex),'%.3d')];
hvlist=hlist;
% check if file already exist, in case, skip.
if exist([filename '.mat'],'file')
disp(['File ' filename ' already exists. Skip measurement']);
......@@ -259,6 +265,7 @@ NBPM = length(o0(1,:));
A = obj.sv;% moovable class object instance
filename = ['steer' mode num2str(vlist(actuatorindex),'%.3d')];
hvlist=vlist;
% check if file already exist, in case, skip.
if exist([filename '.mat'],'file')
disp(['File ' filename ' already exists. Skip measurement']);
......@@ -277,7 +284,7 @@ NBPM = length(o0(1,:));
end
case 'F'
filename = ['steer' 'F00' ];
hvlist=1;
% check if file already exist, in case, skip.
if exist([filename '.mat'],'file')
disp(['File ' filename ' already exists. Skip measurement']);
......@@ -296,8 +303,8 @@ NBPM = length(o0(1,:));
if twoside % double sided measurement
% up
Kp=K0;
Kp(actuatorindex) = K0(actuatorindex) + 0.5*variation;
disp(['UP: ' num2str(K0(actuatorindex),'%3.2e') ' + ' num2str(0.5*variation,'%3.2e') ' = ' num2str(Kp(actuatorindex),'%3.2e')]);
Kp(hvlist(actuatorindex)) = K0(hvlist(actuatorindex)) + 0.5*variation;
disp(['UP: ' num2str(K0(hvlist(actuatorindex)),'%3.2e') ' + ' num2str(0.5*variation,'%3.2e') ' = ' num2str(Kp(hvlist(actuatorindex)),'%3.2e')]);
A.set(Kp); % moovable set also waits for setpoint reach.
% get real variation in case it could not reach set point
......@@ -305,11 +312,12 @@ NBPM = length(o0(1,:));
pause(additional_wait_time)
op = measfun();
disp(['Dorbit: ' num2str(std2(op'-o0'))]);
disp(['+ orbit rms: ' num2str(std2(op([1,2],:)'))]);
% down
Km=K0;
Km(actuatorindex) = K0(actuatorindex) - 0.5*variation;
disp(['DOWN: ' num2str(K0(actuatorindex),'%3.2e') ' - ' num2str(0.5*variation,'%3.2e') ' = ' num2str(Km(actuatorindex),'%3.2e')]);
Km(hvlist(actuatorindex)) = K0(hvlist(actuatorindex)) - 0.5*variation;
disp(['DOWN: ' num2str(K0(hvlist(actuatorindex)),'%3.2e') ' - ' num2str(0.5*variation,'%3.2e') ' = ' num2str(Km(hvlist(actuatorindex)),'%3.2e')]);
A.set(Km);% moovable set also waits for setpoint reach.
% get real variation in case it could not reach set point
warning('impement get real variation');
......@@ -317,17 +325,19 @@ NBPM = length(o0(1,:));
om = measfun();
disp(['Dorbit: ' num2str(std2(om'-o0'))]);
disp(['- orbit rms: ' num2str(std2(om([1,2],:)'))]);
else % single sided
Kp=K0;
Kp(actuatorindex) = K0(actuatorindex) + variation;
disp(['UP: ' num2str(K0(actuatorindex),'%3.2e') ' + ' num2str(variation,'%3.2e') ' = ' num2str(Kp(actuatorindex),'%3.2e')]);
Kp(hvlist(actuatorindex)) = K0(hvlist(actuatorindex)) + variation;
disp(['UP: ' num2str(K0(hvlist(actuatorindex)),'%3.2e') ' + ' num2str(variation,'%3.2e') ' = ' num2str(Kp(hvlist(actuatorindex)),'%3.2e')]);
A.set(Kp);% moovable set also waits for setpoint reach.
warning('impement get real variation');
pause(additional_wait_time)
op = measfun();
disp(['Dorbit: ' num2str(std2(op'-o0'))]);
disp(['+ orbit rms: ' num2str(std2(op([1,2],:)'))]);
om = o0;
end
......@@ -379,6 +389,16 @@ rfv = NaN(NBPM,1);
h2v = NaN(NBPM,NH); % horizontal steerer to vertical orbit
v2h = NaN(NBPM,NV); % vertical steerer to horizontal orbit
% for plots
hplot = NaN(NBPM,NH);
vplot = NaN(NBPM,NV);
rfhplot = NaN(NBPM,1);
rfvplot = NaN(NBPM,1);
h2vplot = NaN(NBPM,NH); % horizontal steerer to vertical orbit
v2hplot = NaN(NBPM,NV); % vertical steerer to horizontal orbit
% figure for response matrix evolution display.
......@@ -395,7 +415,7 @@ axH.XTick = 1:length(hlist)+1;
axH.XTickLabel=[hnames;'frequency'];%obj.rf.attr_name];
axH.XTickLabelRotation = 90;
axH.Title.String= 'horizontal steerers response';
axH.YLabel.String = 'std of orbit response';
axH.YLabel.String = 'std of orbit response [mm]';
legend('hor.','ver');
hold on;
bH(1).YDataSource ='stdh';
......@@ -413,7 +433,7 @@ axV.XTick = 1:length(vlist);
axV.XTickLabel=vnames;
axV.XTickLabelRotation = 90;
axV.Title.String= 'vertical steerers response';
axV.YLabel.String = 'std of orbit response';
axV.YLabel.String = 'std of orbit response [mm]';
legend('hor.','ver');
hold on;
bv(1).YDataSource ='stdh';
......@@ -430,11 +450,12 @@ for ii = 1:length(hlist)
% assign in global RM
h(:,ii) = resp(1,:)'./deltah;
h2v(:,ii) = resp(2,:)'./deltah;
hplot(:,ii) = resp(1,:)'*1e3;
h2vplot(:,ii) = resp(2,:)'*1e3;
% plot
stdh = std2([h, rfh]);
stdv = std2([h2v,rfv]);
stdvalues =[ stdh ; stdv]';
stdh = std2([hplot, rfhplot]);
stdv = std2([h2vplot,rfvplot]);
refreshdata(axH,'caller');
drawnow;
......@@ -445,7 +466,7 @@ for ii = 1:length(hlist)
end
if RF
disp(['Measure Orbit RM for RF frequency. Initial f_RF: ' num2str(rf0,'%9.8f')]);
disp(['Measure Orbit RM for RF frequency. Initial f_RF: ' num2str(rf0,'%9.2f') ' Hz']);
try
% measure
resp = measure('F',deltarf,1);
......@@ -453,11 +474,12 @@ if RF
% assign in global RM
rfh(:,1) = resp(1,:)'./deltarf;
rfv(:,1) = resp(2,:)'./deltarf;
rfhplot(:,1) = resp(1,:)'*1e3;
rfvplot(:,1) = resp(2,:)'*1e3;
% plot
stdh = std2([h,rfh]);
stdv = std2([h2v,rfv]);
stdvalues =[ stdh ; stdv]';
stdh = std2([hplot,rfhplot]);
stdv = std2([h2vplot,rfvplot]);
refreshdata(axH,'caller');
drawnow;
......@@ -478,11 +500,12 @@ for ii = 1:length(vlist)
% assign in global RM
v2h(:,ii) = resp(1,:)'./deltav;
v(:,ii) = resp(2,:)'./deltav;
v2hplot(:,ii) = resp(1,:)'*1e3;
vplot(:,ii) = resp(2,:)'*1e3;
% plot
stdh = std2(v2h);
stdv = std2(v);
stdvalues =[ stdh ; stdv]';
stdh = std2(v2hplot);
stdv = std2(vplot);
refreshdata(axV,'caller');
drawnow;
......@@ -497,7 +520,11 @@ save(['OrbitResponseMatrix' measurementtime '.mat'],...
disp('End of measurement');
% csv files for operation
ebs.autocor_model(obj.rmodel,'exp',pwd)
switch obj.machine
case 'ebs-simu'
ebs.autocor_model(obj.rmodel,'exp',pwd)
otherwise
end
% restore ringcontrol object to initial state.
obj.n_acquisitions = na0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment