Commit b8844bfe authored by Simone Liuzzo's avatar Simone Liuzzo

large figures if required, small ones always

parent cdb2dd76
......@@ -14,27 +14,27 @@ dkk=(k-k0l)./k0l;
if largefig
figure; extfigax = gca;
bar(extfigax,[dkk]);
%title(ax,'Gradient errors');
ylabel(extfigax,'\DeltaK/K');
grid(extfigax,'on');
set(extfigax,'Xlim',[0 nfamq+1],'FontSize',6);
else
Nc = length(dkk);
extracor = mod(Nc,32);
cor_per_cell_mean = squeeze(mean(reshape(dkk((1+extracor/2):(Nc-extracor/2)),32,[]),2));
cor_per_cell_std = squeeze(std(reshape(dkk((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
bar(ax,[cor_per_cell_mean,cor_per_cell_std],'EdgeColor','none');
ylabel(ax,'\DeltaK/K');
legend(ax,'mean','std');
grid(ax,'on');
set(ax,'Xlim',[0 32],'FontSize',6);
end
Nc = length(dkk);
extracor = mod(Nc,32);
cor_per_cell_mean = squeeze(mean(reshape(dkk((1+extracor/2):(Nc-extracor/2)),32,[]),2));
cor_per_cell_std = squeeze(std(reshape(dkk((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
bar(ax,[cor_per_cell_mean,cor_per_cell_std],'EdgeColor','none');
ylabel(ax,'\DeltaK/K');
legend(ax,'mean','std');
grid(ax,'on');
set(ax,'Xlim',[0 32],'FontSize',6);
return
......@@ -43,13 +43,13 @@ return
%stdf=NaN*ones(nfamq,nm);
%meanf=NaN*ones(nfamq,nm);
%for i=1:nm
dkkf=ebs.fold(dkk);
nfamq=length(dkkf);
for ii=1:nfamq
dkkf=ebs.fold(dkk);
nfamq=length(dkkf);
for ii=1:nfamq
stdf(ii,1)=std(dkkf{ii});
meanf(ii,1)=mean(dkkf{ii});
end
end
stda=std(dkk,1,1);
fprintf('%s:\t% .3e\n','all',stda(1));
for i=1:nfamq
......
......@@ -37,7 +37,7 @@ mess={...
% qemmodulplot(handles.axes2, sbpm, modulh, '');hold on;
% qemmodulplot(handles.axes2, sbpm, modulv, '');hold off;
% legend('\beta_x','\beta_z')
%
%
% % qemd(handles.axes2, sbpm, modulv, '\eta_x');
% end
disp('qemstopbands msg');toc;
......@@ -51,114 +51,28 @@ if all(isfield(handles,{'axes2','axes3'})) % displays beta modulation
qemmodulplot(handles.axes3, sbpm, modulv, '\beta_z');
end
% if isfield(handles,'axes3') % displays horizontal dispersion
% if isfield(qemres,'frespx')
% plot(handles.axes3,sbpm,-qemb.pm.alpha*[qemb.frespx-qemb0.frespx...
% qemres.bhscale*qemres.frespx-qemb0.frespx...
% (qemb.frespx-qemb0.frespx)-(qemres.bhscale*qemres.frespx-qemb0.frespx)]);
% else
% plot(handles.axes3,sbpm,-qemb.pm.alpha*(qemb.frespx-qemb0.frespx));
%
% end
% title(handles.axes3,'Horizontal dispersion');
% ax=axis(handles.axes3);
% ym=max(abs(ax([3 4])));
% axis(handles.axes3,[0 844.39 -ym ym]);
% ylabel(handles.axes3,'\eta_x [m]');
% grid(handles.axes3,'on');
% legend(handles.axes3,'measured','fit','difference')
%
% end
% %% compare to simulator
% a=load('/operation/appdata/EbsSimulator/s28dseed1order12.mat','s28dseed1order12');
% rs=a.s28dseed1order12;
% inds=1:length(rs);
% indbs=find(atgetcells(rs,'Class','Monitor'))';
%
% [ls,ts,cs]=atlinopt(rs,0,inds);
% ss=arrayfun(@(a)a.SPos(1),ls);
% bxs=arrayfun(@(a)a.beta(1),ls);
% bys=arrayfun(@(a)a.beta(2),ls);
% dxs=arrayfun(@(a)a.Dispersion(1),ls);
% dzs=arrayfun(@(a)a.Dispersion(3),ls);
% modulhS=bmodul(bxs(indbs)',qemb0.beta(:,1));
% modulvS=bmodul(bys(indbs)',qemb0.beta(:,2));
%
% %%
% figure;
% subplot(2,2,1)
% qemmodulplot(gca, sbpm, modulh, '');hold on;
% qemmodulplot(gca, ss(indbs),modulhS, '');hold off;
% legend('\beta_x FIT','\beta_x SIMULATOR','Location','NorthWest')
% subplot(2,2,2)
% qemmodulplot(gca, sbpm, modulv, '');hold on;
% qemmodulplot(gca, ss(indbs),modulvS, '');hold off;
% legend('\beta_z FIT','\beta_z SIMULATOR','Location','NorthWest')
%
% subplot(2,2,3)
%
% if isfield(qemres,'frespx')
% plot(gca,sbpm,-qemb.pm.alpha*[qemb.frespx-qemb0.frespx...
% qemres.bhscale*qemres.frespx-qemb0.frespx...
% (qemb.frespx-qemb0.frespx)-(qemres.bhscale*qemres.frespx-qemb0.frespx)]);
% else
% plot(gca,sbpm,-qemb.pm.alpha*(qemb.frespx-qemb0.frespx));
%
% end
% hold on;
% plot(gca,sbpm,(dxs(indbs)'-(-qemb.pm.alpha*qemb0.frespx)));
% ax=axis(gca);
% ym=max(abs(ax([3 4])));
% axis(gca,[0 844.39 -ym ym]);
% ylabel(gca,'\eta_x [m]');
% grid(gca,'on');
% legend(gca,'\Delta\eta_x measured','\Delta\eta_x fit','\Delta\eta_x difference','\Delta\eta_x simulator','Location','NorthWest')
%
% subplot(2,2,4)
%
% if isfield(qemres,'frespz')
% plot(gca,sbpm,-qemb.pm.alpha*[qemb.frespz-qemb0.frespz...
% qemres.bzscale*qemres.frespz-qemb0.frespz...
% (qemb.frespz-qemb0.frespz)-(qemres.bhscale*qemres.frespz-qemb0.frespz)]);
% else
% plot(gca,sbpm,-qemb.pm.alpha*(qemb.frespz-qemb0.frespz));
%
% end
% hold on;
% plot(gca,sbpm,(dzs(indbs)'-(-qemb.pm.alpha*qemb0.frespz)));
% ax=axis(gca);
% ym=max(abs(ax([3 4])));
% axis(gca,[0 844.39 -ym ym]);
% ylabel(gca,'\eta_z [m]');
% grid(gca,'on');
% legend(gca,'\Delta\eta_z measured',....
% '\Delta\eta_z fit','\Delta\eta_z difference',...
% '\Delta\eta_z simulator','Location','NorthWest')
%
% disp('simulator (will be removed)');toc;
%%
% if (isfield(handles,'compare') && handles.compare) || ...
% (isfield(handles,'pushbutton13') && strcmpi(get(handles.pushbutton13,'Enable'),'Off'))
if all(isfield(qemres,{'resph','respv','frespx'}))
diffh=qemb.atresph-qemres.resph; % Response H -> H in m/rad
diffv=qemb.atrespv-qemres.respv; % Response V -> V in m/rad
diff1=[diffh diffv];
residual=std2(diff1(:));
hdispresidual=qemb.pm.alpha*std2(qemres.bhscale*qemres.frespx-qemb.frespx);
fprintf('residual H = %g m/rad\n', std2(diffh(:)));
fprintf('residual V = %g m/rad\n', std2(diffv(:)));
mess=[mess;' ';['orbit residual = ' num2str(residual)];...
['H disp. residual = ' num2str(hdispresidual)];...
[];...
[num2str(length(qemres.wrongbpms)) ' bpms not used: ' num2str(qemres.wrongbpms,'%d ')]];
qemplotresp(4,diffh,diffv,'deviation');
end
if all(isfield(qemres,{'resph','respv','frespx'}))
diffh=qemb.atresph-qemres.resph; % Response H -> H in m/rad
diffv=qemb.atrespv-qemres.respv; % Response V -> V in m/rad
diff1=[diffh diffv];
residual=std2(diff1(:));
hdispresidual=qemb.pm.alpha*std2(qemres.bhscale*qemres.frespx-qemb.frespx);
fprintf('residual H = %g m/rad\n', std2(diffh(:)));
fprintf('residual V = %g m/rad\n', std2(diffv(:)));
mess=[mess;' ';['orbit residual = ' num2str(residual)];...
['H disp. residual = ' num2str(hdispresidual)];...
[];...
[num2str(length(qemres.wrongbpms)) ' bpms not used: ' num2str(qemres.wrongbpms,'%d ')]];
qemplotresp(4,diffh,diffv,'deviation');
end
% end
disp('plot disp'); toc;
disp('plot disp'); toc;
if isfield(handles,'text3') % displays values
set(handles.text3,'String',mess,'FontSize',10);
......@@ -173,29 +87,19 @@ if isfield(handles,'axes4') % displays corr. strengths
legend(extfigax,'initial','corrected');
title(extfigax,'Corrector strengths');
grid(extfigax,'on');
else
Nc = length(qemb.cor);
extracor = mod(Nc,32); % remove extra correctors from injection cells
cor_per_cell_std = squeeze(std(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),1,2));
% cor_per_cell_mean = squeeze(mean(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),2));
bar(handles.axes4,cor_per_cell_std,'EdgeColor','none');
title(handles.axes4,'std Corrector strengths (per cell)');
legend(handles.axes4,'initial','corrected');
grid(handles.axes4,'on');
end
Nc = length(qemb.cor);
extracor = mod(Nc,32); % remove extra correctors from injection cells
cor_per_cell_std = squeeze(std(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),1,2));
% cor_per_cell_mean = squeeze(mean(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),2));
bar(handles.axes4,cor_per_cell_std,'EdgeColor','none');
title(handles.axes4,'std Corrector strengths (per cell)');
legend(handles.axes4,'initial','corrected');
grid(handles.axes4,'on');
end
% not working, wrong handle. write below code to enable zoom in out in GUI
% figures.
% set(handles.axes1,'toolbar','figure');
% set(handles.axes1,'menubar','figure');
% set(handles.axes2,'toolbar','figure');
% set(handles.axes2,'menubar','figure');
% set(handles.axes3,'toolbar','figure');
% set(handles.axes3,'menubar','figure');
% set(handles.axes4,'toolbar','figure');
% set(handles.axes4,'menubar','figure');
function bave=baverage(b)
bb=mean(sr.fold(b),2);
......
......@@ -48,24 +48,19 @@ if isfield(handles,'axes4') % displays corr. strengths
legend(extfigax,'initial','corrected');
title(extfigax,'Corrector strengths');
grid(extfigax,'on');
else
% colormp default;
Nc = length(qemb.skewcor);
extracor = mod(Nc,32); % remove extra correctors from injection cells
cor_per_cell_std = squeeze(std(reshape(...
qemb.skewcor((1+extracor/2):(Nc-extracor/2),:),...
32,[],size(qemb.skewcor,2)),1,2));
% cor_per_cell_mean = squeeze(mean(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),2));
bar(handles.axes4,cor_per_cell_std,'EdgeColor','none');
title(handles.axes4,'std Corrector strengths (per cell)');
legend(handles.axes4,'initial','corrected');
grid(handles.axes4,'on');
end
% colormp default;
Nc = length(qemb.skewcor);
extracor = mod(Nc,32); % remove extra correctors from injection cells
cor_per_cell_std = squeeze(std(reshape(...
qemb.skewcor((1+extracor/2):(Nc-extracor/2),:),...
32,[],size(qemb.skewcor,2)),1,2));
% cor_per_cell_mean = squeeze(mean(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),2));
bar(handles.axes4,cor_per_cell_std,'EdgeColor','none');
title(handles.axes4,'std Corrector strengths (per cell)');
legend(handles.axes4,'initial','corrected');
grid(handles.axes4,'on');
% bar(handles.axes4,qemb.skewcor);
% set(handles.axes4,'XLim',[0 size(qemb.skewcor,1)+1]);
% title(handles.axes4,'Corrector strengths');
% grid(handles.axes4,'on');
end
if isfield(handles,'axes2') % displays vertical dispersion
......@@ -101,80 +96,6 @@ end
%
% % %% compare to simulator
% a=load('/operation/appdata/ebs/optics/settings/theory/errcormodel.mat','errcormodel'); warning('replace by ring simulator lattice or remove');
% rs=a.errcormodel;
% inds=1:length(rs);
% indbs=find(atgetcells(rs,'Class','Monitor'))';
%
% modulh=bmodul(qemb.beta(:,1),qemb0.beta(:,1));
% modulv=bmodul(qemb.beta(:,2),qemb0.beta(:,2));
%
% [ls,ts,cs]=atlinopt(rs,0,inds);
% ss=arrayfun(@(a)a.SPos(1),ls);
% bxs=arrayfun(@(a)a.beta(1),ls);
% bys=arrayfun(@(a)a.beta(2),ls);
% dxs=arrayfun(@(a)a.Dispersion(1),ls);
% dzs=arrayfun(@(a)a.Dispersion(3),ls);
% modulhS=bmodul(bxs(indbs)',qemb0.beta(:,1));
% modulvS=bmodul(bys(indbs)',qemb0.beta(:,2));
%
% %%
% figure;
% subplot(2,2,1)
% qemmodulplot(gca, sbpm, modulh, '');hold on;
% qemmodulplot(gca, ss(indbs),modulhS, '');hold off;
% legend('\beta_x FIT','\beta_x SIMULATOR','Location','NorthWest')
% subplot(2,2,2)
% qemmodulplot(gca, sbpm, modulv, '');hold on;
% qemmodulplot(gca, ss(indbs),modulvS, '');hold off;
% legend('\beta_z FIT','\beta_z SIMULATOR','Location','NorthWest')
%
% subplot(2,2,3)
%
% if isfield(qemres,'frespx')
% plot(gca,sbpm,-qemb.pm.alpha*[qemb.frespx-qemb0.frespx...
% qemres.bhscale*qemres.frespx-qemb0.frespx...
% (qemb.frespx-qemb0.frespx)-(qemres.bhscale*qemres.frespx-qemb0.frespx)]);
% else
% plot(gca,sbpm,-qemb.pm.alpha*(qemb.frespx-qemb0.frespx));
%
% end
% hold on;
% plot(gca,sbpm,(dxs(indbs)'-(-qemb.pm.alpha*qemb0.frespx)));
% ax=axis(gca);
% ym=max(abs(ax([3 4])));
% axis(gca,[0 844.39 -ym ym]);
% ylabel(gca,'\eta_x [m]');
% grid(gca,'on');
% legend(gca,'\Delta\eta_x measured','\Delta\eta_x fit','\Delta\eta_x difference','\Delta\eta_x simulator','Location','NorthWest')
%
% subplot(2,2,4)
%
% if isfield(qemres,'frespz')
% plot(gca,sbpm,-qemb.pm.alpha*[qemb.frespz-qemb0.frespz...
% qemres.bzscale*qemres.frespz-qemb0.frespz...
% (qemb.frespz-qemb0.frespz)-(qemres.bhscale*qemres.frespz-qemb0.frespz)]);
% else
% plot(gca,sbpm,-qemb.pm.alpha*(qemb.frespz-qemb0.frespz));
%
% end
% hold on;
% plot(gca,sbpm,(dzs(indbs)'-(-qemb.pm.alpha*qemb0.frespz)));
% ax=axis(gca);
% ym=max(abs(ax([3 4])));
% axis(gca,[0 844.39 -ym ym]);
% ylabel(gca,'\eta_z [m]');
% grid(gca,'on');
% legend(gca,'\Delta\eta_z measured',....
% '\Delta\eta_z fit','\Delta\eta_z difference',...
% '\Delta\eta_z simulator','Location','NorthWest')
%
% disp('simulator (will be removed)');toc;
%
%
%
if isfield(handles,'selplot') % additional plot
sempanelplot(5,handles.selplot,qemb0,qemb,qemres);
......
......@@ -52,27 +52,27 @@ if nargin >= 4 % displays quad rotations
grid(extfigax,'on');
%% set(ax,'Xlim',[0 nq+1],'XTickLabel',labels,'XTickLabelRotation',30);
else
Nc = length([diptilt]);
extracor = mod(Nc,32);
cor_per_cell_dip = squeeze(std(reshape(diptilt((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
Nc = length([tilts]);
extracor = mod(Nc,32);
cor_per_cell_quad = squeeze(std(reshape(tilts((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
% colormap default;
yyaxis(ax,'left');
bar(ax,[cor_per_cell_quad],'EdgeColor','none');
ylabel(ax,'\Theta');
yyaxis(ax,'right');
bar(ax,[cor_per_cell_dip],'EdgeColor','none');
legend(ax,'std quad','std dip');
grid(ax,'on');
set(ax,'Xlim',[0 32+1],'FontSize',6);
end
Nc = length([diptilt]);
extracor = mod(Nc,32);
cor_per_cell_dip = squeeze(std(reshape(diptilt((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
Nc = length([tilts]);
extracor = mod(Nc,32);
cor_per_cell_quad = squeeze(std(reshape(tilts((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
% colormap default;
yyaxis(ax,'left');
bar(ax,[cor_per_cell_quad],'EdgeColor','none');
ylabel(ax,'\Theta');
yyaxis(ax,'right');
bar(ax,[cor_per_cell_dip],'EdgeColor','none');
legend(ax,'std quad','std dip');
grid(ax,'on');
set(ax,'Xlim',[0 32+1],'FontSize',6);
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