Commit a5c4694c authored by Simone Liuzzo's avatar Simone Liuzzo

added emittance measured at pinholes, removed txt, added ebs.autocor_model for...

added emittance measured at pinholes, removed txt, added ebs.autocor_model for cvs file (not working)
parent 46d7d045
......@@ -63,6 +63,8 @@ function [h,v,h2v,v2h,rfh,rfv] = MeasureOrbitResponseMatrix(obj,varargin)
%% get initial informations
additional_wait_time = 5;
measurementtime = datestr(now);
%initial settings:
h0 = obj.sh.get;
v0 = obj.sv.get;
......@@ -137,12 +139,45 @@ NV = length(vlist);
%% initialize measurements
% CHECK AUTOCOR IS NOT ON.
warning('Add here an error if autocor is running!');
autocor=tango.Device(obj.autocor);
if autocor.State ~= 'Off' %#ok<BDSCA>
error('Autcor is not OFF');
end
% pinhole emittances before measurement
pinholes_list = ebs.pinholename(1:5);
for iph = 1:length(pinholes_list)
try
phdev_list{iph} = tango.Device(pinholes_list{iph}); %#ok<AGROW> % get devices
catch err
warning(['impossible to get device pinhole: ' pinholes_list{iph}])
disp(err)
end
end
% function to loop trough cameras measurement. will be replaced by
% srdiag/beam-emittance/all/Emittance_H (?)
function [ex,ey]=readpinholes()
ey = NaN(size(pinholes_list));
ex = NaN(size(pinholes_list));
for ip = 1:length(pinholes_list)
try
ph = phdev_list{ip};
ex(ip) = ph.Emittance_H;
ey(ip) = ph.Emittance_V;
catch errpin
warning(['impossible to read device pinhole: ' pinholes_list{ip}])
disp(errpin)
end
end
end
[ex,ey]=readpinholes(); %#ok<ASGLU>
save(['ApparentEmittances' measurementtime],'pinholes_list','ex','ey');
% initial orbit
na0 = obj.n_acquisitions;
obj.n_acquisitions = nacq;
......@@ -299,7 +334,8 @@ NBPM = length(o0(1,:));
% return to intial value
A.set(K0);
pause(additional_wait_time)
% compute response (not normalized)
response = (op-om) ;
......@@ -307,27 +343,27 @@ NBPM = length(o0(1,:));
driftcontrol; % this function returns an ERROR if orbit changed befor and after measurement
% get pinholes sizes variations
warning('no IAX data. implement PINHOLE DATA append to file IAX');
warning('no ApparentEmittance data. implement PINHOLE DATA append to file IAX');
% save file
%matlab
save(filename,'response','variation','mode');
%text (same file names and format of respmat.py
switch mode
case 'H'
fh = fopen([filename '.txt'],'w');
fv = fopen([strrep(filename,'H','H2V') '.txt'],'w');
fh = fopen([filename ''],'w');
fv = fopen([strrep(filename,'H','H2V') ''],'w');
case 'V'
fh = fopen([strrep(filename,'V','V2H') '.txt'],'w');
fv = fopen([filename '.txt'],'w');
fh = fopen([strrep(filename,'V','V2H') ''],'w');
fv = fopen([filename ''],'w');
case 'F'
fh = fopen([strrep(filename,'F','F2H') '.txt'],'w');
fv = fopen([strrep(filename,'F','F2V') '.txt'],'w');
fh = fopen([strrep(filename,'F','F2H') ''],'w');
fv = fopen([strrep(filename,'F','F2V') ''],'w');
end
fprintf(fh,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM)],variation,A.attr_name,algo,response(1,:));
fprintf(fh,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM)],variation,hnames{actuatorindex},algo,response(1,:));
fclose(fh);
fprintf(fv,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM)],variation,A.attr_name,algo,response(2,:));
fprintf(fv,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM)],variation,vnames{actuatorindex},algo,response(2,:));
fclose(fv);
end
......@@ -336,75 +372,106 @@ NBPM = length(o0(1,:));
% initialize Response matrices
h = NaN(NBPM,NH);
v = NaN(NBPM,NV);
rfh = NaN(NBPM,1);
rfv = NaN(NBPM,1);
h2v = NaN(NBPM,NH); % horizontal steerer to vertical orbit
v2h = NaN(NBPM,NV); % vertical steerer to horizontal orbit
% horizontal response matrix
disp(['Measure Orbit RM for ' num2str(length(hlist)) ' / ' num2str(NHall) ' horizontal correctors']);
% figure for response matrix evolution display.
figure;
ax = gca;
stdh = std2(h);
stdv = std2(h2v);
figure('units','normalized','Position',[0.05,0.2,0.9,0.6]);
% horizontal
subplot(2,1,1);
axH = gca;
stdh = std2([h, rfh]);
stdv = std2([h2v,rfv]);
stdvalues =[ stdh ; stdv]';
b=bar(ax,stdvalues);
ax.XLim = [0, NH+1];
ax.XTick = 1:length(hlist);
ax.XTickLabel=hnames;
ax.XTickLabelRotation = 90;
ax.Title.String= 'horizontal steerers response';
ax.YLabel.String = 'std of orbit response';
bH=bar(axH,stdvalues);
axH.XLim = [0, NH+2];
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';
legend('hor.','ver');
hold on;
b(1).YDataSource ='stdh';
b(2).YDataSource ='stdv';
bH(1).YDataSource ='stdh';
bH(2).YDataSource ='stdv';
% vertical
subplot(2,1,2);
axV = gca;
stdh = std2(v2h);
stdv = std2(v);
stdvalues =[ stdh ; stdv]';
bv=bar(axV,stdvalues);
axV.XLim = [0, NV+1];
axV.XTick = 1:length(vlist);
axV.XTickLabel=vnames;
axV.XTickLabelRotation = 90;
axV.Title.String= 'vertical steerers response';
axV.YLabel.String = 'std of orbit response';
legend('hor.','ver');
hold on;
bv(1).YDataSource ='stdh';
bv(2).YDataSource ='stdv';
% horizontal response matrix
disp(['Measure Orbit RM for ' num2str(length(hlist)) ' / ' num2str(NHall) ' horizontal correctors']);
for ii = 1:length(hlist)
try
% try
% measure
resp = measure('H',deltah,ii);
% assign in ;global RM
% assign in global RM
h(:,ii) = resp(1,:)'./deltah;
h2v(:,ii) = resp(2,:)'./deltah;
% plot
stdh = std2(h);
stdv = std2(h2v);
stdh = std2([h, rfh]);
stdv = std2([h2v,rfv]);
stdvalues =[ stdh ; stdv]';
refreshdata(axH,'caller');
drawnow;
% catch err
% disp(err);
% error(['Error evaluating response for ' hnames{ii}]);
% end
end
if RF
disp(['Measure Orbit RM for RF frequency. Initial f_RF: ' num2str(rf0,'%9.8f')]);
try
% measure
resp = measure('F',deltarf,1);
% assign in global RM
rfh(:,1) = resp(1,:)'./deltarf;
rfv(:,1) = resp(2,:)'./deltarf;
% plot
stdh = std2([h,rfh]);
stdv = std2([h2v,rfv]);
stdvalues =[ stdh ; stdv]';
refreshdata(ax,'caller');
refreshdata(axH,'caller');
drawnow;
catch err
disp(err);
error(['Error evaluating response for ' hnames{ii}]);
error(['Error evaluating Frequency response']);
end
end
% figure for response matrix evolution display.
figure;
ax = gca;
stdh = std2(v2h);
stdv = std2(v);
stdvalues =[ stdh ; stdv]';
b=bar(ax,stdvalues);
ax.XLim = [0, NV+1];
ax.XTick = 1:length(vlist);
ax.XTickLabel=vnames;
ax.XTickLabelRotation = 90;
ax.Title.String= 'vertical steerers response';
ax.YLabel.String = 'std of orbit response';
legend('hor.','ver');
hold on;
b(1).YDataSource ='stdh';
b(2).YDataSource ='stdv';
disp(['Measure Orbit RM for ' num2str(length(vlist)) ' / ' num2str(NVall) ' vertical correctors']);
for ii = 1:length(vlist)
try
% try
% measure
resp = measure('V',deltav,ii);
......@@ -416,35 +483,22 @@ for ii = 1:length(vlist)
stdh = std2(v2h);
stdv = std2(v);
stdvalues =[ stdh ; stdv]';
refreshdata(ax,'caller');
refreshdata(axV,'caller');
drawnow;
catch err
disp(err);
error(['Error evaluating response for ' vnames{ii}]);
end
end
if RF
disp(['Measure Orbit RM for RF frequency. Initial f_RF: ' num2str(rf0,'%9.8f')]);
try
% measure
resp = measure('F',deltarf,1);
% assign in global RM
rfh(:,1) = resp(1,:)'./deltarf;
rfv(:,1) = resp(2,:)'./deltarf;
catch err
disp(err);
error(['Error evaluating Frequency response']);
end
% catch err
% disp(err);
% error(['Error evaluating response for ' vnames{ii}]);
% end
end
save(['OrbitResponseMatrix' datestr(now) '.mat'],...
save(['OrbitResponseMatrix' measurementtime '.mat'],...
'h','v','h2v','v2h','rfh','rfv');
disp('End of measurement');
% csv files for operation
ebs.autocor_model(obj.rmodel,'exp',pwd)
% 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