Commit c7a54bf1 authored by Simone Liuzzo's avatar Simone Liuzzo

emittance reading corrected

parent ae924bf1
......@@ -161,24 +161,34 @@ end
% function to loop trough cameras measurement. will be replaced by
% srdiag/beam-emittance/all/Emittance_H (?)
function [ex,ey]=readpinholes()
function [ex,ey]=readpinholes(doplot)
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;
ex(ip) = ph.Emittance_h.read;
ey(ip) = ph.Emittance_v.read;
catch errpin
warning(['impossible to read device pinhole: ' pinholes_list{ip}])
disp(errpin)
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');
......@@ -247,6 +257,7 @@ NBPM = length(o0(1,:));
disp(['File ' filename ' already exists. Skip measurement']);
a = load(filename,'response');
response=a.response;
filenametotxt;
return
end
......@@ -273,6 +284,7 @@ NBPM = length(o0(1,:));
disp(['File ' filename ' already exists. Skip measurement']);
a = load(filename,'response');
response=a.response;
filenametotxt;
return
end
% check if it is enabled
......@@ -294,6 +306,7 @@ NBPM = length(o0(1,:));
disp(['File ' filename ' already exists. Skip measurement']);
a = load(filename,'response');
response=a.response;
filenametotxt;
return
end
......@@ -368,23 +381,26 @@ NBPM = length(o0(1,:));
% save file
%matlab
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,:));
fclose(fh);
fprintf(fv,['%.8f\t%s,%.1d\t' repmat('%.5f\t',1,NBPM)],variation,vnames{actuatorindex},algo,response(2,:));
fclose(fv);
function filenametotxt
%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-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
......@@ -532,7 +548,11 @@ disp('End of measurement');
% csv files for operation
switch obj.machine
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
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