Commit c7a54bf1 authored by Simone Liuzzo's avatar Simone Liuzzo

emittance reading corrected

parent ae924bf1
...@@ -161,24 +161,34 @@ end ...@@ -161,24 +161,34 @@ end
% function to loop trough cameras measurement. will be replaced by % function to loop trough cameras measurement. will be replaced by
% srdiag/beam-emittance/all/Emittance_H (?) % srdiag/beam-emittance/all/Emittance_H (?)
function [ex,ey]=readpinholes() function [ex,ey]=readpinholes(doplot)
ey = NaN(size(pinholes_list)); ey = NaN(size(pinholes_list));
ex = NaN(size(pinholes_list)); ex = NaN(size(pinholes_list));
for ip = 1:length(pinholes_list) for ip = 1:length(pinholes_list)
try try
ph = phdev_list{ip}; ph = phdev_list{ip};
ex(ip) = ph.Emittance_H; ex(ip) = ph.Emittance_h.read;
ey(ip) = ph.Emittance_V; ey(ip) = ph.Emittance_v.read;
catch errpin catch errpin
warning(['impossible to read device pinhole: ' pinholes_list{ip}]) warning(['impossible to read device pinhole: ' pinholes_list{ip}])
disp(errpin) disp(errpin)
end end
end end
end
if doplot
figure;
bar([ex;ey]');
bp = gca;
legend('hor','ver');
bp.XTick=1:length(pinholes_list);
bp.XTickLabels=pinholes_list;
bp.XTickLabelRotation = 45;
end
end
[ex,ey]=readpinholes(); %#ok<ASGLU> [ex,ey]=readpinholes(true); %#ok<ASGLU>
save(['ApparentEmittances' measurementtime],'pinholes_list','ex','ey'); save(['ApparentEmittances' measurementtime],'pinholes_list','ex','ey');
...@@ -247,6 +257,7 @@ NBPM = length(o0(1,:)); ...@@ -247,6 +257,7 @@ NBPM = length(o0(1,:));
disp(['File ' filename ' already exists. Skip measurement']); disp(['File ' filename ' already exists. Skip measurement']);
a = load(filename,'response'); a = load(filename,'response');
response=a.response; response=a.response;
filenametotxt;
return return
end end
...@@ -273,6 +284,7 @@ NBPM = length(o0(1,:)); ...@@ -273,6 +284,7 @@ NBPM = length(o0(1,:));
disp(['File ' filename ' already exists. Skip measurement']); disp(['File ' filename ' already exists. Skip measurement']);
a = load(filename,'response'); a = load(filename,'response');
response=a.response; response=a.response;
filenametotxt;
return return
end end
% check if it is enabled % check if it is enabled
...@@ -294,6 +306,7 @@ NBPM = length(o0(1,:)); ...@@ -294,6 +306,7 @@ NBPM = length(o0(1,:));
disp(['File ' filename ' already exists. Skip measurement']); disp(['File ' filename ' already exists. Skip measurement']);
a = load(filename,'response'); a = load(filename,'response');
response=a.response; response=a.response;
filenametotxt;
return return
end end
...@@ -368,23 +381,26 @@ NBPM = length(o0(1,:)); ...@@ -368,23 +381,26 @@ NBPM = length(o0(1,:));
% save file % save file
%matlab %matlab
save(filename,'response','variation','mode'); save(filename,'response','variation','mode');
%text (same file names and format of respmat.py
switch mode
case 'H'
fh = fopen([filename ''],'w');
fv = fopen([strrep(filename,'H','H2V') ''],'w');
case 'V'
fh = fopen([strrep(filename,'V','V2H') ''],'w');
fv = fopen([filename ''],'w');
case 'F'
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,hnames{actuatorindex},algo,response(1,:)); function filenametotxt
fclose(fh); %text (same file names and format of respmat.py
fprintf(fv,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM)],variation,vnames{actuatorindex},algo,response(2,:)); switch mode
fclose(fv); case 'H'
fh = fopen([filename ''],'w');
fv = fopen([strrep(filename,'H','H2V') ''],'w');
case 'V'
fh = fopen([strrep(filename,'V','V2H') ''],'w');
fv = fopen([filename ''],'w');
case 'F'
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-1) '%.5f'],variation,hnames{actuatorindex},algo,response(1,:));
fclose(fh);
fprintf(fv,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM-1) '%.5f'],variation,vnames{actuatorindex},algo,response(2,:));
fclose(fv);
end
end end
...@@ -532,7 +548,11 @@ disp('End of measurement'); ...@@ -532,7 +548,11 @@ disp('End of measurement');
% csv files for operation % csv files for operation
switch obj.machine switch obj.machine
case 'ebs-simu' case 'ebs-simu'
% ebs.autocor_model(obj.rmodel,'exp',pwd) if NH == NHall && NV == NVall
ebs.autocor_model(obj.rmodel,'exp',pwd);
else
warning('CSV file not created, partial measurement only.')
end
otherwise otherwise
end end
......
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